tecosystems

Does Performance Matter? Yes (And No)

Share via Twitter Share via Facebook Share via Linkedin Share via Reddit

As Christopher points out, there has been quite a bit of discussion in recent weeks about language performance in general, and Ruby performance in particular. While the conversation has proceeded along fairly predictable lines – non-Ruby folks challenging the performance, Ruby folks defending their language of choice – the debate has been notable if nothing else for its essential civility. Both sides, in my opinion, are to be commended for keeping the discussion in rational territory, and (mostly) avoiding the submerged reef of a flamewar (Joel v DHH excepted).

On the question of performance itself, I actually have little to add. Joel kicked this whole thing off by damning Ruby for its lack of performance (among other things), and closer to home Christopher backed that up with a quick example. Against this evidence, even the Ruby advocates were inclined to cede the point:

  1. IBM’s Rick DeNatale allowed that performance was an issue, but ultimately concluded that “Ruby performance today is surprisingly acceptable for a wide range of uses.
  2. Steve Yegge, who has arguable grown to be Google’s most visible blogger, wrote the following: “If only it performed better. *Sigh*. Well, its performance is in the same class as Perl/Python/JavaScript/Lua/Bash/etc., so there are still plenty of tasks Ruby’s admirably suited for.”
  3. Most significantly, David Heinemeier Hansson (AKA DHH) – the father of the framework that is more responsible than anything for Ruby’s resurgence, Rails – even described a circumstance where they rewrote a Ruby function in C, for performance reasons:

    We did the exactly the latter for Campfire. It has one clearly defined bottleneck. Hundreds of users polling every three seconds for updates. Originally the polling mechanism that handled that was 100 lines of Ruby. We rewrote it over a few hours to 300 lines of C. So we got to keep 90% of the application in Ruby and then we outsourced the bottleneck to C. Writing the entire application in C just so we could get the maximum performance from the polling service would have been madness, so I’m glad we didn’t have to choose.

In the face of such evidence, it’s my opinion that trying to defend Ruby’s performance against closer to the metal languages such as C or C++ would be pointless – and I suspect that folks on both sides would agree.

So if the question is not whether or not Ruby performance is less than impressive, relative to some of its non-dynamic competitors, what is it? Whether that matters, of course.

In his del.icio.us comment on my dynamic language piece regarding, Christopher asks just that question, saying “does performance matter or not?” Between that bit, and the comment here:

del.ico.us is being loaded up with links which claim that Ruby is fast enough, performance doesn’t matter, and that us C++ programmers are just a bunch of curmudgeons (ok that part’s true).

It seems safe to assume that he’s a bit frustrated by the lack of attention to the dynamic language performance (Smalltalk excepted). And perhaps he’s right to be. Oldtime Smalltalker John Duimovich echoes that frustration in his post, “Performance is not optional.”

Personally, I do not agree. Performance does matter, but it is absolutely optional, in my opinion. If it wasn’t, we’d still be building everything in Assembler [shudder]. The success of the dynamic languages is, as far as I’m concerned, all the proof I need of this truth. Is C++ faster than Python, Ruby, et al? Undoubtedly. Is it the right choice for every development task? Not if adoption trends are any indication.

In open source, there’s a school of thought that says that commercial support is best understood as a money to time ratio. At certain points in a firm’s lifecycle, they’re willing to trade time for money (i.e. startups with no money) – at others, they’re more than happy to trade money for time (i.e. well capitalized firms with lots of backlogged work). I see the language debate as a derivative of this. For some tasks, it’s far more suitable to trade time for performance, at others, performance is the premium while time is more expendable. [1] [2] As DHH puts it,

I don’t hear a lot of people claiming that operating systems should be written in PHP. Or that guest books should be written in C. It just appears self-evident that you pick from the sphere of reasonable applicability.

Different tools, different jobs. And so on.

This does not mean, however, that dynamic languages get a free pass. Ted’s right; contentment with the “outsourcing” approach of in-line method caching is potentially dangerous, as it can come across as indifference to language performance. Fortunately, I would not characterize the reactions that I’ve seen as contentment; quite the reverse, if anything. Grudging acknowledgement, along with constructive responses, has been more the norm from where I sit.

Along with many of the other participants, I fully expect Ruby – along with the other dynamic languages – to improve its performance considerably in the days ahead. Not least because there are firms large and small that will continue to draw attention to it. But in no way, shape or form do I believe that performance and performance alone should be the deciding factor in all language decisions. Performance is important, but optional. Performance, after all, is the basis for speed. Speed, you may recall, is just a feature. Features, as it happens, are (or should be) dictated by requirements – not assumed generic assumptions.

[1] The argument could be made, in fact, that given that in many contexts time is money, the argument is not a derivative but in fact one and the same. This would needlessly complicate the point, however, and thus I leave it as an exercise to the reader to determine where they stand on that point.

[2] Astute readers will note that I’m implicitly making the argument that dynamic languages are more productive – the time portion of the above equation, than their static counterparts. I’ll admit readily that this is a gross oversimplification, and one complicated by tool questions, but I think it’s defensible enough, at least on a superficial basis.

5 comments

  1. We just need some of those Smalltalker and Lisper compiler writers to come over to the dark side of the upstart new languages and we’ll all be eating Bacon.

    Or, maybe we could all start using Smalltalk and Lisp…

    Or on the third hand which I’ve recently had surgically added, maybe we can get some kinda crazy ass VM that’s super super fast and has high level implementations of all the crazy ass compiler tricks that make those dynamic languages so fast.

    Want Tail recursion? *bam* mix in the Trampoline module!

  2. Thanks for the links.

    Check out my latest post. I might have to take back my previous claims about python/ruby performance on a technicality. The reason smalltalk was looking so good was that it uses linked lists to implement lists, not because the VM is inheriently faster.

    BTW, I like C++ because I can choose to go low level or stay high leve without leaving the language. C++ isn’t popular these days, but I think with the right framework it could be a decent web development platform.

    The way I look at it is that both Google and Bloglines have proven scalable and both are written with a bunch of C/C++ code.

    BTW, C++ really doesn’t have a lot to do with C these days. With the boost libraries you can get a lot of off the shelf functionality.

  3. After rereading here, I think there was misunderstanding about what I said about the links on del.ico.us. I didn’t mean links I was loading up, but the links others had loaded. But anywho…

    I’m not all that religious about this. I do think it is good to have some real datapoints. It will be interesting to see if there are any reports of projects hitting a wall on Rails scalability in the next year. I think the concurrency point is more of a serious issue than the data structure performance, but time will tell.

  4. Danno: i’m interested in just that, now that Strongtalk’s been open sourced.

    christopher: i actually think you argued the case both effectively and quite rationally. you’re clearly not a bigot, as your Python usage attests to, nor are you wrong that folks like Google and Yahoo get a lot of mileage and performance out of C++. in the Yahoo case, however, the C++ is the base layer, PHP as i understand it the standard on the presentation side.

    i’m totally with you on the concurrency point; there’s a reason people are talking about Erlang, after all.

  5. When I was working on feedflow we considered doing the UI in Rails and the backend crawling, etc. in C++.

    I think for large scale web apps a combination of low level C++ with a high level UI frameworks is a pretty good choice.

    Thanks again for the links.

Leave a Reply

Your email address will not be published. Required fields are marked *