Ruby is the Future

After a whole lifetime of ranting against it (cite, cite, cite, cite), I finally have to eat my words, come out, and say it: Ruby is the language of the future.

Now, I don’t specifically mean Ruby itself will be the most used language in the future, but I believe Ruby is the future now like C++ was the future in the 80s — all mainstream production languages that come next will be, at their heart, a Ruby derivative. And it’s easy to see why.

Those that have known me the longest shouldn’t find this announcement as a shocker. My programming career started in Perl. And while in Perl, I routinely used its features to meta-meta-meta-program, which allowed me to code at a high enough level that I both saved a lot of typing and guarantied my own job security. I left the Perl world for Java and pretty much stuck there, with occasional visits to dot-Net and OCaml. For a long while, I became enamored with static typing (cite, cite, cite), but through my work with Cornerstone and working with Scala, I’ve had a realization: every piece of static typing is, basically, intentionally getting in the programmer’s way.

Ruby’s beauty is that it doesn’t get in the programmer’s way. The type system is ultimately open — much like my beloved Perl — and that means that whatever the programmer wants to do is what the programmer can go ahead and do. Hell, even the private keyword isn’t a keyword at all, but a method (its documentation is here), and so if you wanted your code to go exhibitionist and dump its privates in public, all you need to do is override private to be an alias for public (but make sure to hook in early enough that you get your code run before the method you want to make public!). Sure, the developer who wrote the original code probably had a reason they wanted that code to be private, but a new programmer is driving this application now, and if the new programmer thinks it was a mistake, then why should the type system get in the way of retroactively fixing the library? Further, by fixing the library in application code, later upgrades to the library don’t need to be re-fixed: the one-time patch will automatically get re-applied by application code automatically!

