Comparing pieces of string - part 1 4

Posted by daniel Sat, 01 Dec 2007 15:15:00 GMT

People compare programming languages all the time. Often, comparing languages can feel like comparing pieces of string (as in the expression “how long is a piece of string?”). There doesn’t seem to be much common vocabulary to rely on, particularly when explaining things to a non-programmer.

If you talk to computer scientists (the kind who like to study languages as forms of sophisticated imperative expression), you will get some interesting concepts about the ’power’ of the programming language (e.g. does it support continuations? closures? recursion? functions as first-order variables? etc.). These discussions tend to be really interesting (if you get the jargon), because the topic of programming language design is a pretty neat pseudo-philosophical one. However, they don’t much help in the pragmatic decision between building your company’s core product in Java, Ruby, or PHP (as an example).

If you talk to Rubylosophers, you’ll get some hip and hippie discussions of how languages should be designed for harmony and balance, to make programmers happy. When faced with a Rubygmatic programmer, words like ”productivity” and ”rapid development” will be heard. However, those seem almost magical, and are pretty hard to base a hard decision on unless you’ve experienced them yourself.

In this post, I’ll explain a simple model that I’ve come up with over the years, as I experienced a fair (though by no means vast) variety of languages. Please note that it’s only a model, and it’s not meant to explain everything under the sun. It’s simply a metaphor that I use when describing why language X is better than language Y to someone who doesn’t get programming. If you push and pull at it enough, it will crumble. But before it does, it can still be used to derive some interesting insights. I hope it is useful to others too.

Since I’ve come up with a number of interesting insights from this model, I’m going to split this article into multiple parts, probably about 3.

The basic model

The key piece of thinking behind this model is the idea that as a program ages and more functionality is pinned onto it, it develops something I like to call “viscosity”.

What is programming viscosity? It’s the almost imperceptible (at first) slowing down of the speed at which change can occur, due to the risk of causing unforeseen bugs. It’s not a new concept, nor is it only applicable to software. In ”Developing products in half the time”, which has nothing to do with software, the authors argue that each feature increases the complexity of the system in an exponential manner (because each new feature adds N possible interactions to the product, where N is the number of existing features). That is largely true for software as well, but in a much more pernicious way.

Software products are inherently vulnerable to scope creep, much more so than physical products, because “customers” (be they clients, or business users within your company), have an intrinsic understanding that adding more buttons to a physical object makes it more complex, but they don’t have such a direct understanding of why the same is true for software (a whole article could be written about why that is).

Now, viscosity in software products is never actually infinite. It’s always possible to make changes. However, the viscosity may well become so large that each change ends up taking a huge amount of time. When that happens, change freezes because it’s too expensive. Not only that, but as the complexity increases, it becomes more difficult for programmers to deal with it. Either they get irritated and bored by it, in which case they’ll figure out a way to get out of your project and move elsewhere, or they simply can’t cope with it anymore, and then you get a situation like that described in this article, where you need a vastly better programmer to come in and sort out the mess (effectively rewriting half or all of the system in the process). If you don’t have access to one of those great programmers when that happens, you’re stuffed. If you do, you may still be stuffed, but at least you have a chance.

This state of high viscosity is, in my experience, inevitable. No matter how smart your programmers and how fantastic your language, they’ll eventually reach it, unless your project is really trivial (e.g. an online company brochure). All non-trivial projects accumulate features over time and get harder and harder to work with. The question is, can you push this point back until you can actually afford a major rewrite? If you pick the wrong language, what’ll happen is you’ll reach that point too quickly, before you’ve shipped your product and started taking in cash. And then your business will sink. Even if you have vast amounts of money available to patch things up, you want to push back that point as far as possible, because a Big Rewrite is always a costly and risky manoeuvre, with no guarantees of success.

Without further ado, here’s the basic graph showing what I’ve been talking about.

There’s only one new element that I haven’t talked about in this graph, and that’s the Boredom Limit. What this limit means is quite simple: beyond this point, your programmers will lose interest. They’ll still work, maybe even work hard, but it’ll be something other than the love of coding something cool that keeps them at it (good examples might include: financial bonuses, personal commitment, enthusiasm for the business idea behind the project). Even if they continue to work on the project, there’ll be a nagging voice inside telling them they’d rather be doing something else, and that will start to take its toll as time passes. This extra cost won’t kill your project, but you should be aware of it so that you can ensure those additional incentives are in place - otherwise your programmers will just leave.

So, let’s draw a first insight from this graph.

Insight 1: Comparing languages

Let’s represent more than one language on this graph. Each person might have their own opinion about languages. The comparison below represents my experience with 3 fairly important technologies used to develop web applications: Java, PHP and Ruby on Rails.

There are basically two factors at play here: the initial overhead, which increases the viscosity right from the get-go; and what I’ll call the “viscosity function”, which is the speed at which viscosity increases with time.

A framework like PHP has very little overhead at first, which is extremely good for very small projects that have extremely little chance of growing beyond that simple stage. For instance, a very lightly dynamic website with some simple forms would be very quick to develop in PHP, and slower to develop in most other frameworks. However, as the project grows, the viscosity of a PHP application quickly becomes unmanageable. Since all medium projects have a tendency to accrue extra features and become larger, I would not recommend PHP for anything that is likely to be more than a simple site with a handful of forms and dynamic elements.

