Why Ruby’s The Mansion of Bliss

Scott Hanselman weighed in on the Ruby buzz, saying that no language is all things to all people at all times.  I agree, but think that there are a couple things about Ruby that don’t require us to get into language design philosophies. Let me quickly state that these things are not unique to Ruby, but may take the appearance of The Mansion of Bliss to those with backgrounds in more statically-defined languages. (“The Mansion of Bliss” was, I learned on my flight to Panama last night, a phrase used in the early 19th century to mean “tits.”)

The first thing that I like about Ruby is that it has an interactive console / REPL loop. For instance, let’s say you’re trying to divvy up a bunch of data into bins, but don’t know the exact cut you want. With Ruby, you can instantiate a database connection, retrieve this table’s data, that table’s data, apply this filter, that filter, etc., interactively. Of course you can do this with a static language, but every time you make a step of progress, you have to recompile, start the system, retrieve the data, stitch up the joins, and then check to see if your new filter moves you a step forward (which is the much-to-be-admired test-driven way, but sometimes keeping that line green takes a lot of time off the clock). Or, I imagine, you could do it in an interactive SQL Explorer, if your SQL is better than mine.

The other thing I quite like about Ruby is that while everything’s an object, there’s an implicit receiver. So if you have:

puts ‘Hello, world!’

alone in a file or alone in the console, you can do without the likes of:

public static void main(String[] args) { … }

and, y’know, that’s just nice. Object-orientation is the Mansion of Bliss, to be sure, but sometimes there’s something to be said for a block of imperative code.

Further, after 10 years trying to remember what combination of decorators with which to read a file, there’s something awfully blissful about File.Open(“foo.txt”), much less File.open(http://www.knowing.net), which you do for the price of require ‘open-uri’

It does make me pine, though, for two other things that it could have:

What if every line of code you ever wrote were available, perhaps organized in some form of browser?

What if as you worked in that interactive shell, you could just shut down the system and return to it later, having the exact objects, in all their complex state, restored to their former glory?

I suppose that such capabilities are impossible or someone would surely have implemented them by now.