Shared publicly  - 
 
the meaning of “object” in computer languages.
xah's rumination extempore, №201311271937 

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

Java, is a tight pant. The whole language is encased in class/object model. In fact, except some primitive types, everything in the lang is a class. In fact, the entire lang, what Sun Micro scum called API/Platform, is a giant class tree. In Java, the class/object thing has a rather definite meaning. A Class is kinda like a factory, from which spring objects. To do things in Java, first you create a factory to spawn the object things. Class/Object in Java, we might say is the classic.

Now, python, is also OOP. However, the nature of class/object in the lang is rather different from Java. Class in python is still a factory, from which spawn objects. But, you don't have to write a class to do things. in java, {class, object, language data type} are distinct concept. But in python, {object, language data type} means about the same thing. So, 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 general, python is more flexible and dynamic than java. Although almost every value in python is object, but you don't really have to do OOP. And you don't have to define any class if you don't want to to write any program, however large or comple. For example, you can translate the entirety of existing shell scripts to python, without oop in sight. 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 well among its community. its doc, its data types, all talk and revolve about objects. God forbid you don't think of objects.

in lisp, you also have object. Though, here, the “object” isn't any object of OOP. Basically, any source code, any expression, is considered a object when it is run. In lisp, “object” basically means the internal representation of your lisp expression. So, when you type (list x y), and when you eval it, it's said to be lisp object. Of course, some lisp has OO systems as add on, and object have different meaning there.

in JavaScript, almost everything is also a object. However, js object is nothing like Java/python, nor as lisp's internal entity. JS object is pretty much just a hash table. 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 almost every js entity is object, yet js has almost nothing to do with oop. What oop it has, is mostly created by people, as libraries.

JavaScript Tutorial by Example
http://xahlee.info/js/javascript_basics.html

Xah Emacs Lisp Tutorial
http://ergoemacs.org/emacs/elisp.html

Xah's Java Tutorial
http://xahlee.info/java-a-day/java.html

Xah's {Python, Perl, Ruby} Tutorial
http://xahlee.info/perl-python/index.html
JavaScript Tutorial by Example. Xah Lee. , 2009-01-30 , …, 2013-11-14. Tweet. This page will quickly get you started on JavaScript the language. You need to have basic understanding of the language before you can script the DOM/web.
3
Fabrice Popineau's profile photoXah Lee's profile photoNick Alcock's profile photo
14 comments
 
In Common Lisp, you have a true object oriented language (actually the first one acknowledged by the object Management Group in 1994).
Classes, methods, instances and a full featured object oriented protocol. Plus the type system of CL is fully integrated with the object system.
Xah Lee
 
right, but it's a add on package right? the CLOS?
 
Quite. Fixating on the meaning of what a given language happens to call an 'object' is pointless, since lots of languages use that word for things that have nothing to do with OOP (even C has objects in that sense, hallowed in the language standard no less: C99 refers to objects 680 times and not one is an OOP object). Instead, you want to focus on whatever that language has that acts like an OOP object, be it called objects, classes, or whatever. (Plus, of course, every language has a slightly different focus on the idea, from the Java everything-is-an-ADT approach through the C++ optional approach through the original SmallTalk and Simula message-passing approach through the scripting language bag of attributes.)
Xah Lee
 
+Nick Alcock right. And a long time gripe of mine similar here is meaning of "list". Which the lispers at comp.lang.lisp have left a real bad taste for me.

list means quite a lot different things in different langs, but often, when in argument in a particular lang community, the people ignore, deny, any other meaning, insisting any code, tutorial, writing, not using their meaning is wrong or troll. This was the case with many common lisper regular fuckheads in comp.lang.lisp when i was active there about a decade ago.

a listy thing that's fixed in length and allow fast access is most often called array.

listy thing that's chained as in lisp, is often called list or linked list.

lisp's vector is array.

Mathematica's List[] is array.

perl's array and python's list are ... not sure what they called technically, but perhaps a smart array. That is, array with auto expansion feature without being slow. Specifically, it's not lisp's linked list. I believe ruby's array is similar here.

what perl calls a list, is actually only a syntactic thing. Once it's set to a var, it's called array.

PHP's list is a mix and array and hashmap. It's really a hashmap with magic. But when keys are not used/set, it auto default to numbers in sequence, as array.

JavaScript's array is really a hashmap, what it calls object, with some magic. The index of js's array is actually just the name of keys that happens to be positive integer...
Xah Lee
 
also, the name for the whole family of listy thing is called by different names in different lang.

lisp calls it “sequence”. (but not including hash table, but includes associative list)

Java calls it “collectible”.

Python wants to call it “sequence”, and if counting {hash, map, sets} it's called “container” type.

“hash table” is known as “map” in java, “dictionary” in python, “property” in javascript, “array” in PHP. But in {perl, ruby, lisp}, it's just called any of {hash, hash map, hash table}.

i also heard “aggregate”, but not sure which lang uses that. Where?
 
Yeah, every language has semi-overlapping names for its data structures :) there aren't enough names in English is the problem.

You won't find me claiming that there is Only One True List because I came out of the era when you had to write your own data structures: I must have written dozens of list ADTs (and non-A DTs) and every one was different.

Dunno who uses 'aggregate' for a list-like entity. DTrace uses 'aggregation', but that's not for a list at all but for something much more bizarre: <http://docs.oracle.com/cd/E37670_01/E38608/html/dt_agg.html>
Xah Lee
 
+Nick Alcock thanks. One question i have. Do you know how's python, perl, ruby's implemented is called technically? they are array (fixed length, fast random access, but when appended, it auto add n slots internally, where n is algorithmically  determined)

my second question is, why didn't lisp do that? perhaps not today because nobody'd work on it, but why didn't it happen say 20 or 30 years ago? because cons and vector are already habituated?
 
I have no idea about any of that, really. [vectors] might well work that way in a modern Lisp implementation. Lists don't because back in the days of yore it would clearly have been insane to do anything involving mega-copying of list contents just in order to extend them, and very risky (what if there wasn't enough contiguous memory? No virtual memory, remember, and memory was expensive enough that wasting a whole max-size-of-list's-worth just in case you wanted to expand a list was a mad idea.)
Xah Lee
 
+Nick Alcock i thought you'd be interested. I don't know C, and you are C expert that's why i asked you. Am not actually sure they do mega copy... but i remember googled about it... it's easy to find articles that discuss their implementation, including pointing to the C source code.
 
I have the source of all three here, actually.

 - A Python (2 and 3) list is a C array of pointers to elements. Its size is boosted in sub-exponential steps when needed. (This is optimal given modern malloc()s.)
 - A Ruby (1.9.3) array is a C array, similarly structured, but is boosted in exponential steps. Maybe they don't realise malloc() has improved since SunOS 4.
 - I tried to look up how Perl lists worked and my eyes bled out of my skull. Perl's implementation is every bit as unimaginably awful as it was last time I looked at it.
Xah Lee
 
+Nick Alcock super cool! thank you. I envy you the ability to look up C code on anything!
 
That's not hard, all you need is a hundred GiB or so and a Gentoo installation :P without something like that, you don't really have the source, you just have the potential for it. (And yes, sometimes I really do grep the entire thing. I wish Google Code Search was still going, it was much faster.)
Add a comment...