At the other extreme, a language like Java, with a rock-solid framework like J2EE, has enormous up-front overheads. It takes about a week just to get your development environment wired up so you can get started on your development! By that time, the PHP project should already be finished and shipped. In From Java to Ruby, Bruce Tate quotes some engineering managers who claim that it takes at least 2 years to earn the adjective “experienced” in the Java world. And, from my personal experience, that’s true. There are many, many bits and pieces to learn in a framework like J2EE, and it takes an enormous span of time to acquire them all, and just as long to wield them effectively. On the good side, however, J2EE scales admirably well into the future, so long as it’s been reasonably well architected. Your development might be a pain, lumbering along like a snail right from the beginning, but you can rest fairly well assured that it will be a looong time before it slows down much more than that.

Finally, in the middle, a framework like Ruby on Rails provides a much, much better viscosity function than PHP, but with a much, much lower initial overhead than J2EE. Rails supports most of the useful J2EE patterns right out of the box, so that reduces the viscosity function quite a bit. It’s very quick to learn and be productive in (I started doing cool things with it practically from day one). So the initial overhead is low.

Placing these languages like that is only my opinion, of course. Feel free to disagree. However, this is the way I’d place them based on my experience of them.

That’s enough for this first article. I’m very keen to hear what others think about this model, so please leave some comments if you have some suggestions. Part 2 and 3 of this article will cover how this model can be extended to explain the effects of good and bad architecture, of development methodologies and of programmer quality (and probably a couple more things I haven’t thought of yet).

Thanks for reading.

Please vote this article up on social news sites! Why?

Stumble It!
Trackbacks

Use the following link to trackback from your own site:
http://inter-sections.net/trackbacks?article_id=comparing-pieces-of-string-part-1&day=01&month=12&year=2007

Comments

Leave a comment

  1. Avatar
    Will Sargent about 3 hours later:

    Nice article. I think you’ve hit on something when you say that the boredom threshold kicks in well before the system devolves into a big ball of mud. I don’t think that’s related to the technology though, so much as the relevance of the programmer’s work to the system as a whole. In a large system, the programmer will make less of an impact on the project, and be building on work that was already decided a while ago. In those circumstances, there’s less room for creativity. This is especially noticable in simple database backed web applications: the acronym CRUD is very telling.

  2. Avatar
    daniel about 3 hours later:

    Absolutely, that’s a good point! So what you’re saying is that, as a project becomes bigger (and hence more important to the company sponsoring it), it likely becomes more boring to a good programmer, because of their reduced importance in the context of it. So the line of boredom goes down as the project gets more and more massive, which drives away the best programmers.

    This would help explain why large enterprise projects are so difficult to deliver. Not only are the best programmers driven away, but the size of the project is such that bad programmers are unable to cope with the complexity. I guess that’s where the J2EE stack comes in handy, since it allows the complexity to remain manageable by most programmers for a long time, so long as it’s architected well.

    This would also point to mega-projects being inherently doomed to failure - a conclusion that’s pretty well supported by reality (see NPfIT in the UK..).

  3. Avatar
    Musashi 1 day later:

    As one that has only ever worked in the J2EE field, I’ll restrict my comments to that.

    I certainly agree that as projects progress, the complexity can increase to the point where the effort to maintain them outweighs any percieved benefit - thus leading to programmer dissatisfaction. I would contend that the reasons that drive this are not always the language, but have a lot to do with management, architecture and adherence to good design/code standards.

    Management will set unsupportable timeline::feature lists; this leads to poor and sloppy design/code being permitted to meet timelines (with the ancient lie/delusion that “we’ll fix it later”). I worked numerous projects where coders were permitted to hack-code to make new features work which had been sanctioned by management (while Architects quit in protect). Good design principles (http://www.oma.com/resources/publishedArticles.html) and coding standards have been around for many years - and I’m still shocked at how many projects I visit where they are not applied. Indeed, many of the principles that people break, defeat the whole purpose of choosing an OO language (if indeed they chose it based upon rational reasons). Further to this, many people are still “afraid” to do some simple refactoring to clean bad-smells before they become code-cancers.

    So, in-short, your graphs are pretty; but in reality, they are no where near what real world impact can be - and the reasons aren’t the choice of the language, but rather, the way that the language gets implemented.
    Also, setting up an initial J2EE environment including DB connectivity, Source Control, build scripts etc takes a lot longer than 3-weeks. :-)

  4. Avatar
    daniel 12 days later:

    Musashi:

    (for the record, I know Musashi irl)… I agree that those are all huge factors. However, I think that reducing the importance of language choice to being a minor factor is wrong.

    Taking my examples… Java and Ruby intrinsically allow those code smells to be detected and hence fixed. PHP does not. That puts PHP at a huge longer term disadvantage.

    It takes 3 weeks to set up a J2EE environment? It takes less than an hour to set up a full-stack MVC + automated unit tests + database + code control environment for Rails development. In the time that you take to set up a development environment, I managed to:

    • Learn Rails
    • Learn the Facebook API
    • Build an SMS gateway connector
    • Build a moderately complex facebook app
    • Build two automated test suits for it (I switched to RSpec halfway through)
    • Deploy this application and accumulate about 4 hundred users

    This puts Java at a huge up-front disadvantage, one that even the best project manager can’t make up for.

    I totally agree that the factors you mention can be and are often very significant, and they will skew your chosen language’s “baseline” in various directions, but the difference between the languages themselves is still very real and its effect on development cost is, I believe, an order of magnitude larger than that of management or customer decisions.

    No matter how wrong management might get it, they cannot get it so wrong as to turn a J2EE application into the maintenance nightmare that a large PHP application represents. And no matter how right they get it, they can never make Java development be as quick and nimble for smaller applications as PHP development is, either!

    Daniel

Comments