[ Before I let the point go, the public/private by method bears one more point of praise: as a mathematician by training, the conceptual purity of everything being an object or method is extremely attractive. Okay, well, in Ruby only *almost* everything is an object or method (i.e. +.class fails), but that's one of those points that can get touched up in a later language. ]

The class-definition-as-script approach is another aspect of the type that I’m very fond of. Those who worked on my Perl projects know that I would regularly read configuration files and build objects dynamically based on that, including configuring behavior by overriding method definitions in the symbol table. In Ruby, things can work pretty much the same way. This is a mandatory kind of behavior for our enterprise environments, where things tend to work one of two ways: either they change so quickly that a normal code release cycle can’t keep up, or they are so restrictive that changes can’t be made to the code itself in a timely way. In both cases, since code is data, the normal release cycle can be completely undercut by storing code definition in the database (or an easy-to-change config file) and changing it there. The result will be a brand new and arbitrary configuration of code, but unit tests should have caught any problems that might come up.

Which brings us to the key change that I had to accept before my conversion: development is made up of unit tests and code tracing. Unit tests are basically the safety replacement for all those limitations that static typing places on the programmer. So unit tests need to be applied aggressively, but they need to be applied aggressively in any language. Given the Ruby type system, it’s simply not feasible to test all possible inputs and outputs, and YAGNI says that writing code to validate for those inputs is unnecessary until/unless they become a problem. This leaves us with writing unit tests only for the good usages (and the bad usages when we have a specific example): these tests are the easiest to write, because they’re most in line with how the developer is thinking when they’re in the flow. So this is another case where Ruby’s way of doing thing is most in line with the natural way a software developer works — FTW!

Now, detractors out there (like me yesterday) would argue that the lack of error checking leads to difficult (if not impossible) to understand messages and errors. While there is some validity there, the response to this is twofold: First, unit testing will isolate the particular line being called that, which at least tells you what you’re doing wrong, so you can stop doing it; Second, the fact that Ruby is not compiled means that it is easy to walk through the source in order to figure out what is going on. This means that you can dig into the library/framework you’re learning and really learn what’s going on, which is an educational opportunity. This difficult to understand message or error is a sign that you don’t really grok how your library/framework works, which you really need to do before you go ahead and just use it willy-nilly in your application! After all, that library could be redefining 1 to be 2 for all you know!

The last major complaint that people (like I was) have against Ruby is that it is basically unmaintainable over the long haul. I’ve admitted before that there’s less trouble on that front in Ruby than there was back in Perl, but I want to offer four more responses at this point. Three are in short form: one, any maintainability problem is obviously a failure of writing out your test specifications; two, the number of bugs per line of code is a constant, and so Ruby having fewer lines of code than Java means that Ruby has fewer bugs than Java; and three, the Ruby allows you to implement the big re-write with unprecedented speed — why bother maintaining all that old ugly code when it’s just as easy to rebuild it from scratch? The fourth point, however, is really where Ruby’s power shines: seeing as how the life expectancy of a Ruby gem (all the way from conception through hype to passe) is about 6 months, and whatever Rails app that’s being written should be bought by Twitter or Google or Amazon for $$$ within 9 months, then clearly maintainability isn’t all that important after all. The speed of writing the code is the only important part, because you don’t want someone to beat you to the punch!

I hope at this point it is clear that Ruby is the language for 21st century Real Programmers.

[ Edit: More on this at the post "Ruby is the Future 2".]

This entry was posted in Classic, Programming Language Punditry. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

24 Comments

  1. Ulf Krum
    Posted April 1, 2009 at 3:38 AM | Permalink

    Nice April Fool’s joke ;-)

  2. Mark Menard
    Posted April 1, 2009 at 5:42 AM | Permalink

    Where is Robert and what did you do with him? I may be forced to call the Durham police and file a police report!

    Mark

  3. Sven
    Posted April 1, 2009 at 5:44 AM | Permalink

    yeah its always a great idea to rewrite software from scratch…. are you serious?!?

  4. Posted April 1, 2009 at 6:52 AM | Permalink

    OK, you win April Fool’s Day :-)

  5. first april
    Posted April 1, 2009 at 7:08 AM | Permalink

    april, april

  6. Posted April 1, 2009 at 8:11 AM | Permalink

    Hmm…. I thought I posted this earlier from my iPhone. Must have gone awry. It was around 6Am.

    Anyway….

    WHERE IS ROBERT AND WHAT DID YOU DO WITH HIM?!?! We may be forced to call the Durham Police and file a report of suspected foul play. ;)

    I pretty much agree with everything except the longevity of Ruby code. Nice writeup, even if it is an April Fools joke.

    Later,

    Mark

  7. Jori
    Posted April 1, 2009 at 8:39 AM | Permalink

    No, Python will be. Ruby is still a one-trick-pony.

  8. boardtc
    Posted April 1, 2009 at 8:42 AM | Permalink

    Nice one! You had me going there for a bit!

  9. Steffen
    Posted April 1, 2009 at 8:57 AM | Permalink

    That’s quite the convincing argument. Now, given that Ruby seems to be the wave of the future, would you recommend it as a language for someone to jump into without any serious programming background?

    I ask because I have about 7 books on teaching yourself various languages, including Perl, C, C++ and Ruby; if I ever get enough time to sit down and work through any of them would you recommend I start with, and focus on, Ruby?

    Rather than going through all of them and giving myself a roundabout education on the evolution of programming languages, which I’m already doing with a number of other hobbies of mine.

  10. cremes
    Posted April 1, 2009 at 9:10 AM | Permalink

    Nice!

    I didn’t twig to the April Fool until the 4th paragraph. Nicely understated snark…

    :)

  11. Posted April 1, 2009 at 9:45 AM | Permalink

    The difficulty with rewriting is not that rewriting is hard; it’s that the existing code contains behaviours and interface specifications that are far more detailed and hidden than can easily be elicited.

    This is more true in some applications than others. I work on compilers. The only gold definition of the language (Delphi) is embedded in the compiler behaviour, because that’s what customers use. If a customer gets the compiler to do X, then the compiler had better always do X in the future, otherwise it’s a breaking change.

    Rewriting something like this is never, ever trivial, no matter how powerful your language, because the requirements and specification that you need to implement are only described in the original source, because the original source is the only program with sufficient semantic density to describe *everything*. No test suite is sufficient to cover everything. The combinatorial complexity of input sentences more than a few tokens long quickly puts paid to that idea.

  12. Posted April 1, 2009 at 10:33 AM | Permalink

    As a Perl to Java (to Groovy) to Ruby developer myself, I think you’re right on. I still think Larry Wall is the bomb, but Ruby (and other languages like it) is the future. In fact, sometimes I wonder if Perl 6 is so long in coming because Larry’s hacking in Ruby these days ;)

  13. ilan berci
    Posted April 1, 2009 at 12:32 PM | Permalink

    Brilliant article, I really appreciate you taking the time to write this.

    To take your point even further, I believe that the next “ruby type” like language will do away with the class system as well as even that can get in a programmers way! OO languages that use prototypical inheritance such as iolanguage offer cleaner meta programming goodness. Anyone who has dynamically added class level methods to a ruby class has suffered from the following:

    (class < self; self; end).define_method …

    Then there is the whole problem of singleton classes:
    class Foo
    def bar 1; end

    f = Foo.new
    def f.bar 2; end

    but f.class is still a Foo???!!!

    whereas in the prototypical languages the object is the class and this type of confusion never arises..

    lastly, to offer even more meta opportunities, methods could be first class citizens, with full reflection (including looking at source at run time)

    Ruby is currently my favorite language by far and I can’t wait for the next “ruby type” language to knock my socks off,

    As a side note, the potion language by _why is stunningly beautiful as well and I urge you to take a look at it.. I am anxiously awaiting more literature on it as I lack the brain cells to fully appreciate it’s capabilities from just reading the current documentation..

    Thanks again for the great article

  14. weknow
    Posted April 1, 2009 at 12:35 PM | Permalink

    ruby is awesome and beauty, yes, we know that. but I guess we need a even higher level language for the future.

    and… please don’t write blogpost like this, there’s a bunch of jealous out there ;)

    btw, I am happy you understand the mistakes you made in the previous posts (don’t feel like an asshole hopefully you are a better programmer today!)

  15. Brian
    Posted April 1, 2009 at 1:13 PM | Permalink

    Is this an April Fool’s joke?

  16. Posted April 1, 2009 at 1:47 PM | Permalink

    “Okay, well, in Ruby only *almost* everything is an object or method (i.e. +.class fails)”

    *Everything* is an object in Ruby. From your example above:

    irb> plus = 1.method(:+)
    => #
    irb> plus.class
    => Method
    irb> plus.call(1)
    => 2

    Even methods are objects.

  17. Bobby
    Posted April 1, 2009 at 3:37 PM | Permalink

    this is what I call ‘April FAIL’, I would remove the last part – it looks silly

  18. Steffen
    Posted April 1, 2009 at 3:43 PM | Permalink

    Curses!

    My smooth-lobed, non-programmer mind failed to take into account that this is April Fools day, and I just realized everything I didn’t really understand just washed over my head while I was reading.

    Damn fool, I am.

  19. Posted April 1, 2009 at 5:02 PM | Permalink

    Andrew: Not everything. “if” isn’t an object.

  20. Steve
    Posted April 1, 2009 at 5:41 PM | Permalink

    The TIOBE index and various job boards still place Ruby at about 2% mind share, which is fairly unimpressive after 15+ years in existence.

    The following article predicted that Ruby would never become mainstream three years ago:

    http://beust.com/weblog/archives/000382.html

    and not much has changed since then…

    I love Ruby, but I’m not holding my breath any more, I just think it is and will remain a niche language.

  21. Posted April 1, 2009 at 5:52 PM | Permalink

    Nice April’s Fool post.

  22. Posted April 1, 2009 at 7:23 PM | Permalink

    Reading all these comments I’m reminded of a certain parrot. http://www.bbea.ws/WHOOSH2.gif

  23. Posted April 1, 2009 at 8:43 PM | Permalink

    @Steve

    http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

    On TIOBE, PHP has ~9%. Perl and JavaScript have ~3%. For Ruby to have 2% is pretty impressive.

  24. Posted April 2, 2009 at 8:57 AM | Permalink

    Bah, I read this on April 2nd, and didn’t realize it was an April Fools joke until the very last sentence when you used the phrase “Real Programmers”. I’m with Russ. You win April Fools.

2 Trackbacks

  1. [...] it, some people didn’t, and some people weren’t sure what to make of it, but the Ruby is the Future post was an April Fool’s Day joke. It was intended to be satire, starting with [...]

  2. [...] insanely dynamic nature of the Ruby language, which is why I satired that functionality in Ruby is the Future (be sure to read the follow-up at April Fails or April Fools Epic Win? On “Ruby is the [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">