Performance vs Readability: the biggest dilemma

Let’s say you want to start a FLOSS project.
How many people did that up to now? Many.
But there is a problem, or better, a conflict of goals.

In one hand, you have the need of making your code fast enough. Which task is even more complex if you are using an interpreted language (for reasons out of the scope of this blog post). On the other hand (:D) there is the very important requirement of keeping your code human readable.
Languages, in general, have several “syntax levels” basing on developer’s skills. Newbies tend to stick to what is the standard way of writing, say, a for loop, while more skilled people are able to exploit all the potential of the language by using very exotic “code constructs”. Again, I don’t want to get into any particular language here, I just want to explain the trade-off that a developer, especially a FLOSS one has to accept when writing software.

It’s obvious that the two things, performance and readability, don’t play nice together. And the former, causes wannabe-developers to have hard times understanding how a particular function works. The worst case here is that the same developers will give up ahead of time. This is one of the reasons why the faster and more complex a codebase is, the harder is to start contributing to it.

There are two reasons that bring developer to choose performance over readability anyway: the former brings them an orgasming sensation of owning the whole World. And writing obfuscated code is just another way to tell the world how c00l someone is (l33t). Unfortunately, most of the times people doing that are right. Because it’s the only way to get applications working without annoying users with high wait times.

“In a perfect world, there wouldn’t be no need for caching”. Myself.

Yes, caching is a perfect example of the trade off between readability and performance. Caching a particular data retrieval code, increases its complexity, by the need of validating, tainting, generating, removing, (etc), cached data.

About lxnay

the creator of Sabayon Linux, Entropy Package Manager {Eit, Equo, Rigo}, Molecule release media buildsystem, Matter Portage buildbot/tinderbox and only God knows what else...

2 responses to “Performance vs Readability: the biggest dilemma

  1. Stupot

    Comments in code always help.

    Unfortunately, the way that complicated code tends to be put together is almost more of a trial and error. Nobody wants to comment their code until it’s working and by the time it is, they get lazy and just put a generic comment.

    I haven’t actually contributed much to FLOSS code, but I’ve gleamed this much from working with devs in the profession.

  2. Radtoo

    Keeping code encapsulated to be much simpler on the outside than on the inside is very important. Not matter how you look at it, we don’t really understand even the simplest programs down to the lowest level. It is only “simple” there because it is encapsulated nicely. So, whatever “cool” and “optimized” stuff you or anyone else does on the inside of some program, it needs to simply be a part of a program and composing it with other parts needs to be simple. Otherwise we drown ourselves in complexity. Maths and our hardware mostly do that already, so the problem mainly is in software.

    Many languages just aren’t too good at creating composable code – parts are too strongly connected to be reusable or even distinguishable in these that spoils it all, complexity “spills over”. And that is why this trade-off between performance and readability is so strong in many languages right now.

    At least we’re getting closer to much better composability in software now, with unit testing, functional programming and other things are getting quite some attention lately.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

hello, twitter

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 585 other followers

del.icio.us

%d bloggers like this: