Python vs. Ruby, Again
The level of a language has always become an interesting phenomenon. I can see that most young languages tend to “raise” their language level; making it closer to humans (programmers) than to machines. The benefits of a very high level language is of course obvious: programmers code less and become more productive. Most computers todays are fast, and productivity is better than (insignifficant) performance gain in most cases. And up to today… I can see two languages that have top-notch language level: Ruby and Python.
Both Ruby and Python are the most famous all-purpose scripting languages. By all-purpose, I mean it is used to solve diverse and different sets of problems as easy as possible. By scripting, I mean that from coding to execution phase, one does not have to do a compilation phase (at least apparently so). Just from these factors, we can see that all-purpose scripting languages are very high level languages: more closer to natural language than machine language.
My views may not be that valid: I have never made non-trivial programs in any of the languages. My view can be regarded as the view of someone that is eager to learn either Ruby or Python, and make decisions based on preliminary tutorials, language power, and complexity. This first-time impression is more important than most people think – a good impression will let more people join the language community and then contribute to it, thus strengthening the language.
At the first glance, Ruby looks very powerful. For example, to print hello 5 times, we can write 5.times { print "hello" } in Ruby. Cool eh? Ruby’s paradigm (Everything is Object) is one of the best IMHO. Ruby does not merely “support” OOP; Ruby builds on OOP. Its magnificent access control, mixin mechanism, and operator overloading is often left behind by other modern programming languages (e.g. Java expelled operator overloading, Python has no real access control).
However, after skimming the whole Ruby tutorial, I feel that although some claims that Ruby is easy to learn, it is not that easy. There are lots of things one must learn from a typical C or Pascal programmers: closures, blocks, variable name convention… (we assume that that person knows OOP). These are language features, however, which made Ruby more complex than Python (and more complex can be better or worse; it depends).
Compare Ruby to Python. In Python we can’t of course write 5.times { print "hello" }. One should write for i in range(5): print "hello", a typical procedural flavor. Its grammar is much more concise than Ruby, and maybe the most concise of all programming languages, mainly because it terminates statement group automagically according to indentation. The learning curve is, IMO not very deep: Ruby’s is deeper. The new stuff (primarily slicing and list comprehensions) can be ignored when teaching starters. I also have the impression that Python has better and larger community than Ruby; for example, there are no Ruby game programming projects or community with size matching that of PyGame. Python is even used by Google.
Python sadly does not feature a great new paradigm shift: it merely simplifies coding to a certain extent (but it does it well, admittedly). Python also got a minus point in it standard libraries, because they have no standard class, module and method naming convention (it got mixed up in joinedwords or underscore_separated_words and even camelCase and PascalNotation). Ruby seems to be good at using PascalNotation for classes and underscore_separated_words for class methods, and even has wonderful conventions for destructive, non-destructive and query functions (with ? and ! in the end of function name), as well as class, instance, global, and local variables.
My conclusion is that while Ruby offers a better ideology in programming, Python’s community and simplicity wins over it. Both are great programming languages, and Python only wins by a tiny fraction. If Ruby expands well and gained substantial addition to its community base, I am sure that Ruby will tip over Python some day.
1 comment
times 5
You can do the following in Python:
>> print "hello" * 5
Your point about python not being fully object-oriented still stands.
Post new comment