[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[school-discuss] Re: Ruby (was: good programming language for learning)



Phil Torrance III wrote:

. Python
is often heralded as an Object-Oriented language, but
its support for Object-Orientation seems to have been
tacked on. Some operations are implemented as methods,
while others are implemented as global functions.
Also, the need for an explicit "self" parameter for
methods is awkward. Some complain about Python's lack
of "private" or "hidden" attributes, which goes
against the Encapsulation/Information Hiding
principle, while others feel that Python's
"privateness is by convention" approach offers all of
the practical benefits as language-enforced
encapsulation without the hassle. The Ruby language,
on the other hand, was created in part as a reaction
to Python. The designer of Ruby decided that he wanted
something "more powerful than Perl, and more
Object-Oriented than Python." You can see this
[comparison of Python and Ruby for more information]
[@]http://dev.rubycentral.com/faq/rubyfaq-2.html

I took a quick look a Ruby just now and it seems like a pretty nice language. Very similar to Python but with more syntactic sugar, most notably for attributes and anonymous functions. I think Python's level of object-orientation is just fine but the syntax is somewhat cumbersome -- partially as a result of Python being older and simpler than Ruby. I read somewhere that the explicit "self" in Python is by design, which I personally don't like.

But from a higher level, it seems like code written in Ruby could be fairly easily converted to Python. The main non-syntactic differences I can see are encapsulation (public/private) and tainting. Things like unified types/classes, metaclasses, static methods, and generators have been recently introduced into Python so it's catching up with Ruby on those fronts. Meanwhile, Ruby's support for embedding is improving.

The syntactic sugar *is* pretty nice. The sugar means that it's not so obvious what a particular line of code does to someone who's not familar with Ruby, compared to Python, but that may or may not be important to you. I may look into Ruby in the future.

- Jason Lai