my internal holy war
Much like two zealots arguing over the relative merits of their favorite OSes, or their favorite programming languages, I find myself having an internal struggle over which language I prefer, and why.
Most of this is rambling thoughts on the relative merits of Ruby and Python, so bear with me.
If find Ruby a very powerful language. I very much enjoy its consistent nature, and object oriented structure. I like objects. I like blocks. I like the language itself, and the syntax, quite alot.
I often think of Ruby as "the new perl". Ruby has strong regexp functionality and it is relatively easy to use. The std libraries are clean, and seemingly well thought out. Alot of work has gone into making Ruby operate under the "philosophy of least surprise".
All that given, I feel that ruby suffers in some of the same ways that perl does. With all this power, comes great responsibility. I find that people writing ruby code tend to be very 'clever'. People often saying 'you can do that in one line', and things like that. They fail to mention that 1 line code is generally not clear, not easy to decipher days/weeks after writing it, and not easy to read by other/future developers that may need to work on the codebase. I don't like 'clever' code.
I have myself written 'clever' code. It made me feel smart. It made me feel sexy. It made me feel like the world was my oyster, and I was the pearl of justice bending nature to my will...well, ok...but it did make me feel smart. I later went back, and had to fix something in my code. I remember looking at my 'clever' code, and actually having to take time to think about what it was doing. It was not apparent, even to me, after time had passed. That time it took to decipher, was wasted time. If the code had been clear and simple in the first place, I could have grokked it, and moved on. I felt smart when I wrote it, but later I realized it was a delusional sense of accomplishment. 'Clever' code is not good code.
It sometimes seems that people write 'clever' code on purpose, to show everyone else how smart they are, or how accomplished of a programmer they are. I have seen code like that, and it plain sucks. The less transparent the code is, the harder it is to maintain, and the worse it ends up being in the long run.
I think ruby programmers could win some obfuscation contents, and give the perl camp a run for their money. Ruby code is full of very smart people. Far smarter than I am. Alot of Ruby code is too 'clever' though. Very clever. Very difficult to maintain.
Python, on the other hand, enforces a bit more rigidity. I don't really care for python regexp, and I find some of the sigil choices to be 'odd'. I generally prefer a discreet ending to looping structures and if statements. It must be an artifact of all those college courses with Java and C. (ps. I hate java).
Python code tends to be a bit clearer than ruby code. Not quite so 'clever'. I don't think python has the same ability for cleverness, as certain structures require a certain format, or are more difficult to write. The language itself doesn't have all the 'options' that ruby does.
I think, at this point, that it comes down to the realization that I like writing ruby, but I don't like reading other people's 'clever' ruby code. I might not like writing python quite as much as I like writing ruby, but I certainly like reading other people's python more than I like reading other people's ruby code.
Remember. Say no to 'clever'.
Thoughts? Comments?
EDIT:
I found an interesting article about ruby and python, from a marketing perspective.
Bambi Meets Godzilla