Parting Thoughts

PartingThoughts.net

Ruby vs. Blunt Scissors

Posted 16 February 2007

One of the things that Ruby’s advocates find wonderful, and others often find scary, is its dynamic nature. You don’t declare the types of variables, and you can change them at will. Classes (even the base classes) are always open and new methods can be easily added, or existing ones overridden.

You can certainly get yourself into trouble by misusing these capabilities, but they eliminate a lot of unnecessary coding and increase the flexibility of your code. Ruby doesn’t protect you against yourself; it gives you the power and trusts that you’ll use it wisely. Java, at the other extreme, makes you go through hoops to protect you from yourself. Dave Thomas calls Java “the blunt scissors of programming languages.”

I am no expert on programming languages, I’ve never programmed in Java, and I’m uninterested in religious debates. But I do enjoy Ruby, and I have a lot of respect for the numerous programmers who say it has made them more productive—and that the fears that people coming from more structured languages have just aren’t justified. In reality, they say, things like mistakenly using a variable as the wrong type just don’t happen often, and protecting yourself from this isn’t worth all the declarations and rigidity that strict typing imposes.

If you haven’t used Ruby, you should take a look. ruby-lang.org is a great place to start.

If you’re a Java programmer, check out Bruce Tate’s From Java to Ruby.

Irrelevant side-note: If you google for “ruby benefits,” the top result is for a ruby gemstone necklace claimed to “correct any mental distortions regarding the meaning of love, particularly divine love. It also clarifies communication among your mind, memory, emotions, and body regarding divine love and its expression.” I guess they invested more in SEO than did ruby-lang.org.