topaz: (qwrrty)
Tim Pierce ([personal profile] topaz) wrote2008-03-14 11:09 am
Entry tags:

Ruby: the love is really gone

As a postscript to my previous complaint about Ruby, I received today a fantastic exploration of Ruby's closure and execution semantics, via [livejournal.com profile] zsquirrelboy: http://innig.net/software/ruby/closures-in-ruby.rb.  This covers some of the ground that I did but then goes much, much deeper.  I have only covered about half of it and probably will not get any farther today.  If you are a Ruby fan or any kind of a computer language nerd I strongly recommend that you take 30 or 40 minutes to read through it.

The upshot is: Ruby is even more fucked than I recognized.  I'm an understanding guy, and would be willing to accept a lot of the language's foibles if they were well documented up front, but some of these conclusions are really damning.  See section 3 in particular, especially if you think that "I thought I knew all there was to know about the 'return' statement" is a funny joke.

Ruby seems like a very interesting but ultimately unsuccessful experiment in functional language semantics, where some of the novel concepts just do not pan out.  Blocks in particular are a failure: if they were just implemented as first-class closures it would solve a lot of problems, but that doesn't seem likely.  A pity.
nacht_musik: (Default)

[personal profile] nacht_musik 2008-03-14 03:37 pm (UTC)(link)
huh. I appreciate your investment of time and frustrating for saving *me* time and frustration. I shall avoid Ruby for serious projects. :-)

[identity profile] rwx.livejournal.com 2008-03-14 04:23 pm (UTC)(link)
The less you know about functional programming, the better ruby is for serious projects.

Err, more seriously, it's great as a web scripting language so far as I can tell, but the whole 'pass a block into space to violate your class structure' thing is a giant bucket of fail.

still doesn't use tabs for scoping, though, which I just watched people get fscked by so hard I'm still laughing three days later.
ckd: (cpu)

[personal profile] ckd 2008-03-14 04:33 pm (UTC)(link)
I haven't used Ruby, and I'm not nearly as good with CS concepts like closures as I would like to be, but I'd be interested in your opinion of how Python handles these features (assuming of course that you have one).
ext_86356: (Default)

[identity profile] qwrrty.livejournal.com 2008-03-14 04:43 pm (UTC)(link)
I don't, really. Python seems like a fine language but I've never been fond of it, partly because it feels to me like the syntax tends to get too much in my way. My sense of it is that it's much more careful to define consistent rules about the language semantics, so I would be very surprised if it fell into traps like the ones I'm talking about here.

[identity profile] nooks.livejournal.com 2008-03-14 05:05 pm (UTC)(link)

Thanks for pointing that out. It really helped me to clarify the problems I have with PHP. Every now and then I come across someone who says that PHP is their preferred scripting language, or someone who thinks it's "not that bad". Now I can simply bellow "defined by implementation!" while I drop a half-brick into a sock to show the error of their ways.

jss: Me (bastardcard)

[personal profile] jss 2008-03-14 05:11 pm (UTC)(link)
Use the whole brick.

[identity profile] numignost.livejournal.com 2008-03-15 02:26 am (UTC)(link)

Are Ruby's blocks based more closely on parallel programming coroutines than on functional closures? Not that it's a parallel language, but in terms of philology maybe we can regard Ruby as [good scripting] + [good objects] + [barely passable functional] + [a hint of parallel] + [great reflection]. It's the combination of reflection and objects that has made Ruby prominent, and the somewhat garbled functional semantics were fortunately "good enough" for Rails.

As a point of comparison, Python is more of a [good scripting] + [I really hate Python objects] + [good functional]. (I haven't explored Python reflection.)

Or take something like OCaml, which I seem to recall is [great functional] + [great objects] + [nothing else].

I think we're still waiting for [scripting] + [objects] + [functional] + [multithreaded] + [reflection]. Not to mention [extensible] and [aspect oriented]. Groovy, F#, and Boo all have some new ideas to put on the table, but this is very much an ongoing conversation about finding the right compromises for different problem domains.


[identity profile] khedron.livejournal.com 2008-03-15 05:26 pm (UTC)(link)
I went & bought the new Ruby book (The Ruby Programming Language (http://www.amazon.com/gp/product/0596516177), with illustrations by why the lucky stiff (http://poignantguide.net/ruby/)). I won't have time to read this for a while though. Bookmarking your link for later.
Edited 2008-03-15 17:30 (UTC)