Optimize for developer cycles, not CPU cycles

Performance in software development matters less than you might think. I bet that you waste plenty of CPU cycles and memory for zero good reasons somewhere you aren't looking at and wouldn't look at by intention.

Example: binary vs textual encoding

Today I had a talk to a fellow developer who argued that binary encoding is faster than textual. He isn't wrong! Binary encodings mean less work to the CPU. The talk was about an application that received messages of around 100 bytes once a second from around 20 to 30 IoT devices (not becoming more in the foreseeable future) via MQTT.

For a today's PCs (2023) that's a piece of cake - even for the weakest ones. The application does more than receiving those messages but still it's literally nothing.

The much bigger problem is that binary encodings lack a lot of standard tooling. Look at all the standard UNIX utilities like sed, grep, cat, and many more that you just lock out of your toolbox with binary encodings.

You lose the inspectability of messages and network traffic with tools like wireshark when things go wrong or you need to find bugs. When a stream of data is text you just look at it and most likely you can make sense of it. Not with binary, sorry! UNIX has the philosophy "text is the universal protocol" for good reasons.

Takeaway

Optimize for developer performance not hardware performance! Developers cost more than CPU cycles (in most cases). When you spot bootlenecks do your homework and profile the application. No uninformed, gut-feeling refactoring to make code faster!

So stop thinking about performance beforehand! Every time before you write code and you feel the need to make the "fastest" solution or introduce some "clever" pre-calculated variables, think twice!

Since a lot of good software development advice today, and I'd call it state-of-the-art knowledge, advocates against premature optimization it's still impressive that these performance discussions with colleagues never vanish, and perhaps won't ever.

Disclaimer

I still catch myself wanting to "optimize" where there's nothing to optimize (for now). Knowing this feeling and being able to suppress it I'd consider myself healed from "premature optimization" disease.

Back