On Apr 24, 2012, at 5:18 PM, Lew Schwartz wrote:
> Just as a matter for curiosity, has anyone fooled around with RUBY as
> a second language? Can you offer any comments as to ease & scope of
> use vs Python (for example)?
Both Ruby and Python are great languages, and share many of the same
advantages. The preference for one over the other largely depends on two
things: your feeling towards terse vs. verbose code, and which one you learned
first.
People who know Ruby get annoyed by some of Python's differences, and
vice-versa. So the real difference is the coding style differences, not
personal preference.
Ruby follows the Perl philosophy of several ways to do the same things,
and preferring non-alpha syntax characters over more English-like syntax. Here
is an example of a basic loop in Python:
for i in range(5):
print i
...and the same in Ruby:
(0..5).each do |i|
puts i
end
I can think of at least 3 other ways of writing the Ruby version -
that's simply part of the overall Ruby philosophy.
One of the things that I think is a horrible aspect of Ruby is the
implicit return value: any statement returns the value of the last evaluated
expression. When this happens in a method, and the method does not have an
explicit 'return' statement, the method returns that last evaluated value. This
can be used well in many cases, but in my experience, results in a lot of
hard-to-detect bugs.
Python, OTOH, has as one of its core principles "explicit is better
that implicit". If a method lacks a return statement, None (the Python null
value) is returned. IMO, this makes much more sense.
Another thing that annoys me about Ruby code is the lack of comments.
Since the majority of influential Ruby developers are heavily into TDD, they
feel that comments are worthless: if you want to know what some code is doing,
you should read the corresponding test for that code. Do you need to handle an
edge case? Then there should be a test for that edge case, and thus no need to
add a comment to your pristine code.
-- Ed Leafe
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.