For the past 8-9 years, Java has been my bread-and-butter programming language, and to this date it is the language I am most familiar with. However, for the past few years I have developed a growing interest in dynamic scripting languages, and Ruby in particular. To a large extent this was fueled by the elegant Ruby on Rails web application framework, although I have written a few standalone Ruby applications as well. To be honest I have never learned Ruby as thoroughly as I would have liked, and I have not really taken much advantage of its metaprogramming facilities. I still have a stack of Ruby (and Ruby on Rails) books that I am hoping to make it through at some point… Regardless, so far it has served me very well and always felt like an enjoyable programming language.
At work, the most widely used scripting language is Python. I had never written any Python code until a few weeks ago. Somehow the (admittedly superficial) fact that indentation is meaningful in Python has always put me off just enough, and that combined with the increasing buzz that Ruby was generating made me choose Ruby over Python or other scripting languages (I’m afraid Perl wasn’t even in the running…). However, after writing a couple of Python scripts over the past few weeks, I have to admit that it really is not a bad language. Surprisingly, I actually quite like the fact that indentation rather than explicit “end” statements or braces is used to delineate code blocks. There are few things that strike me as slightly ugly, such as the constant “self” references and the fact that it somehow feels less OO (for example in Python the length of a string is determined using
"foo".length()). Still, overall Python and Ruby seem about equally powerful and much more akin than I initially thought, to the point that I would gladly pick either of them over Java (not to mention C/C++) whenever I can get away with it.
My dilemma is that I cannot decide which language to use for my personal projects. I am usually always working on some web application or other (most of which never see the light of day, but still…), and sometimes I have a need to whip out a simple script. Every once in a while I also become compelled to start writing a computer game, and one of these years I might actually finish one. ;)
On the one hand, I still slightly prefer Ruby’s elegance over Python, but not to the point that this should be a significant factor. Ruby on Rails is a stronger sticking point, as it is an excellent web framework with a strong community to support it. Python has a few interesting web frameworks that seem to be gaining some traction (I will write about these in a separate post), and while some of these seem like potential alternatives, none are as mature as Rails, nor do they have as strong a community behind them. However, it seems like while Python was slightly late to the game, it is catching up and only a matter of time until its web frameworks are strong competitors for Rails.
My main reason for considering to focus on Python for personal projects is that I am going to keep getting exposure to Python at work (at least occasionally), and learning two very similar dynamic, scripting languages seems like a waste of effort (particularly considering that we are not only talking about the core language, but also the corresponding standard library and common third party libraries). I would much rather learn one scripting language really well and then pick up another, very different language (Erlang seems most interesting to me right now, but I might consider Haskell or OCAML as well). One could argue that Rails is really a DSL for web apps and should be considered independent of Ruby (in which case I might be tempted to continue to use Rails for web development and use Python for everything else), but I don’t think that this would really do it justice (in fact I’ve often wished I was better at Ruby in order to write more elegant Rails code). So I would strongly prefer to choose a single scripting language and a corresponding web framework.
Another thing that Python has going for it is the sheer amount as well as maturity of its third party libraries. Ruby is very quickly catching up in this respect, but it still seems like Python’s offerings are generally better in terms of both availability and stability. For example, Python has strong game and graphics programming libraries (such as PyGame), whereas I was not able to find any equally strong libraries for Ruby the last time I looked for them about 6 months ago (although some are in the works).
So that’s my dilemma… I have started playing with some of the Python web frameworks (again, I’ll write more about this in the future), and I think I will use my experience with this to guide my decision. If things go well, I will probably decide to focus on Python for now. Otherwise, I simply won’t be able to justify not using Rails, in which case I will have to bite the bullet and continue to use (and further study) Ruby and Ruby on Rails for personal projects, while at the same time using Python at work.
Surely some of you must have been in similar situations, so any advice is appreciated. :)