waffle

Ruby Tuesday

So: after months of tip-toeing around it, last night I sat down and tried converting a small toy app previously written in another language to Ruby, a kind of Ruby trial by fire. Considering the circumstances, it went fairly well. However, I’m left wondering some things. (Readers not intimately familiar with my programming situation: loving Objective-C, liking Perl, using PHP and getting by with it, not touching Python with a stick (out of bad experiences with it, not because of tribal dogma).)

The documentation is fine. However, the Book’s HTML version (the only one at hand) keeps referring to itself in terms of page numbers only printed in the dead tree version (which by implication is not at hand). Jumping around is guesswork, and I suppose it wouldn’t be so bad if the pure API documentation was also guilty of referencing the rest of the book in the same way in some places. You can point out weaknesses in PHP all day, but the PHP manual is comprehensive, well-structured, searchable and downloadable, and even the manual’s discussion parts (“discussion” meaning those not directly saying “this class does that and this method does this” but discussing the material in a wider context, not the user-added comments) have these blue linky things in them that you can click.

Threads: awesome. No concurrent threads: whuh?

Regular expressions: good that they’re built in. However, I poopoo its seeming unability to return an iterator of a standard array of matches when you know you have a string with multiple matches in. scan is close but doesn’t return the entire match (\0) in its array (matches) of arrays (groups). Update a few days later: fix.

This experiment has strengthened my small experience and general hunch of Ruby: it’s good in the ways that Perl is good, and it’s conventional in the ways that Perl is not conventional (everything is an object! sane OO model! iterators!), but its principle of least surprise introduces bigger surprises: things are less than useful in some common scenarios (threads and concurrency, regexes and multiple matches) simply because they simplify or deviate from the norm.

Don’t get me wrong – I love it because it’s simple, and deviating from the norm doesn’t automatically mean doing it worse. The two together have certainly already meant dynamite for Ruby in many places. I think I’ll keep using Ruby for some stuff, but it’s not all sunshine.

Comments

Not particularly, especially since it wasn’t one isolated bad experience with it (it’d take something special for it to get the boot solely because of one bad experience).

I realize that tons of people do get along with Python, and that there’s undoubtedly great stuff written in it as well: much of Google’s internal workings, Universal Feed Parser, the official BitTorrent client being some examples… hell, Django, which I’d love to not only try but actually use because it sounds like a better fit for me than Rails.

However, I do not get along with Python, and it’s not because I haven’t tried repeatedly. I don’t want to point out the truth too obviously, because it’s so easily misunderstood as tribal “we-rule-they-suck” nonsense: Perl and Python are conceptually not the same, and we’re not talking whitespace or sigils here. There are few people who get along well with both, and I’m personally just a better fit for Perl (and, I guess, Ruby) than I am for Python.

There’s a je-ne-sais-quoi about the differences between Perl and Python that makes me uncomfortable because I think it makes me sound like I’m making it up just so I don’t have to supply a real reason, but it’s all I have to offer you.