From: Kristof Bastiaensen Date: 2004-05-13T18:14:05+09:00 Subject: Re: Recommendations (Ruby making my head swim) On Thu, 13 May 2004 10:45:29 +0900, Claus Spitzer wrote: > 8< ----- snip ----- >> In so many ways, object-oriented programming is so natural, and Ruby >> lets that emerge so beautifully. Unfortunately, I think it's easy to >> get lost in the terminology. We end up talking about "string objects" >> or worse, "instances of the String class", instead of just saying >> "strings". Eventually, it's important to have those three concepts >> mean the same thing in your head, but until you wrap your head around >> objects and classes, it's just confusing. >> > > And even though this is perhaps > the most important concept in OOP it is also the most ignored one by > professors, which instead jump straignt to terms like encapsulation and > inheritance and polymorphism. I went through three courses that dealt > with OOP (at least remotely) until I came upon a professor that > explained the above before anything else. Once that was understood, > everything else clicked into place. > > -CWSpitzer I agree completely. I find it always annoying when you open a book about "object oriented programming", and it contains twenty times the word "management" on each page, many other buzzwords, diagrams, flow tables, but no example code. In fact Object Oriented Programming is very closely related to human communication and language. Messages (methods) are the verbs, and objects can be seen as Subjects (or vocative, direct object, ....). OO-programming is a very natural way to talk with the computer. Ruby does this perhaps even better than the original OO-language (smalltalk), because constructs like "if" and "while" are part of the languages grammer, not verbs, just like in real life. A nice example of this is a moo (), which is sort of a chat-room with objects. In addition to talking with people you can manipulate objects, create them, manipulate them, etc... It would probably be easy to create one in Ruby. Also the idea of "Duck Typing" is very natural in this regard. (When it quacks like a Duck, you assume it is a duck). You don't care what it is, as long as it responds to what you ask it to do. It is like going to the shop, they will not ask you what you are, as long as you respond to there question to pay. It is interesting that Perl was designed with natural languages in mind, while Ruby (and 00 in general) may even come closer to them. Kristof