One of the answers to my “controversial opinions” question on Stack Overflow claims that “programming is so easy a five year old can do it.“
I’m sure there are some aspects of programming which a five year old can do. Other parts are apparently very hard though. Today I came to the following conclusion:
- If your code deals with arbitrary human text, it’s probably broken. (Have you taken the Turkey test recently?)
- If your code deals with floating point numbers, it’s probably broken.
- If your code deals with concurrency (whether that means database transactions, threading, whatever), it’s probably broken.
- If your code deals with dates, times and time zones, it’s probably broken. (Time zones in particular are hideous.)
- If your code has a user interface with anything other than a fixed size and a fixed set of labels (no i18n), it’s probably broken.
You know what I like working with? Integers. They’re nice and predictable. Give me integers, and I can pretty much predict how they’ll behave. So long as they don’t overflow. Of have an architecture-and-processor-dependent size.
Maybe you think I’m too cynical. I think I’m rather bullish, actually. After all, I used the word “probably” on all of those bullet points.
The thing that amazes me is that despite all this hardness, despite us never really achieving perfection, programs seem to work well enough most of the time. It’s a bit like a bicycle – it really shouldn’t work. I mean, if you’d never seen one working, and someone told you that:
- You can’t really balance when it’s stationary. You have to go at a reasonable speed to stay stable.
- Turning is a lot easier if you lean towards the ground.
- The bit of the bike which is actually in contact with the ground is always stationary, even when the bike itself is moving.
- You stop by squeezing bits of rubber onto the wheels.
Would you not be a touch skeptical? Likewise when I see the complexity of software and our collective failure to cope with it, I’m frankly astonished that I can even write this blog post.
It’s been a hard day. I achieved a small victory over one of the bullet points in the first list today. It took hours, and I pity my colleague who’s going to code review it (I’ve made it as clear as I can, but some things are just designed to mess with your head) – but it’s done. I feel simultaneously satisfied in a useful day’s work, and depressed at the need for it.