What’s the deal with programming, as a careeer? It seems like the lower levels at least should be readily accessible even to people of thoroughly average intelligence but I’ve read a lot that leads me to believe the average professional programmer is borderline incompetent.
E.g., Fizzbuzz. Apparently most people who come into an interview won’t be able to do it. Now, I can’t code or anything but computers do only and exactly what you tell them (assuming you’re not dealing with a thicket of code so dense it has emergent properties) but here’s what I’d tell the computer to do
#
Proceed from 0 to x, in increments of 1, (where x =whatever)
If divisible by 3, remainder 0, associate fizz with number
If divisible by 5, remainder 0, associate buzz with number,
Make ordered list from o to x, of numbers associated with fizz OR buzz
For numbers associated with fizz NOT buzz, append fizz
For numbers associated with buzz NOT fizz, append fizz
For numbers associated with fizz AND buzz, append fizzbuzz
#
I ask out of interest in acquiring money, on elance, rentacoder, odesk etc. I’m starting from a position of total ignorance but y’know it doesn’t seem like learning C, and understanding Conrete Mathematics and TAOCP in a useful or even deep way would be the work of more than a year, while it would place one well above average in some domains of this activiteity.
Or have I missed something really obvious and important?
I have no numbers for this, but the idea is that after interviewing for a job, competent people get hired, while incompetent people do not. These incompetents then have to interview for other jobs, so they will be seen more often, and complained about a lot. So perhaps the perceived prevalence of incompetent programmers is a result of availability bias (?).
This theory does not explain why this problem occurs in programming but not in other fields. I don’t even know whether that is true. Maybe the situation is the same elsewhere, and I am biased here because I am a programmer.
That means, in this horribly simplified universe, that the entire world could consist of 1,000,000 programmers, of whom the worst 199 keep applying for every job and never getting them, but the best 999,801 always get jobs as soon as they apply for one. So every time a job is listed the 199 losers apply, as usual, and one guy from the pool of 999,801 applies, and he gets the job, of course, because he’s the best, and now, in this contrived example, every employer thinks they’re getting the top 0.5% when they’re actually getting the top 99.9801%.
Makes sense.
I’m a programmer, and haven’t noticed that many horribly incompetent programmers (which could count as evidence that I’m one myself!).
Do you consider fizzbuzz trivial? Could you write an interpreter for a simple Forth-like language, if you wanted to? If the answers to these questions are “yes”, then that’s strong evidence that you’re not a horribly incompetent programmer.
Could you write an interpreter for a simple Forth-like language, if you wanted to?
Probably; I made a simple lambda-calculus interpret once and started working on a Lisp parser (I don’t think I got much further than the ‘parsing’ bit). Forth looks relatively simple, though correctly parsing quotes and comments is always a bit tricky.
Of course, I don’t think I’m a horribly incompetent programmer—like most humans, I have a high opinion of myself :D
I’m probably not horribly incompetent (evidence: this and this), but there exist people who are miles above me, e.g. John Carmack (read his .plan files for a quick fix of inferiority) or Inigo Quilez who wrote the 4kb Elevated demo. Thinking you’re “good enough” is dangerous.
What’s the deal with programming, as a careeer? It seems like the lower levels at least should be readily accessible even to people of thoroughly average intelligence but I’ve read a lot that leads me to believe the average professional programmer is borderline incompetent.
From what I can tell the average person is borderline incompetent when it comes to the ‘actually getting work done’ part of a job. It is perhaps slightly more obvious with a role such as programming where output is somewhat closer to the level of objective physical reality.
Proceed from 0 to x, in increments of 1, (where x =whatever) If divisible by 3, remainder 0, associate fizz with number If divisible by 5, remainder 0, associate buzz with number, Make ordered list from o to x, of numbers associated with fizz OR buzz For numbers associated with fizz NOT buzz, append fizz For numbers associated with buzz NOT fizz, append fizz For numbers associated with fizz AND buzz, append fizzbuzz
I don’t know anything about FizzBuzz, but your program generates no buzzes and lots of fizzes (appending fizz to numbers associated only with fizz or buzz.) This is not a particularly compelling demonstration of your point that it should be easy.
(I’m not a programmer, at least not professionally. The last serious program I wrote was 23 years ago in Fortran.)
The bug would have been obvious if the pseudocode had been indented. I’m convinced that a large fraction of beginner programming bugs arise from poor code formatting. (I got this idea from watching beginners make mistakes, over and over again, which would have been obvious if they had heeded my dire warnings and just frickin’ indented their code.)
Actually, maybe this is a sign of a bigger conceptual problem: a lot of people see programs as sequences of instructions, rather than a tree structure. Indentation seems natural if you hold the latter view, and pointless if you can only perceive programs as serial streams of tokens.
I got this idea from watching beginners make mistakes, over and over again, which would have been obvious if they had heeded my dire warnings and just frickin’ indented their code.
This seems to predict that python solves this problem. Do you have any experience watching beginners with python? (Your second paragraph suggests that indentation is just the symptom and python won’t help.)
Your general point is right. Ever since I started programming, it always felt like money for free. As long as you have the right mindset and never let yourself get intimidated.
Your solution to FizzBuzz is too complex and uses data structures (“associate whatever with whatever”, then ordered lists) that it could’ve done without. Instead, do this:
for x in range(1, 101):
fizz = (x%3 == 0)
buzz = (x%5 == 0)
if fizz and buzz:
print "FizzBuzz"
elif fizz:
print "Fizz"
elif buzz:
print "Buzz"
else:
print x
This is runnable Python code. (NB: to write code in comments, indent each line by four spaces.) Python a simple language, maybe the best for beginners among all mainstream languages. Download the interpreter and use it to solve some Project Euler problems for finger exercises, because most actual programming tasks are a wee bit harder than FizzBuzz.
The least-effort strategy, and the one I used for my current job, is to talk to recruiting firms. They have access to job openings that are not announced publically, and they have strong financial incentives to get you hired. The usual structure, at least for those I’ve worked with, is that the prospective employee pays nothing, while the employer pays some fraction of a year’s salary for a successful hire, where success is defined by lasting longer than some duration.
(I’ve been involved in hiring at the company I work for, and most of the candidates fail the first interview on a question of comparable difficulty to fizzbuzz. I think the problem is that there are some unteachable intrinsic talents necessary for programming, and many people irrevocably commit to getting comp sci degrees before discovering that they can’t be taught to program.)
I think the problem is that there are some unteachable intrinsic talents necessary for programming, and many people irrevocably commit to getting comp sci degrees before discovering that they can’t be taught to program.
I think there are failure modes from the curiosity-stopping anti-epistemology cluster, that allow you to fail to learn indefinitely, because you don’t recognize what you need to learn, and so never manage to actually learn that. With right approach anyone who is not seriously stupid could be taught (but it might take lots of time and effort, so often not worth it).
Formal credentials certainly help, but I wouldn’t say they’re required, as long as you have something (such as a completed project) to prove you have skills.
My first paying job was webmaster for a Quake clan that was administered by some friends of my parents. I was something like 14 or 15 then, and never stopped working since (I’m 27 now). Many people around me are aware of my skills, so work usually comes to me; I had about 20 employers (taking different positions on the spectrum from client to full-time employer) but I don’t think I ever got hired the “traditional” way with a resume and an interview.
Right now my primary job is a fun project we started some years ago with my classmates from school, and it’s grown quite a bit since then. My immediate boss is a former classmate of mine, and our CEO is the father of another of my classmates; moreover, I’ve known him since I was 12 or so when he went on hiking trips with us. In the past I’ve worked for friends of my parents, friends of my friends, friends of my own, people who rented a room at one of my schools, people who found me on the Internet, people I knew from previous jobs… Basically, if you need something done yesterday and your previous contractor was stupid, contact me and I’ll try to help :-)
ETA: I just noticed that I didn’t answer your last question. Not sure what to recommend to competent programmers because I’ve never needed to ask others for recomendations of this sort (hah, that pattern again). Maybe it’s about networking: back when I had a steady girlfriend, I spent about three years supporting our “family” alone by random freelance work, so naturally I learned to present a good face to people. Maybe it’s about location: Moscow has a chronic shortage of programmers, and I never stop searching for talented junior people myself.
I took an internship after college. Professors can always use (exploit) programming labor. That gives you semi-real experience (might be very real if the professor is good) and allows you to build credibility and confidence.
Python tip: Using “range” creates a big list in memory, which is a waste of space. If you use xrange, you get an iterable object that only uses a single counter variable.
There was a discussion of transitioning to Python 3 on HN a week or two ago; apparently there are going to be a lot of programmers, and even more shops, holding off on transitioning, because it will break too many existing programs. (I haven’t tried Python since version 1, so I don’t know anything about it myself.)
A big problem with transitioning to Python 3 is that there are quite a few third-party libraries that don’t support it (including two I use regularly—SciPy and Pygame). Some bits of the syntax are different, but that shouldn’t be a huge issue except for big codebases, since there’s a script to convert Python 2.6 to 3.0.
I’ve used Python 3 but had to switch back to 2.6 so I could keep using those libraries :P
I’ve read a lot that leads me to believe the average professional programmer is borderline incompetent.
Programming as a field exhibits a weird bimodal distribution of talent. Some people are just in it for the paycheck, but others think of it as a true intellectual and creative challenge. Not only does the latter group spend extra hours perfecting their art, they also tend to be higher-IQ. Most of them could make better money in the law/medicine/MBA path. So obviously the “programming is an art” group is going to have a low opinion of the “programming is a paycheck” group.
And going by his other papers, though, it looks like the effect isn’t nearly so strong as was originally claimed. (Though that’s wrt whether his “consistency test” works, didn’t check about whether bimodalness still holds.)
No, just personal experience and observation backed up by stories and blog posts from other people. See also Joel Spolsky on Hitting the High Notes. Spolsky’s line is that some people are just never going to be that good at programming. I’d rephrase it as: some people are just never going to be motivated to spend long hours programming for the sheer fun and challenge of it, and so they’re never going to be that good at programming.
I’d rephrase it as: some people are just never going to be motivated to spend long hours programming for the sheer fun and challenge of it, and so they’re never going to be that good at programming.
This is a good null hypothesis for skill variation in many cases, but not one supported by the research in the paper gwern linked.
In addition to this, if you’re a good bricklayer, you might do, at most, twice the work of a bad bricklayer. It’s quite common for an excellent programmer (a hacker) to do more work than ten average programmers—and that’s conservative. The difference is more apparent. My guess might be that you hear this complaint from good programmers, Barry?
Although, I can guarantee that everyone I’ve met can do at least FizzBuzz. We have average programmers, not downright bad ones.
I’ll second the suggestion that you try your hand at some actual programming tasks, relatively easy ones to start with, and see where that gets you.
The deal with programming is that some people grok it readily and some don’t. There seems to be some measure of talent involved that conscientious hard word can’t replace.
Still, it seems to me (I have had a post about this in the works for ages) that anyone keen on improving their thinking can benefit from giving programming a try. It’s like math in that respect.
i think you overestimate human curiosity for one. Not everyone implements prime searching or Conways game of life for fun.
For two. Even those that implement their own fun projects are not necessarily great programmers. It seems there are those that get pointers, and the others.
For tree, where does a company advertise? There is a lot of mass mailing going on by not competent folks.
I recently read Joel Spolskys book on how to hire great talent, and he makes the point that the really great programmers just never appear on the market anyway.
It seems there are those that get pointers, and the others.
Are there really people who don’t get pointers? I’m having a hard time even imagining this. Pointers really aren’t that hard, if you take a few hours to learn what they do and how they’re used.
Alternately, is my reaction a sign that there really is a profoundly bimodal distribution of programming aptitudes?
Are there really people who don’t get pointers? I’m having a hard time even imagining this. Pointers really aren’t that hard, if you take a few hours to learn what they do and how they’re used.
There really are people who would not take that few hours.
I don’t know if this counts, but when I was about 9 or 10 and learning C (my first exposure to programming) I understood input/output, loops, functions, variables, but I really didn’t get pointers. I distinctly remember my dad trying to explain the relationship between the * and & operators with box-and-pointer diagrams and I just absolutely could not figure out what was going on. I don’t know whether it was the notation or the concept that eluded me. I sort of gave up on it and stopped programming C for a while, but a few years later (after some Common Lisp in between), when I revisited C and C++ in high school programming classes, it seemed completely trivial.
So there might be some kind of level of abstract-thinking-ability which is a prerequisite to understanding such things. No comment on whether everyone can develop it eventually or not.
One of the epiphanies of my programming career was when I grokked function pointers. For a while prior to that I really struggled to even make sense of that idea, but when it clicked it was beautiful. (By analogy I can sort of understand what it might be like not to understand pointers themselves.)
Then I hit on the idea of embedding a function pointer in a data structure, so that I could change the function pointed to depending on some environmental parameters. Usually, of course, the first parameter of that function was the data structure itself...
Usually, of course, the first parameter of that function was the data structure itself...
Cute. Sad, but that’s already more powerful than straight OO. Python and Ruby support adding/rebinding methods at runtime (one reason duck typing is more popular these days). You might want to look at functional programming if you haven’t yet, since you’ve no doubt progressed since your epiphany. I’ve heard nice things about statically typed languages such as Haskell and O’Caml, and my personal favorite is Scheme.
Oddly enough, I think Morendil would get a real kick out of JavaScript. So much in JS involves passing functions around, usually carrying around some variables from their enclosing scope. That’s how the OO works; it’s how you make callbacks seem natural; it even lets you define new control-flow structures like jQuery’s each() function, which lets you pass in a function which iterates over every element in a collection.
The clearest, most concise book on this is Doug Crockford’s Javascript: The Good Parts. Highly recommended.
The technical term for this is a closure. A closure is a first-class* function with some associated state. For example, in Scheme, here is a function which returns counters, each with its own internal ticker:
While we’re sharing fun information, I’d like to point out a little-used feature of Markdown syntax: if you put four spaces before a line, it’s treated as code. Behold:
I suspect it’s like how my brain reacts to negative numbers, or decimals; I have no idea how anyone could fail to understand them.
But some people do.
And, due to my tendency to analyse mistakes I make (especially factual errors) I remember the times when I got each one of those wrong. I even remember the logic I used.
But they’ve become so ingrained in my brain now that failure to understand them is nigh inconceivable.
There is a difference in aptitude, but part of the problem is that pointers are almost never explained correctly. Many texts try to explain in abstract terms, which doesn’t work; a few try to explain graphically, which doesn’t work terribly well. I’ve met professional C programmers who therefore never understood pointers, but who did understand them after I gave them the right explanation.
The right explanation is in terms of numbers: the key is that char *x actually means the same thing as int x (on a 32-bit machine, and modulo some superficial convenience). A pointer is just an integer that gets used to store a memory address. Then you write out a series of numbered boxes starting at e.g. 1000, to represent memory locations. People get pointers when you put it like that.
Yeah, pretty much anyone who isn’t appallingly stupid can become a reasonably good programmer in about a year. Be warned though, the kinds of people who make good programmers are also the kind of people who spontaneously find themselves recompiling their Linux kernel in order to get their patched wifi drivers to work...
What’s the deal with programming, as a careeer? It seems like the lower levels at least should be readily accessible even to people of thoroughly average intelligence but I’ve read a lot that leads me to believe the average professional programmer is borderline incompetent.
E.g., Fizzbuzz. Apparently most people who come into an interview won’t be able to do it. Now, I can’t code or anything but computers do only and exactly what you tell them (assuming you’re not dealing with a thicket of code so dense it has emergent properties) but here’s what I’d tell the computer to do
# Proceed from 0 to x, in increments of 1, (where x =whatever) If divisible by 3, remainder 0, associate fizz with number If divisible by 5, remainder 0, associate buzz with number, Make ordered list from o to x, of numbers associated with fizz OR buzz For numbers associated with fizz NOT buzz, append fizz For numbers associated with buzz NOT fizz, append fizz For numbers associated with fizz AND buzz, append fizzbuzz #
I ask out of interest in acquiring money, on elance, rentacoder, odesk etc. I’m starting from a position of total ignorance but y’know it doesn’t seem like learning C, and understanding Conrete Mathematics and TAOCP in a useful or even deep way would be the work of more than a year, while it would place one well above average in some domains of this activiteity.
Or have I missed something really obvious and important?
I have no numbers for this, but the idea is that after interviewing for a job, competent people get hired, while incompetent people do not. These incompetents then have to interview for other jobs, so they will be seen more often, and complained about a lot. So perhaps the perceived prevalence of incompetent programmers is a result of availability bias (?).
This theory does not explain why this problem occurs in programming but not in other fields. I don’t even know whether that is true. Maybe the situation is the same elsewhere, and I am biased here because I am a programmer.
Joel Spolsky gave a similar explanation.
Makes sense.
I’m a programmer, and haven’t noticed that many horribly incompetent programmers (which could count as evidence that I’m one myself!).
Do you consider fizzbuzz trivial? Could you write an interpreter for a simple Forth-like language, if you wanted to? If the answers to these questions are “yes”, then that’s strong evidence that you’re not a horribly incompetent programmer.
Is this reassuring?
Yes
Probably; I made a simple lambda-calculus interpret once and started working on a Lisp parser (I don’t think I got much further than the ‘parsing’ bit). Forth looks relatively simple, though correctly parsing quotes and comments is always a bit tricky.
Of course, I don’t think I’m a horribly incompetent programmer—like most humans, I have a high opinion of myself :D
I’m probably not horribly incompetent (evidence: this and this), but there exist people who are miles above me, e.g. John Carmack (read his .plan files for a quick fix of inferiority) or Inigo Quilez who wrote the 4kb Elevated demo. Thinking you’re “good enough” is dangerous.
From what I can tell the average person is borderline incompetent when it comes to the ‘actually getting work done’ part of a job. It is perhaps slightly more obvious with a role such as programming where output is somewhat closer to the level of objective physical reality.
I don’t know anything about FizzBuzz, but your program generates no buzzes and lots of fizzes (appending fizz to numbers associated only with fizz or buzz.) This is not a particularly compelling demonstration of your point that it should be easy.
(I’m not a programmer, at least not professionally. The last serious program I wrote was 23 years ago in Fortran.)
The bug would have been obvious if the pseudocode had been indented. I’m convinced that a large fraction of beginner programming bugs arise from poor code formatting. (I got this idea from watching beginners make mistakes, over and over again, which would have been obvious if they had heeded my dire warnings and just frickin’ indented their code.)
Actually, maybe this is a sign of a bigger conceptual problem: a lot of people see programs as sequences of instructions, rather than a tree structure. Indentation seems natural if you hold the latter view, and pointless if you can only perceive programs as serial streams of tokens.
This seems to predict that python solves this problem. Do you have any experience watching beginners with python? (Your second paragraph suggests that indentation is just the symptom and python won’t help.)
Your general point is right. Ever since I started programming, it always felt like money for free. As long as you have the right mindset and never let yourself get intimidated.
Your solution to FizzBuzz is too complex and uses data structures (“associate whatever with whatever”, then ordered lists) that it could’ve done without. Instead, do this:
This is runnable Python code. (NB: to write code in comments, indent each line by four spaces.) Python a simple language, maybe the best for beginners among all mainstream languages. Download the interpreter and use it to solve some Project Euler problems for finger exercises, because most actual programming tasks are a wee bit harder than FizzBuzz.
How did you first find work? How do you usually find work, and what would you recommend competent programmers do to get started in a career?
The least-effort strategy, and the one I used for my current job, is to talk to recruiting firms. They have access to job openings that are not announced publically, and they have strong financial incentives to get you hired. The usual structure, at least for those I’ve worked with, is that the prospective employee pays nothing, while the employer pays some fraction of a year’s salary for a successful hire, where success is defined by lasting longer than some duration.
(I’ve been involved in hiring at the company I work for, and most of the candidates fail the first interview on a question of comparable difficulty to fizzbuzz. I think the problem is that there are some unteachable intrinsic talents necessary for programming, and many people irrevocably commit to getting comp sci degrees before discovering that they can’t be taught to program.)
I think there are failure modes from the curiosity-stopping anti-epistemology cluster, that allow you to fail to learn indefinitely, because you don’t recognize what you need to learn, and so never manage to actually learn that. With right approach anyone who is not seriously stupid could be taught (but it might take lots of time and effort, so often not worth it).
Do recruiting firms require that you have formal programming credentials?
Formal credentials certainly help, but I wouldn’t say they’re required, as long as you have something (such as a completed project) to prove you have skills.
My first paying job was webmaster for a Quake clan that was administered by some friends of my parents. I was something like 14 or 15 then, and never stopped working since (I’m 27 now). Many people around me are aware of my skills, so work usually comes to me; I had about 20 employers (taking different positions on the spectrum from client to full-time employer) but I don’t think I ever got hired the “traditional” way with a resume and an interview.
Right now my primary job is a fun project we started some years ago with my classmates from school, and it’s grown quite a bit since then. My immediate boss is a former classmate of mine, and our CEO is the father of another of my classmates; moreover, I’ve known him since I was 12 or so when he went on hiking trips with us. In the past I’ve worked for friends of my parents, friends of my friends, friends of my own, people who rented a room at one of my schools, people who found me on the Internet, people I knew from previous jobs… Basically, if you need something done yesterday and your previous contractor was stupid, contact me and I’ll try to help :-)
ETA: I just noticed that I didn’t answer your last question. Not sure what to recommend to competent programmers because I’ve never needed to ask others for recomendations of this sort (hah, that pattern again). Maybe it’s about networking: back when I had a steady girlfriend, I spent about three years supporting our “family” alone by random freelance work, so naturally I learned to present a good face to people. Maybe it’s about location: Moscow has a chronic shortage of programmers, and I never stop searching for talented junior people myself.
I was very surprised by this until I read the word “Moscow.”
Is it different in the US? I imagined it was even easier to find a job in the Valley than in Moscow.
I was unsurprised by this until I read the word “Moscow”. (Russian programmers & mathematicians seem to always be heading west for jobs.)
I took an internship after college. Professors can always use (exploit) programming labor. That gives you semi-real experience (might be very real if the professor is good) and allows you to build credibility and confidence.
Python tip: Using “range” creates a big list in memory, which is a waste of space. If you use xrange, you get an iterable object that only uses a single counter variable.
Hah. I first wrote the example using xrange, then changed it to range to make it less confusing to someone who doesn’t know Python :-)
Not in python 3 ! range in Python 3 works like xrange in the previous versions (and xrange doesn’t exist any more).
(but the print functions would use a different syntax)
In fact, range in Python 2.5ish and above works the same, which is why they removed xrange in 3.0.
There was a discussion of transitioning to Python 3 on HN a week or two ago; apparently there are going to be a lot of programmers, and even more shops, holding off on transitioning, because it will break too many existing programs. (I haven’t tried Python since version 1, so I don’t know anything about it myself.)
A big problem with transitioning to Python 3 is that there are quite a few third-party libraries that don’t support it (including two I use regularly—SciPy and Pygame). Some bits of the syntax are different, but that shouldn’t be a huge issue except for big codebases, since there’s a script to convert Python 2.6 to 3.0.
I’ve used Python 3 but had to switch back to 2.6 so I could keep using those libraries :P
Cool
--”Epigrams in Programming”, by Alan J. Perlis; ACM’s SIGPLAN publication, September, 1982
Programming as a field exhibits a weird bimodal distribution of talent. Some people are just in it for the paycheck, but others think of it as a true intellectual and creative challenge. Not only does the latter group spend extra hours perfecting their art, they also tend to be higher-IQ. Most of them could make better money in the law/medicine/MBA path. So obviously the “programming is an art” group is going to have a low opinion of the “programming is a paycheck” group.
Do we have any refs for this? I know there’s “The Camel Has Two Humps” (Alan Kay on it, the PDF), but anything else?
And going by his other papers, though, it looks like the effect isn’t nearly so strong as was originally claimed. (Though that’s wrt whether his “consistency test” works, didn’t check about whether bimodalness still holds.)
No, just personal experience and observation backed up by stories and blog posts from other people. See also Joel Spolsky on Hitting the High Notes. Spolsky’s line is that some people are just never going to be that good at programming. I’d rephrase it as: some people are just never going to be motivated to spend long hours programming for the sheer fun and challenge of it, and so they’re never going to be that good at programming.
This is a good null hypothesis for skill variation in many cases, but not one supported by the research in the paper gwern linked.
Fixed that for you. :) (I’m a current law student.)
In addition to this, if you’re a good bricklayer, you might do, at most, twice the work of a bad bricklayer. It’s quite common for an excellent programmer (a hacker) to do more work than ten average programmers—and that’s conservative. The difference is more apparent. My guess might be that you hear this complaint from good programmers, Barry?
Although, I can guarantee that everyone I’ve met can do at least FizzBuzz. We have average programmers, not downright bad ones.
I’ll second the suggestion that you try your hand at some actual programming tasks, relatively easy ones to start with, and see where that gets you.
The deal with programming is that some people grok it readily and some don’t. There seems to be some measure of talent involved that conscientious hard word can’t replace.
Still, it seems to me (I have had a post about this in the works for ages) that anyone keen on improving their thinking can benefit from giving programming a try. It’s like math in that respect.
i think you overestimate human curiosity for one. Not everyone implements prime searching or Conways game of life for fun. For two. Even those that implement their own fun projects are not necessarily great programmers. It seems there are those that get pointers, and the others. For tree, where does a company advertise? There is a lot of mass mailing going on by not competent folks. I recently read Joel Spolskys book on how to hire great talent, and he makes the point that the really great programmers just never appear on the market anyway.
http://abstrusegoose.com/strips/ars_longa_vita_brevis.PNG
Are there really people who don’t get pointers? I’m having a hard time even imagining this. Pointers really aren’t that hard, if you take a few hours to learn what they do and how they’re used.
Alternately, is my reaction a sign that there really is a profoundly bimodal distribution of programming aptitudes?
There really are people who would not take that few hours.
I don’t know if this counts, but when I was about 9 or 10 and learning C (my first exposure to programming) I understood input/output, loops, functions, variables, but I really didn’t get pointers. I distinctly remember my dad trying to explain the relationship between the * and & operators with box-and-pointer diagrams and I just absolutely could not figure out what was going on. I don’t know whether it was the notation or the concept that eluded me. I sort of gave up on it and stopped programming C for a while, but a few years later (after some Common Lisp in between), when I revisited C and C++ in high school programming classes, it seemed completely trivial.
So there might be some kind of level of abstract-thinking-ability which is a prerequisite to understanding such things. No comment on whether everyone can develop it eventually or not.
There are really people who don’t get pointers.
One of the epiphanies of my programming career was when I grokked function pointers. For a while prior to that I really struggled to even make sense of that idea, but when it clicked it was beautiful. (By analogy I can sort of understand what it might be like not to understand pointers themselves.)
Then I hit on the idea of embedding a function pointer in a data structure, so that I could change the function pointed to depending on some environmental parameters. Usually, of course, the first parameter of that function was the data structure itself...
Cute. Sad, but that’s already more powerful than straight OO. Python and Ruby support adding/rebinding methods at runtime (one reason duck typing is more popular these days). You might want to look at functional programming if you haven’t yet, since you’ve no doubt progressed since your epiphany. I’ve heard nice things about statically typed languages such as Haskell and O’Caml, and my personal favorite is Scheme.
Oddly enough, I think Morendil would get a real kick out of JavaScript. So much in JS involves passing functions around, usually carrying around some variables from their enclosing scope. That’s how the OO works; it’s how you make callbacks seem natural; it even lets you define new control-flow structures like jQuery’s each() function, which lets you pass in a function which iterates over every element in a collection.
The clearest, most concise book on this is Doug Crockford’s Javascript: The Good Parts. Highly recommended.
The technical term for this is a closure. A closure is a first-class* function with some associated state. For example, in Scheme, here is a function which returns counters, each with its own internal ticker:
To create a counter, you’d do something like
Then, to get values from the counter, you could call something like
Here is the same example in Python, since that’s what most people seem to be posting in:
*That is, a function which you can pass around like a value.
While we’re sharing fun information, I’d like to point out a little-used feature of Markdown syntax: if you put four spaces before a line, it’s treated as code. Behold:
Also, the emacs rectangle editing functions are good for this. C-x r t is a godsend.
I suspect it’s like how my brain reacts to negative numbers, or decimals; I have no idea how anyone could fail to understand them. But some people do.
And, due to my tendency to analyse mistakes I make (especially factual errors) I remember the times when I got each one of those wrong. I even remember the logic I used.
But they’ve become so ingrained in my brain now that failure to understand them is nigh inconceivable.
There is a difference in aptitude, but part of the problem is that pointers are almost never explained correctly. Many texts try to explain in abstract terms, which doesn’t work; a few try to explain graphically, which doesn’t work terribly well. I’ve met professional C programmers who therefore never understood pointers, but who did understand them after I gave them the right explanation.
The right explanation is in terms of numbers: the key is that
char *x
actually means the same thing asint x
(on a 32-bit machine, and modulo some superficial convenience). A pointer is just an integer that gets used to store a memory address. Then you write out a series of numbered boxes starting at e.g. 1000, to represent memory locations. People get pointers when you put it like that.Yeah, pretty much anyone who isn’t appallingly stupid can become a reasonably good programmer in about a year. Be warned though, the kinds of people who make good programmers are also the kind of people who spontaneously find themselves recompiling their Linux kernel in order to get their patched wifi drivers to work...
xkcd reference!
Dammit! That’ll shouted at my funeral!