I’ve not touched Ruby yet, but I’m insatiably curious, so I talked to Darren about it.
As far as I can work out, dynamic languages in general are fantastic if you’re running Test Driven Design; because it’s not the compiler that tells you you’re wrong, it’s the tests. (I’ve never tried this with a dynamic language, but am looking forward to the experience.)
I have a bit of a problem with this idea, though. As much as I like to go on about “the right way”, in practice I’ve not yet seen a project where all the developers write tests for absolutely everything, however much they might like to. The temptation to “just hack that bit of code” seems to be too much. I think this is particularly true of project tools; those little scripts which lend themselves nicely to Perl or Ruby and which aren’t really part of the code base.
Does Ruby tend to encourage people to write tests for everything? Darren thinks not. I’ve certainly hacked a few Perl scripts together in the past; things which had ten line comments for one strange regular expression, or little scripts which made perfect sense to me then, but I couldn’t tell you what they did or how they worked today. They always grow; have you noticed that? I like to think I’m a bit more disciplined now than I used to be, but the idea of thousands of developers out there with another language that lends itself to hacking makes me uncomfortable. It’s like seeing a good friend try on a dress, asking, “Does this make me look fat?” and trying to work out how to tell her that really, it’s not the fault of the dress. Imagine the expression on my face. It’s the same one I’m wearing now (the expression, not the dress).
It’s not Ruby’s fault; I’m sure it’s a great language. I believe, though, that there’s another way to encourage people into the golden path of TDD, even full-on Agile. Ruby’s a relatively new language*, and from this outsider’s point of view, it looks as though it’s gaining a culture and a following all of its own.
Is TDD part of that culture? Do the manuals, forums, etc. for Ruby say, “If you use this language, you should consider reading more about Test Driven Design”?
Just curious… and lazy…
I have vague, unformed visions of a monster language which is absolutely bound to definitions and tests for the behaviour of each class. I have even more vague ideas of how to implement that. I have a better idea of how horribly unwieldy it might be. Back to JBehave…
Update: Thanks to commenters and to Steven, who wrote this illuminating post in response. I think I’m starting to grasp the “Rails” concept of Ruby on Rails – it’s a web development framework with integrated testing (thanks, Steven). Will have to get round to practicing this at some point. If nothing else, I’d love to get a feel for the speed of the TDD / dynamic language cycle.
It’s good to see a bunch of people being so enthusiastic about their work. Hope for the future.
* I’m told that my perception of Ruby as a new language is wrong; it’s been around for as long as Java, and unit testing is built into the standard library. Sweet.