Waffle is a weblog.
The author of Waffle, some guy in Sweden, also occasionally writes stmts.net.

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.


  1. Care to add more detail about your bad experience with Python?

    By Jason Huggins · 2006.07.19 23:08

  2. 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.

    By Jesper · 2006.07.20 01:25

  3. Concurrent threads are coming in a planned future version of Ruby. The threading code you write today should still work in the future, but faster.

    By Andrew · 2006.07.20 02:05

  4. Okay, fair enough to leave it je-ne-sais-quoi. :-)

    By Jason Huggins · 2006.07.20 19:52

  5. Andrew: Awesome.

    Jason: I was hoping it was.

    By Jesper · 2006.07.20 21:50

  6. FYI, you can access the full match when using the iterator form of String#scan, if you can bear using the special global variables:

    "foo bar baz co".scan(/(\w)(\w*)/) do full_match = $& head = $1 tail = $2 end

    By Joshua E Cook · 2006.07.21 20:32

  7. Joshua: It’s still dumb that such a method doesn’t already exist, but it’s several kinds of awesome how the globals still work in multiple match scenarios. I’ll be able to work around this now.

    By Jesper · 2006.07.21 23:41

Sorry, the comment form is closed at this time.