blog/recovered/2007.09.26-python-and-ruby-brain-dump.md
2011-12-02 23:24:03 -08:00

3.2 KiB
Raw Blame History

Title: Python and Ruby brain dump Date: September 26, 2007 Timestamp: 1190802840 Author: sjs Tags: python, ruby

It turns out that Python is the language of choice on the OLPC, both for implementing applications and exposing to the users. There is a view source key available. I think Python is a great choice.

<p>Ive been using Ruby almost exclusively for over a year but the last week Ive been doing a personal project in Python using <a href="http://web.archive.org/web/20080820115439/https://storm.canonical.com/">Storm</a> (which is pretty nice btw) and <a href="http://web.archive.org/web/20080820115439/http://excess.org/urwid/">urwid</a>.  Im remembering why I liked Python when I first learned it a few years ago.  It may not be as elegant as Ruby, conceptually, but it sure is fun to code in.  It really is executable pseudo-code for the most part.</p>


<p>Im tripping up by typing <code>obj.setattr^W^Wsetattr(obj</code> and <code>def self.foo^W^Wfoo(self</code> but other than that I havent had trouble switching back into Python.  I enjoy omitting <code>end</code> statements.  I enjoy Pythons lack of curly braces, apart from literal dicts.  I hate the fact that in Emacs, in python-mode, <code>indent-region</code> only seems to piss me off (or <code>indent-*</code> really, anything except <span class="caps">TAB</span>).  I really like list comprehensions.</p>


<p>The two languages are so similar that at a glance you may think there are only shallow differences between the languages.  People are always busy arguing about the boring things that every language can do (web frameworks anyone?) while ignoring the interesting differences between the languages and their corresponding ecosystems.</p>


<p>Python has more libraries available as its the more popular language.  The nature of software written in the languages is different though as the languages themselves are quite different.</p>


<p>Ruby has some Perl-ish features that make it a good sysadmin scripting language, hence we see nice tools such as <a href="http://web.archive.org/web/20080820115439/http://www.capify.org/">Capistrano</a> and <a href="http://web.archive.org/web/20080820115439/http://god.rubyforge.org/">god</a> written in Ruby and used by projects written in other languages.</p>


<p>Python is faster than Ruby so it is open to classes of software that would be cumbersome in Ruby.  Source control, for example.  You can write a slow <span class="caps">SCM</span> in Python though, as <a href="http://web.archive.org/web/20080820115439/http://bazaar-vcs.org/">Bazaar</a> demonstrates.  You could probably write a passable one in Ruby as well.  If it didnt quite perform well enough right now it should fare better in a years time.</p>


<p>I still think that my overall joy is greater when using Ruby, but if Ruby isnt the right tool for the job Ill probably look to Python next (unless some feature of the problem indicates something else would be more appropriate).  The reason I chose Python for my current project is because of libs like urwid and I needed an excuse to try out Storm and brush up on my Python. ;-)</p>