All posts

Side effects are too complicated

Why software needs to be modular and what that means

Side effects are too complicated

I am not smart enough to think about side effects and you aren't either

When writing software, especially as a beginner, one tends to think of variables as something that is, well, variable.

While this is technically correct, I want to make an argument about how it hinders the readability and maintainability of software to have things that change.

Changing values actually has a name; it's called Mutability.

When learning programming, you will most certainly stumble upon mutability very early on, likely when whoever is introducing you to programming is explaining basic mathematical operators.

Consider this:

let x = 1
x = x + 1

Easy enough, right? x is now 2, everyone is happy!

Why that's bad

The variable x now has multiple meanings throughout your code. Depending on where you look, there are different values for x. While the above example is rather easy to understand, this changes quickly when code becomes more complex.

Take a look at the following example:

let x = 1
let y = 2

if (x < y) x = 3
if (y > x) y = 4

While I admit that this code is pretty useless, it highlights a point: You need to read it in full and think about it to understand it.

The value of x changes throughout the code and therefore changes the outcome of the y > x check.

What should you do instead?

Everything should only have one value that never changes.

Sure, there are cases where it makes sense from a performance perspective to use mutation, but for those cases one should write a dedicated function.

const x = 1
const y = 2

These values will not change. Once you know what they are you can trust them.

© 2026 tiha.io /// NUXT · CONTENT