Why programming is mentally hard?

Jukka Paulin
2 min readDec 27, 2023

--

There may be a lot of reasons why, even though you would like to, it seems to be hard to write software.

I wrote earlier, a few years ago this question: “Why programming is mentally hard?”

A simple recipe to produce software, from anyone who has studied computer science, is
that ‘data structures + algorithms = code’.

So in theory it should be quite simple to do programming.

Since algorithms have become very abundant, being developed in laboratories, universities, and often also being published to be fully used by anyone, we’d intuitively think that software would be even easier than placing LEGO blocks on top of each other.

Programming is perhaps best learned by following examples. Repeating what others have done, has a value to it. Even though it might seem counterintuitive to do something that has “already been done”, the difference is that when you do it yourself, even typing manually some piece of example code, that very act of concentrating on it, and more importantly, thinking what the machine will do on seeing your commands — this is what teaches programming.

Errors are important things to encounter. Did you know, that even AI learns of asymmetry of the data that it encounters? Errors are important guidance to making code. Be curious about troubleshooting and solving errors, while coding. To be little bit smarter than I am, I’m going to give you one Tip: write very small chunks at a time — and run your code. This way you will see instantly if it has bugs. Fix them. (Commit, if you use ‘git’). Grab yourself a mental pat on the head, or cup of tea or coffee. Rinse and repeat.

Learning the elementary building blocks of code is a sure step in advancing towards mastery of programming.

Computer code, after all, can be distilled down to very few elementary things:

storing values of data, in variables

doing arithmetic operations

handling strings (language)

restoring (loading) a state — to continue your adventures from a well known place

calling subroutines (functions)

writing those subroutines, to keep your mental model clear

combining things (this is called ‘compounding functions’ in the theory of computer languages)

comparing two things — the ‘if’ and ‘switch’ keywords in many languages

acting upon the results of comparison ‘then’, jumping to another place to execute a branch of code

Subroutines

The importance of having functions (also called ‘subroutines’) is that it makes the main code more clear. There is a lot of opinions and almost devout rules about how to write good subroutines; but suffice to say, these routines help your brain manage the complexity. There is a well-known concept of ‘wishful thinking’ in computing — it’s a methodology to postpone, for now, some of the hard parts and some of the details of your future code. Programming by Wishful Thinking (flatrick.github.io)

Do it!

If you’re curious, don’t hesitate. Try out some programming. Start with looking at examples, run them yourself. Take the simplest of environments. Every error that you encounter, is a learning step. The world of developers is out there, go ahead and ask! You will be helped.

--

--

Jukka Paulin
Jukka Paulin

Written by Jukka Paulin

Blogger, human bean, geek. Owner of Jukkasoft.com and secret Wordpress lover.

No responses yet