Meaning of Object in Computer Languages

By Xah Lee. Date: . Last updated: .

object! you hear it about in every lang, every lang's docs. Though, their nature is quite different.

Java's Concept of Class/Object

In Java, “Object” refers to a instance of a class.

here's a quote from Java lang spec:

What is a Java Object?

The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types (§4.2) are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types (§4.3) are class types, interface types, and array types. There is also a special null type. An object (§4.3.1) is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object (§4.3.2). String literals are represented by String objects (§4.3.3).

[http://docs.oracle.com/javase/specs/jls/se7/html/index.html]

java se 7 spec chapter 4 c3qWR
java doc on java.lang.Object [http://docs.oracle.com/javase/specs/jls/se7/html/index.html]

Also, “Object” may also mean java.lang.Object. It is root class of all classes.

java object 2022-07-01 XYWFT
[http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html]

“class” is a language keyword. (for code example, see: Java Tutorial: The “extends” Keyword.)

“class” also refers to the datatype created by a constructor with keyword “class”.

Python's Concept of Class/Object

Now, python, is also OOP. However, its concept of class/object is very different from Java. But in python, “object” and “language data type” means about the same thing.

In python, most values, is a “object”. A string is object. A list is object. Hash table is object. And they all have methods. In contrast to Java, there is not much sense of “class” in the language, but it has “object”, defined as a language data type.

here's a quote from python doc

python 3.5.9 doc 3.1 2022-07-01 rJps3
3. Data model — Python v3.5.9 documentation

Objects are Python's abstraction for data. All data in a Python program is represented by objects or by relations between objects. (In a sense, and in conformance to Von Neumann's model of a “stored program computer,” code is also represented by objects.)

Every object has an identity, a type and a value. An object's identity never changes once it has been created; you may think of it as the object's address in memory. The ‘is‘ operator compares the identity of two objects; the id() function returns an integer representing its identity.

An object's type determines the operations that the object supports (e.g., “does it have a length?”) and also defines the possible values for objects of that type. The type() function returns an object's type (which is an object itself). Like its identity, an object's type is also unchangeable. [1]

3. Data model — Python v3.3.3 documentation

Python's class/object is almost the reverse of Java's class/object. In python, object is the class. Object is a language data type. “Class” is a convenient programer term.

Although almost every value in python is object, but you don't really have to do OOP. For example, you can translate the entirety of shell scripts on earth to python, sans a iota of oop. In fact python is often used for sys admin, as perl.

Though, python the lang is heavily “object” tied, and you have to buy it in order to live in it. Its doc, its data types, all talk and revolve about objects. God forbid you don't think of objects.

Lisp Object

in lisp, you also have object. Though, here, the “object” isn't any object of OOP. In lisp, “object” basically means the internal representation of your lisp expression.

here's a quote from emacs lisp manual:

emacs lisp manual object 2022-07-01 SzTKC
emacs lisp manual object 2022-07-01 SzTKC

A Lisp “object” is a piece of data used and manipulated by Lisp programs. For our purposes, a “type” or “data type” is a set of possible objects.

Lisp Data Types (ELISP Manual)

[see Xah Emacs Lisp Tutorial]

JavaScript Object

in JavaScript, almost everything is also a object. [see JS: Object Type] However, js object is nothing like Java/python, nor as lisp's internal entity.

JavaScript object is basically a hash table, by definition. So, in sharp contrast to java, js in fact do not have any class at all. But also, in sharp contrast to python, even though everything is a “object” in both languages, yet JavaScript's object has almost nothing to do with OOP. What oop it has, is mostly created by people, as libraries.

Node.js Object

In node.js, its “object” is used mostly as a namespace mechanism. See: Node.js Dot Notation as Namespace Mechanism

C Language Object

here's what [Nick Alcock https://plus.google.com/115849739354666812574/posts] says about C:

C has objects too, pretty much denoting “a thing in memory which can have a value, or whose components can have values”. (Thus, a bitfield is an object, even though you can't take the address of it; a string constant is an object even though you can't modify it, and even though it's an array; a function is not an object, even though you can take its address.)

This is a rather ad-hoc definition mostly used to declare in the standard that certain things can be done to objects that cannot be done to anything else (such as freely casting pointers to them to void *, which you can do to an array, but not to a function pointer, since that's not an object).

However, note that this terminology postdates OOP: nobody was talking about “objects' when C was young. So this, like ‘const’”, is actually terminological leakage back from OOP languages (mostly C++, which was already several years old when the C standardization effort began) into C.

The Point of Confoundedness

one might ask, what's the point?

it's confounding!

Google Plus discussion:

https://plus.google.com/+XahLee/posts/ERPZ7vW3Son

https://plus.google.com/+XahLee/posts/DWyfwpiyzEm

Thanks to [Dan Lentz https://plus.google.com/+danlentz/posts] on correction on Java's Object terminology.