Placeholder Image

ADN Informatique

Consultant Ingénierie Informatique

Saguenay (Jonquière), Québec, Canada. Tél: (581) 683-9887 Téléc: (581) 221-0874

Placeholder Picture


Programmation objet

2008-11-18 10:49:20 (ID: 90, Parent: 0, Type: post)
 Extrait d'une entrevue avec le créateur du langage Erlang.  Il parle de sa vision de la programmation orientée objet.

You've been reading my OOP sucks blogs. I saw a blog yesterday, they said Erlang is actually more object oriented, truer to the spirit of pure object orientation than all object oriented languages. You could take two views: you could say either Erlang isn't object oriented - which I used to say a few years ago - or you could say it's more object oriented than all the object oriented languages. Alan Kay said that he made a mistake in not really emphasizing the messaging aspect of object oriented programming. He said in SmallTalk you talk about sending a message to an object, but you don't, you do a function call. I think function calls and remote procedure calls are too high-level in the sense that a function call or a remote procedure call returns to the person who made it.

If I do remote procedure call against you, I can say "Hey, do this!" and the answer automatically comes back to me, but that's not how we work. I could say "You do that" and reply to this guy. Why am I involved? That's how we behave. If you are a manager at office you say "Can you check this out? When you've done it, tell this guy". This is just an asynchronous message passing model. I think when you talk about object orientated programming, when you model a world, you are encouraged to think in terms of objects and I don't see objects. I also have what you would call the categorization problem: which object do I put my code in? Sorry I just don't get this. Let's suppose you have a method, in SmallTalk terms, that manipulates time of a directory structure or something like that, is this a subclass of a time object or is it a subclass of a directory object? I don't know.

Years ago I've started several projects staff - file my data/my letters, physical papers and research reports and things like that. Every time I've done that it failed, because I get files and I put something on this line - it says "Correspondence", "Lectures", "Papers". Then I get this thing: it's a paper, I put it in the file called papers; this is a letter which contains a paper "Do I put it in 'Correspondence' or do I put it in 'Lecture notes'?". It breaks down because I don't know where to put it. I think if you've got objects in your function, which object do you put it in? I made another filing scheme, in which I just numbered everything, and I have files and I go over my office and the first file says 1-167 and the next file says 168- something. I have a single file that goes 1,2,3,4 and some text. I use emacs to create, I use grep to search, and it's a brilliant system!

This is how we organize things in English. We have a dictionary and when we want to know what the word means, we look it up in the dictionary. Everything is in alphabetical order - that's a good way to organize data. I think object oriented programming is not a good way to organize data. There is a principle in programming "Never write something twice" - yes, it's a fine principle, a great principle, but let's think about this: "How do I find the old stuff, that I am going to reuse?" That becomes extremely difficult, in fact, I think people have been deluded into thinking that this choice is easy. When I started programming, there were no choices, I programmed everything in Fortran - Fortran was the only language I had on my machine. Nowadays, some poor sod's got to choose the programming language: "Should I have Java or C# or C++ or Lua or F# or Pascal or Prologue or Erlang or Haskell? On what should I do it?" "You don't want something in the-NET framework or a Java framework that runs on the JVM or on Mac OSX?"

You have all these decisions, incredibly difficult to make, and then you got bosses. You don't write this stuff in scratch! You got to reuse somebody else's code. After all that is. Somebody else's code doesn't do exactly what you want - it does something that's subtly different. Then, the time taken to modify and understand this old code takes an incredible amount of time. Have you ever sat there with code that somebody else has written and have to modify it? You spend hours and hours doing it. You can't reuse object oriented code, because all the stuff it inherited has to be there as well. You can't just take this stuff out and put it in your program cut and paste, like you did in C, or Erlang or Prologue or Perl, you got to take all the stuff it inherits from.

One of the problems I had with object oriented programming, one guy said: "You wanted a banana but what you got was a gorilla that was holding the banana and the entire jungle. You got a lot of stuff in it and all you wanted was just a little bit of code". The Lisp idea - lots of little functions - ubiquitous data structures like Lists, everywhere, and lots of very small functions that work on this, that these are highly reusable. Code that's referentially transparent, that means if you call it twice with the same arguments, you get the same value - it's very reusable. To them the question is "How do we reorganize all this stuff? I think something like a dictionary, like the English dictionary, put in alphabetical order. Don't put lots of modules, just put one module! If code is referentially transparent, it's small functions, then it doesn't belong to object. Where does it belong? What is the containing object? There isn't one! So, just put them all in alphabetical order and use Google to search it and you'll find the code easily.

Document Informatif

ADN Informatique


Rev. 1

Jean-Luc Cyr