I have always been under the impression that most of the population doesn't have whatever it is that makes us able to be effective programmers. Even among programmers there is something that distinguishes the really good from the really average. What is it in the brain that is so different?
Some time ago I read an article where someone postulated that programmers and people with autism have similar brain features (though not exactly the same of course). Some type of mental differences in how the brain processes information that is not found in most of the population. Although the typical stereotype of a geeky nerd who never showers, stays up 3 days in a row to code, and has no social skills comes to people's minds, I really don't find any consistent outward signs in all the programmers I have known over my career. Most have been fairly normal people who are nonetheless possess the ability to write an debug code. Some did exhibit the stereotypical traits but in most cases you wouldn't know they were programmers by how they acted.
Something however does distinguish the programmer from the non-programmer, and the good one from the average. A set of mental skills and talents, a creative outlook, ability to concentrate deeply, and an intense need to slay problematic dragons. You can find many of these traits in other professions, but programming above all is a dense combination of mental abilities that (rarely) require an advanced education.
Almost all other professions take a long time to learn the basics before you move beyond them. Becoming a doctor takes 7 years or more. In many professions such as architecture and chemistry you need advanced degrees and long practice before anyone allows you to do any original work. Yet I have know people who barely graduated high school be able to write complex software. I never had any formal programming education and taught myself; although I did start working on a masters in chemistry I basically flunked out and got a programming job by pure luck.
People either are able to program or not. Education can help prepare you better and give you better tools to start with, but if your mental capabilities are those required to program then you won't be able to do it. Pure intelligence doesn't matter. One of the worst pieces of code I ever saw (a 29,000 line C program in one file with a 14,000 line event loop) was written by a guy with a PhD in some science field. He just didn't get how you structured and debugged a program despite working on it for 18 months.
One time I had a guy I work with come to my office every day for months and explain what he needed to do (in boring detail) and finally ask me what he how to proceed. I basically helped him write his entire project; he simply didn't want to admit he didn't know how. Oddly enough he later went to work at NASA as an engineer.
I have had people work on my projects who didn't have a clue and I would basically write most of their code for them (this happened a lot during the dot-com era). One guy I worked with was one of the first people I knew who got a java certification, yet he simply had no concept of how to build an application. Knowing syntax doesn't make you a programmer.
Programming requires the ability to concentrate on purely abstract concepts using an arcane set of languages and tools, and to create something from nothing that makes a computer do something useful. You need to be able to imagine a solution to an imprecisely defined problem that you can't see or touch. When you do create this something you often have to fix problems in it with very little or even misleading information.
I remember back in my Deltagraph days getting one line bug reports like "I opened some file and it crashed" with no further details or examples. Solving this type of bug requires an immense understanding of the application and its pathways plus the ability to imagine what possible set of circumstances could lead to a user reporting this. Sometimes it seems like you are solving a murder with no body, no evidence, no perp and not a clue where it happened. Yet everyday we face similar challenges that nonetheless have to be dealt with.
It's funny that I don't feel all that bright, lots of things seem way over my head. I made a "D" in comparative anatomy in college because I simply couldn't remember all those stupid blood vessels, yet I think nothing of working with a dozen different technologies on a huge project. Again, it's not knowing syntax (I purposefully forget it) since I remember where to look it up, but the much more vague ability of integrating the whole project in my head. I still remember how I approached virtually every project I have ever worked on but can't remember a method I used last week in some common java class.
Programmers are not geniuses, but there are genius programmers who can be orders of magnitude more productive than the rest of us. I remember that one guy wrote the original 68K emulator at Apple in PowerPC assembly language in a single weekend. Amazing.
For most non-programmer people programming a computer seems like magic, and somehow they think that as a programmer you must be smarter than other people. It's very difficult to explain to them what it is that makes us programmers function. Usually I tell people "I tell computers what to do and sometimes they do it". That's about as far as you go before their eyes glaze over and they fall asleep on you.
So the next time you write some code, imagine that you are one of a small (and at least in the US, getting smaller) group of mildly autistic savants who think of things that aren't there and build things that don't really exist, all while downing Jolt Cola (which I miss) and dreaming of the day when the program actually works the first time.