Should I Learn Python or Ruby next?

MRAB python at mrabarnett.plus.com
Tue Jun 22 22:31:53 EDT 2010


rantingrick wrote:
> On Jun 22, 7:56 pm, Gregory Ewing <greg.ew... at canterbury.ac.nz> wrote:
>> Thomas Jollans wrote:
>>> "Everything is an object" in both languages, or so they say.
>> That's really a meaningless statement, because it depends on
>> what you count as a "thing". But there is at least one thing
>> that is an object in Python but not in Ruby. There are no
>> stand-alone functions in Ruby, or callable objects in general.
>> The only way to invoke code is to call a method of some
>> object.
> 
> Although i will admit the chaining of methods compared to the nesting
> of built in functions seems more linear-ly natural as in this case...
> 
> RUBY:
> ['one', 'two', 'three'].map{|x| x.capitalize}.join(',')
> 
> PYTHON
> ','.join(map(string.capitalize, ['one','two', 'three']))

','.join(x.capitalize() for x in ['one','two', 'three'])

> ','.join(map(lambda x:x.title(), ['one','two', 'three']))
> 
> ...but i digress
> 
>> This can be confusing to someone coming from Python, because
>> you can write what *look* deceptively like top-level function
>> definitions. But they actually become methods of class Object,
>> which is inherited by everything, and thus become implicitly
>> available in any other method.
> 
> Yes i call that "Ruby's Global Nightmare" and the folks over at
> SketchUp are learning day by day how this nightmare is going to
> undermine the Ruby API. Not only that, but since the API is for
> scripting it seems more natural to use Pythonic namespaces so you can
> write simple scripts very easily with one or two functions or complete
> packages spanning multiple modules without fear of name clashes (ever
> tried debugging that! 8^O). Of course you can create a module with
> Ruby (see next comment)
> 
[snip]
Napoleon once said "Never interrupt your enemy when he is making a
mistake."! :-)




More information about the Python-list mailing list