On Simply Writing Simple Code

Thursday • December 1st 2022 • 11:12:46 pm

On Simply Writing Simple Code

Thursday • December 1st 2022 • 11:12:46 pm

Programming is not just about writing computer programs, it is also about reading and understanding them in the future.

Sometimes, it is a good idea, to look at our computer programs…

From years in the future, and ask, what would the older me wish to see.

There are usually three choices, tasty spaghetti code, which can be demanding to read.

Object oriented code, which can work, in theory, but rarely does in practice.

And functional programming code, which is about as limited as it gets.

But it is actually what we want, because it enforces simplicity.

Functional programming, demands that we write small functions.

That take input, and produce output.

And they only really run, in a single line.

You don’t really need anything for it, but putting the functions you want to run…

In a list or an array, can further enforce the simplicity.

There is no branching logic here, you just put huge chunks of the whole program…

In a single, column.

What simple functional programming, means in practice, is simplicity.

So that when the older you, does come back to change something.

No only does the older you get programs, that are all written in a simple single line.

And thus reveal what they are doing, with their function names.

But you can also, take this list of functions.

And inject some debug and logging functions in between.

Because it is just, input and output.

You can inspect, what the functions are sending down the program.

All this simplicity, adds to create flexibility for your future self.

But don’t worry, you don’t have to learn a new programming style.

Simply, learn from it, and build your programs out of simple functions,

That are simply executed, in an easy to inspect and extend sequence.