8 ms·
OOP Before OOP with Simula
- thomasfl 7y agoIt’s worth boring that OOP was invented by Lisp programmers. Simula was the first language were you could write class. At the University of Oslo in Norway, most computer science courses used Simula up until the late 1990’s. Some of the lectures was held by the inventors of OOP themeselves.
- seanmcdirmid 7y agoWell, there was also first language to do prototype OO (sketchpad) back in 1962. Also the first VPL and probably constraint based programming language as well.
- tyingq 7y agoI like Perl's approach to OOP. Almost 100% of it is a single function, bless(). Everything else is just namespaces, which isn't specifically an OO thing. There's no magic "this" or "self", so the OO is very easy to understand.
- e12e 7y agoI'm not sure I wouldn't call the fact that -> function/procedure invocation prepend the caller (aka self) as "not magical"? This seems rather similar to python with its explicit self argument to methods? https://perldoc.perl.org/perlootut.html https://perldoc.perl.org/perlootut.html
- tyingq 7y agoFair. "Understandbly and implicitly magical". Is there a lang doing it better?
- e12e 7y agoSmalltalk? (ed: perhaps not quite fair, as message passing/oo is arguably smalltalk's sole paradigm. Common lisp CLOS is another that's also rather clear, but also rather explicit.) Ed2: there's also Dylan, but again rather explicit: https://opendylan.org/documentation/intro-dylan/objects.html https://opendylan.org/documentation/intro-dylan/objects.html As I understand it, rust is rather low on ceremony: https://doc.rust-lang.org/book/ch17-01-what-is-oo.html https://doc.rust-lang.org/book/ch17-01-what-is-oo.html
- marmaduke 7y agoSelf in Python isn't magical, it's just the bound instance conventionally named self. An object isn't magical, just syntactic sugar over a dictionary/namespace. Class syntax isn't magical but syntactic sugar for a call to type function.
- nocman 7y agoUm, perhaps I'm misunderstanding your point, but Perl 5's object model was based on that of Python. And every method of a Perl 5 object receives a $self scalar as its first argument ( see https://perldoc.perl.org/perlobj.html https://perldoc.perl.org/perlobj.html ). In fact, Larry Wall specifically stated in the 11th "State of the Onion" speech that he "stole" Python's object system for Perl 5. I remembered him saying this, so I went to find the transcript. However, I could not find a transcript of the actual speech. I did, though, find this perlmonks.org quote of Larry Wall (from that speech): "I don't really know much about Python. I only stole its object system for Perl 5. I have since repented." https://www.perlmonks.org/?node_id=1212836 https://www.perlmonks.org/?node_id=1212836 So unless you mean Perl 5's "$self" is somehow "non-magic" (whatever you mean by that), I guess I don't understand what you mean when you say it has no "this" or "self".
- tyingq 7y agoIt doesn't have $this or $self. It has @_, which predates the OO that went into Perl.
- nocman 7y agoSorry, just getting back to this. Yeah, it has @_, and in the Perl object model, the first entry in the @_ array is a reference to the object, which is almost always called $self. Anyway, what people name the reference doesn't matter. The point is that it functions like 'this' and 'self' do in other languages, and it is very much required in object methods (which differ from normal subs in that they are passed that first argument automatically).
- k__ 7y agoDoesn't surprise me. If I look how people build class systems with JS before ES2015, I'd guess all languages that have closures and higher order functions could invent OOP. Maybe that isn't even needed IDK.
- jrimbault 7y agoPeople did it in C way back, with usually structs containing their value and a table of functions associated with them (vtable). You can do "inheritance" by having the parent struct be the first member of the child struct. You can do all sorts of fun stuff (composition is easy of course, injection also). The only thing of note, is that you can't "curry" the source, you'll always have to give the "source/this/self" object as an argument to the method. This isn't any different from how you could in python, for example, do : `"my string".split(" ")` or `str.split("my string", " ")`. (just some fun little experiments I did last year https://github.com/jRimbault/DataStructures/blob/master/lib/struct/String.h https://github.com/jRimbault/DataStructures/blob/master/lib/..., there isn't any vtable, but it does show a string "class/struct" with all private fields, and methods for creating, managing those objects)
- mistrial9 7y agoone-deep tables of function pointers with some kind of sensible model on why sets of function pointers are there.. many, many useful applications.
- marmaduke 7y ago> You can do "inheritance" by having the parent struct be the first member of the child struct. You can do all sorts of fun stuff I have done this, 'fun' is not how I describe the result to colleagues
- jrimbault 7y agoAlright, -fun +nightmarish. Still fun though.
- dboreham 7y ago
- foobar_ 7y agoWhoever talks about OOP without mentioning simula should never be hired.