Better Programming

Advice for programmers.

Follow publication

You're unable to read via this Friend Link since it's expired. Learn more

Member-only story

Code Readability or Performance: Which Is More Important?

Bikash Paneru
Better Programming
Published in
9 min readJun 24, 2021
a perplexed-looking woman and the words “performance?” and “readability?”
Base image by ospanali on unsplash

The discussion around the importance of code readability compared to performance has been floating around on the internet for a long time. However, it is difficult to come up with an objective answer.

So let’s try to analyze readability and performance in different contexts instead of trying to find an objective answer.

Let’s start with a question: Is this readable code?

- .... .. ... / .. ... / .-. . .- -.. .- -... .-.. .

This is actually Morse code that translates to “this is readable!” You might say that this is readable if you know Morse Code. Now, does it make sense to call this code unreadable if you do not know Morse code? Not really, because it is readable Morse code.

Now let’s apply this to software. Can you figure out what the following code does by taking a quick glance at it?

This is actually an implementation of the bubble sort. If you know how bubble sort works and are used to writing algorithms like this, then you could probably figure it out in a quick glance. However, if you have never looked at the bubble sort algorithm before, you might take some time to figure this out.

Would you call this code unreadable just because it could take some extra time for people unfamiliar with the topic to understand it? This question brings us to our first point.

If the above algorithm intrigued you, then take a look at this detailed explanation and analysis of bubble sort by Vaidehi Joshi. I read this a while back and think it is an interesting read.

Readability is not tied to concepts

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Bikash Paneru
Bikash Paneru

Written by Bikash Paneru

Technology for Passion, Noodles for Hair and Junk for Food. https://mrdivinemaniac.github.io/

Responses (1)

Write a response