In Defense of Efficient Computing

We all know that the cost of computing is on a definitive downtrend and while this is a great thing I worry that it is also steering developers to become less proficient in writing efficient (and reliable) code.

If most problems can be solved by throwing money and hardware at sub par wasteful code, what is the incentive to writing thoughtful, efficient programs?

The answer is RELIABILITY (and possibly to save your planet)

While the cost of computing is going down the adoption of dynamic languages is going up and that worries me. Perhaps I am just a backwards man who hasn’t seen the light yet but I urge you to bear with me as I present my argument against the use of dynamic languages in a production environment.

Why do I claim that dynamic languages are wasteful?

If you appreciate theater it is likely that you also appreciate that  the actors have to work hard at every performance. It is a beautiful thing, but it is also a lot of repetitive work and that is exactly the problem with dynamic languages in general.

How so? Every execution (performance) requires that a lot of work is done by the language runtime (showtime) environment. Most of the time this is repetitive work, mindlessly repeated every time you run your code.

Compare this with the stark contrast of cinema (compiled code) – there is no showtime hustle, the movie is already shot, cut, edited and packaged for delivery. No energy is wasted.

You might ask me how significant is this waste I am talking about and the truth is that most of the time it is negligible but like everything in life, the devil is in the details.

Hypothetically, let us say that at each execution a dynamic program wastes a mere 10,000 CPU cycles doing “preventable runtime busy-work”. That figure is utterly insignificant if you are looking at the trees only, but as you step back to look at the forest your perspective might change.

Imagine this same piece of code running on a few hundred-thousand computers around the world and being executed a few thousand times a day on each. Now multiply this by each program of each dynamic language in existence and you might conclude that dynamic languages are not very good for our planet because computing demands energy and energy demands natural resources.

So, if you believe in green computing through algorithmic efficiency you already have a good case against the use of dynamic languages.

“But dynamic languages are more productive so the energy wasted on one end is saved on another!”

Some might argue that dynamic languages are able to offset their “global footprint” by being more productive. Unfortunately, I beg to differ.

Unless you are simply writing throwaway (or generally short-lived) code, the odds are that whatever you are building will remain in play for years to come. This brings two new variables into the equation, one is maintenance costs and the other is failure costs. I am going to argue that compiled languages do a better job at minimizing those costs in the long run due to the increased reliability they offer.

First, we need to define what “productive” means in a quantifiable way because there is no room for fuzzy subjective opinions in computer science.

I believe that the Total Cost of Ownership (TCO) of a software solution is the ideal metric of productivity. A language that can deliver a piece of software with a lower lifetime TCO should be considered more productive simply because more was produced for less.

TCO encompasses everything from time-to-market risk, development costs, maintenance costs, failure-rate costs as well as any other overhead incurred.

My argument is that while dynamic languages may accelerate the initial delivery of a software solution, it does so at the cost of reliability and maintainability. This is detrimental for the TCO bottom line because in practical terms (at least for large, long-lived projects) it translates into decreased productivity.

“But compiled languages are too hard!”

 

The place for dynamic languages

With all that being said, I must disclose that I often use dynamic languages in my research when it makes sense, mostly for throwaway code or prototyping. In fact, one of my favorite tools (MATLAB) is centered around a particularly terrible dynamic language. What I am against is using dynamic languages for the development of code intended for production environments. That is all.

Conclusion

If you love our planet and you love computer science, I urge you to not take the easy way out, embrace the beautiful complexity of machine efficient code and write greener programs by using a compiled language. It can only make you smarter in the long run :)

1 comment

  1. Ken Dakin   •  

    Rod,
    I completely agree with your article and always wonder where people are coming from when they happily waste resources just because they can get away with it. Having faster processors is good because we can do lots more work for the same cost (or get faster answers to time critical questions) – not because we can acheive the same result by allowing ourselves to get lazy. I agree that for one-off programs that are run a couple of times it doesn’t matter too much – but one-off programs have a tendency to outlive their creators and get modified to create more one-off programs that may also persist. This way lies madness (non-maintainable code that is both inefficient and inconsistent).
    For production programs we should construct solid frameworks that are as efficient as possible (and as re-useable as possible unless this conflicts with performance to a great extent). Most of the programs and sub-routines I produced over 40+ years were written with efficiency constantly in mind and yet they also had close to zero bugs and needed few changes if any over their very long lifetimes of 20 years or more. I produced instruction set simulators for test/debugging purposes where zero tolerance was the only option (otherwise the products would have been worse than useless and given false positives).
    I would like to say that I very much enjoy your blog and I am as impressed, as you clearly are, by the awe inspiring JFK speech which always gives me goosebumps each time I see it. My own wish is that world leaders get together soon and jointly commit to setting up a base on Mars by 2030 say. This might also kick start the world economy for years to come and inspire a new generation like nothing else could. My audacious vision is that we should send self assembly robots to carve out an underground base first using only materials to hand (e.g. to fashion most of the ‘boring components’ out of natural rock for instance – at ever increasing scales) and follow this with a manned expedition to secure and populate the prepared space.

Leave a Reply