Python vs Ruby

bruno modulix onurb at xiludom.gro
Fri Oct 21 08:07:17 EDT 2005


Amol Vaidya wrote:
> "Casey Hawthorne" <caseyhHAMMER_TIME at istar.ca> wrote in message 
> news:02efl19c4n4994vtlt2ubrs7ulg4mcm8ug at 4ax.com...
> 
>>What languages do you know already?
>>
>>What computer science concepts do you know?
>>
>>What computer programming concepts do you know?
>>
>>
>>Have you heard of Scheme?
>>
>>
>>Ruby is a bit Perl like -- so if you like Perl, chances are you might
>>like Ruby.

Ruby is a whole lot Smalltalk-like -- so if you like Smalltalk... !-)

>>Python is more like Java.

<troll>
Err... Python is more like what Java would have been if Java was a smart
 dynamic hi-level object oriented language !-)
</troll>

>>I have heard, but have not been able to verify that if a program is
>>about
>>10,000 lines in C++
>>it is about
>>5,000 lines in Java
>>and it is about
>>3,000 lines in Python (Ruby to?)

For a whole lot of common tasks (like file IO etc), the Java/Python loc
ratio is between 5/1 and 10/1. Also, not having the dumbest type system
in the world, Python is naturally much more generic than Java, which
saves a lot of boilerplate code. I think that the real numbers would be
much like 5000 lines in Java -> 1000 lines in Python - and probably 5000
-> 500 in some cases.

> 
> I've done a lot of studying on my own, and taken the classes that my 
> high-school offers. I feel that I have a fairly good understanding of Java, 
> and basic OO concepts due to that. 

<IMHO>
Err... I wouldn't start another HolyWar, but Java is not that Object
Oriented. 'Class-based' would be more appropriate. Python, while not
being class-based (ie: it doesn't impose that all code goes into a
'class' statement), is much more an OO language than Java, since in
Python *everything* is an object - even functions, classes and modules.
This makes a *big* difference.

So yes, you may have learned some basic 00 concepts with Java (classes,
instances, inheritence and polymorphism), but with Python and/or Ruby,
you will probably realize that there's much more in the OO paradigm than
all the Java world can dream of.
</IMHO>

> 
> Well, I'm not sure what you mean by programming concepts. I'm familiar with 
> OO through Java, and procedural programming through C. I'd be more detailed, 
> but I'm not exactly sure what you are asking. Sorry.

patterns, metaclasses, aspects, closures, anonymous functions,
higher-order functions, multiple dispatch, properties (computed
attributes), generators, list expressions... does that ring a bell ?

> I have no idea what Scheme is, but I'll cettainly look it up as soon as I'm 
> done writing this.

Scheme is a Lisp dialect - Lisp being one of the oldest programming
languages, and one of the most modern programming languages. Whatever
the latest overhyped revolutionary new silver bullet buzzword stuff, you
can bet your ass Lisp already had it many years ago.

Now Lisp never managed to make it to the mainstream... It's a language
(well, a familly of languages should I say) that is worth learning, but
probably not until you've become familiar with some Python features and
idioms.

Another language that failed to make it to the mainstream but is worth
giving a try is Smalltalk - the father of OOPLs (Simula being the
GrandFather). BTW, most of Ruby's feature have been happily stolen from
Smalltalk !-)

> I've never given Perl a shot. It was another language I considered learning, 
> but my father's friend told me to go with Python or Ruby.

+1



-- 
bruno desthuilliers
ruby -e "print 'onurb at xiludom.gro'.split('@').collect{|p|
p.split('.').collect{|w| w.reverse}.join('.')}.join('@')"
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list