Posted: Aug 12, 2010 10:21 pm
by VazScep
newolder wrote:objects are instances of code data and code methods.

OOP techniques are employed@bluebrain.

Oo is how we think we think.


So the core idea of OOP is its take on how to write modular programs. In most programming languages, it is a good idea to separate how something is used from how it works, and this idea has been cashed out in several ways (APIs, protocols, interfaces, signatures). It is sometimes a good idea to make these modules "hot-pluggable", so that they can be replaced and updated live in a system without ever having to do a rebuild.

Many application designs follow this model even if they are not written in a so-called "OOP language". The Linux Kernel is written in C, and has a modular design such that you can replace parts of the kernel while the system is up and running without ever having to reboot. Every service on the internet follows this model as far as the server and client is concerned. I can switch between browsers and web servers can be replaced without having to restart the internet.

The original OOP language (Smalltalk, not Simula), took this idea and built a programming language in it. A Smalltalk system is a huge collection of objects communicating via implicit protocols that can be hot-plugged live. The ability to manipulate a Smalltalk system live without having to rebuild it is so dramatic that the default way to write a program in Smalltalk is simply to fire up the IDE (a Smalltalk program) and then replace modules until you no longer have an IDE, but instead, you have, say, a music player. The idea is taken to further extremes with "reflection", where the modules of the system which define how the core language works can be replaced. Replace some modules, and suddenly, you're not even writing your program in Smalltalk anymore. The possibilities for error are extremely grim, here. It's easy to do something wrong and screw the system up. This is why Smalltalk arguably has the most sophisticated debugger of any programming language to this day. And of course, that debugger is yet another module that can be replaced, as can individual stack frames in some smalltalks. The possibilities for recovering from errors live are limitless.

I wouldn't call any of these stupid ideas. My criticisms are directed at Java, which did its best to ignore all of them. The only motivation behind Java was to make a secure, garbage-collected language that could be marketed at C++ programmers and which could pay lip-service to OOP which was experiencing a wave of hype at the time. Java started calling itself "pure object-oriented", because it required every bit of code to be defined in a class, leading to the Kingdom of Nouns phenomenon. Smalltalk also requires every bit of code to be defined in a class, but doesn't suffer the same headaches. Again, Java was just paying lip-service, and misses the point completely.

There are multiple threads that could be pursued here, and I suggested starting by talking about static versus dynamic typing, or in more accurate but less familiar terms, nominal versus duck typing. Smalltalk is dynamically typed, as are Python, Perl, Javascript, PHP and Ruby. C++, Java and C# are all statically typed. The presence of typing has a significant effect on the way these languages work and what is possible with them. In particular, the concept of inheritance is heavily downplayed in Smalltalk, Python and Ruby compared to C++, Java and C#.

I'll add another reply tomorrow if this isn't enough to get a discussion rolling.

trash(object) from the verb, to trash, bin etc.
This isn't OOP syntax. It's just an ordinary function application, something which you can do in any high-level language (save Prolog). In (single-dispatch) OOP, you don't trash objects. You tell objects to trash themselves. How's that for mimicking the way humans think?