Programming is hard

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.

Published Thursday, January 29, 2009 8:28 PM by skeet
Filed under: ,

Comments

# re: Programming is hard

I don't know if you intended it to, but I don't think that your post rebuts the claim that programming is easy.  Each of the domains that you mentioned is certainly not easy to deal with, but the problems (to my mind) are related to those domains (sometimes inherently, sometimes due more to historical baggage) rather than programming per se.

I think that the problem is that although a professional programmer often needs to deal with the thorny issues you've raised, I don't consider them "programming" in the pure sense.

Thursday, January 29, 2009 4:47 PM by Keith

# re: Programming is hard

I agree that they're inherently hard - but I count that as part of programming in every *practical* sense.

Put it this way: a programmer who could do the "pure" stuff but couldn't make even a stab at any of these wouldn't be much use as a professional developer.

Thursday, January 29, 2009 4:56 PM by skeet

# re: Programming is hard

I agree with your sentiment, and I apologize if I'm just arguing semantics, but I think that the distinction between "programming" and "professional software development" is important.  I think that if more developers mentally separated the task of modelling the real world (the hard part) and implementing that model using the programming language of their choice (relatively easy, though not without its own challenges), the industry would be in better shape.

In particular, I think that too often when teaching people to be developers, we fail to explicitly teach the skills required to do the hard parts, but expect them to somehow pick the knowledge up from reading real-world code.  This makes "programming" look harder than it really is (because people are actually trying to pick up both the programming language as well as design patterns for representing messy real world concepts).  At the same time, it doesn't give people the right mindset to approach profession software development, because the design patterns are often completely implicit in the code they read, and there's no discussion of alternative designs and the tradeoffs that would make one design favored over the other.

Thursday, January 29, 2009 9:14 PM by Keith

# re: Programming is hard

I agree and you could also add this to the list:

- If your code needs to run in any kind of security context it is probably broken.

- If your code uses any resources where non-trivial clean-up is needed it is probably broken.

Friday, January 30, 2009 12:52 AM by Brian Rasmussen

Leave a Comment

(required) 
(required) 
(optional)
(required)