Popular conceit about learning programming languages

Pascal Costanza costanza at web.de
Sun Nov 24 17:08:00 EST 2002


Donn Cave wrote:
> Quoth Pascal Costanza <costanza at web.de>:
> ...
> | Just recently I have encountered some useful terminological distinctions 
> | in c.l.l that made sense to me. There you have the imperative and 
> | message-passing paradigms on the one hand, and the procedural and 
> | object-oriented style on the other hand. The interesting bit is that 
> | these things are independent. So procedural style is well-suited for the 
> | imperative paradigm and object-oriented is well-suited for the 
> | message-passing paradigm. However, you can also do message-passing in a 
> | purely procedural languages as well as use the imperative style in most 
> | object-oriented languages. I guess that you are thinking along these 
> | lines as well.
> 
> Perhaps I could be, if message passing were clearer to me!

Message passing means that there are several entities that communicate 
by sending messages between them. The main points are that these 
entities are autonomous and that there is no central "main" program that 
controls the behavior of these entitities.

What people usually mean when they say "object-oriented" are things like 
classes, inheritance, overriding, encapsulation, and so on. But these 
features don't guarantee that you have the above mental model in mind. 
(So for example, with overriding you can make sure that a certain set of 
objects respond to certain message in their specific way. It's not clear 
from a message alone what will happen when you send it to a particular 
object; objects are autonomous. However, you can make use of overriding 
even in programs that are essentially imperative.)


> It can be much harder to get something done in pure FP, at least
> that's true for me.  Now, this is obviously because I ``think in
> Python'', or rather I think in procedural terms, and someone who
> ``thinks in Haskell'' will have less trouble.

I have my doubts. When a Haskell program doesn't behave as expected you 
have to know what goes on behind the scenes - you have to know which 
expressions get evaluated at what stage, in which order statements are 
executed, and so on, in order to understand the program's behavior. 
However, languages like Haskell deliberately try to hide these things. 
In contrast, imperative and object-oriented languages make it easy to 
understand what happens when. That's what I mean when I am talking about 
"simpler operational model". (Declarative languages also have 
operational models, you can't do without.)


Pascal

-- 
Given any rule, however ‘fundamental’ or ‘necessary’ for science, there 
are always circumstances when it is advisable not only to ignore the 
rule, but to adopt its opposite. - Paul Feyerabend




More information about the Python-list mailing list