Ruby kicks ass.

That’s the executive summary. Here’s the full post:

The other day The Joel wrote about a book called Beyond Java. Having recently developed an intense interest in finding the next generation of programming languages (live in C# for a few months and you will too) — and given the fact that Joel’s summary triggered fond memories of the hilarious, memorable, and absolutely spot-on Execution in the Kingdom of Nouns — I decided to give it a shot.

It’s a good book. A bit indecisive — no one can say, but I think this or maybe this but no one can say — but interesting reading nonetheless. And very, very up on Ruby. Particularly Ruby on Rails, which I had been hearing a lot about from various vectors for quite some time now.

So I installed Ruby on Rails, and I followed along with the ‘creating a weblog in 15 minutes’ screencast and I was (of course) duly impressed. After dealing with .NET’s mindless SQL interactivity, Active Record alone was enough to knock my socks off, and the scaffolding support atop that was enough to actually knock my socks back on only to knock them off again in some sort of incredible double-knock-sock-knocking knockapalooza.

But of course, I’d never worked with Ruby before so the demo was inscrutable to me; it was impressive, but if you don’t know Ruby it’s hard to tell what’s magic and what’s, you know, magic. If you’ve only ever used direct jumps then virtual function dispatch looks pretty damn sexy and any sufficiently unfamiliar programming language looks like goddamn sorcery until you figure it out.

“So,” sez I, “it must be time to learn Ruby.”

With cartoon foxes.

This Why guy is — if I might be allowed a brief meander into the vernacular — nucking futz, but he is also endlessly entertaining, far more articulate than most code-friendly persons (Persons of coded descent? Coding Americans? Coditos?) ever manage to become, and a pretty talented artist to boot. And not just ‘a talented artist… for a programmer’, actually, like, you know, talented. What with the drawing and all.

I think the thing that strikes me the hardest about Ruby is the fact class definitions are no longer magic like they are in every other language I’ve used. In C++ style languages the class foo { incantation opens a class and the } closes it and in between you’ve got a special list of allowed syntax with specific keywords and constructs and laws and regulations and red tape and occasionally tiny little policemen who tell you that a semicolon was expected and that your vehicle registration has expired and would you please remain in the vehicle.

Maybe that last part was just in my imagination, it’s been a while since I did a lot of heavy lifting in C++, but the point is that it’s a modal language.

Ruby has none of that. Writing class Contrived doesn’t put your parser into a special mode; if it’s implemented as I assume it is, it operates more like ‘create the class Contrived if it doesn’t already exist, and then push it’s context onto the scope stack’. And then a few lines later the end pops it back off. And in between — you can put any damned thing you want. You can perform I/O. You can run calculations. You can call methods that write methods and embed them into your class. This shit is hot. You know how your C# classes always have like sixty properties that are all coded like

private int m_Foo;  
public int Foo  
		return m_Foo;  
		m_Foo = value;  

and you wish you could just drop in a small script that wrote them all for you? With Ruby, you can. Except you don’t need to, because they wrote one for you already!

It’s a language designed to automate that which can be automated. What’s not to love?