Why Can't Programmers.. Program?

int main() {
printf(“Get back to work!\n”);
return 0;
}

rien: I guess something was lost in translation then :slight_smile:

Sure, creating your own stack has its own sets of problems, and it’s not suitable to replace all usages of recursion. It’s often a good idea, though. I’d say that using a stack instead of recursion is not so much “handcrafted optimization” as it is “avoiding expensive patterns where they are not needed” :slight_smile:

Fortunately, coding is merely my hobby. The one time I applied for a job, I did have to do some basic code in front of the owner of the company. He asked me to do something basic that I hadn’t done in C in many years, so I couldn’t remember the commands, so I had to resort to the last language in which I had actually done it: REALbasic. That was a bit embarrassing, to say the least. I also had to recode the script in front of him, because I wrote it under a minute and had a few logical errors in it, which I corrected. Then I optimized it in front of him, which I couldn’t walk away without doing. I didn’t get the job (thankfully), but I was one of the top two candidates. The only thing that won out the other guy in the end was that he had more experience with .NET than I did. Or so they told me. Could very well have been that I was a colossal embarrassment, but they were too kind to tell me. Who knows? But I do know that I’m glad I didn’t get the job. I just haven’t got the chops to sit in a room and code all day, not even for pay.

So, exactly where are you FINDING these job candidates? sounds like a piss poor advertising and recruiting practice if 99.5% are not valid candidates.

Geesh, I advertise on Craigslist in Austin or Phoenix and over 1/2 of the people who apply are able to pass a test like this. And this is with modest pay for an easy and flexible work at home job (ssh, svn, etc). Plus I get maybe 10 to 15 replies running the advertising 1 time, and those replies come in within the first 5 days. So I get 5 to 8 real job candidates and I can focus on long-term aspects of which person is best.

In other words, just like writing a good resume is important, writing a good job description and knowing where to find people is just as important.

“It is interesting that at least two solutions given in the comments are wrong. People don’t even know that they can’t program.”

People might know how to program, they just don’t test what they program!

If I’d been given the “swap 2 values with no temp variable” problem before yesterday, I probably would have said “you can’t do it”.

Now that I’ve seen the trick (which isn’t a general solution. It only works for integers, and only those containing values that won’t overflow when added), I probably would have said “you shouldn’t”.

I’ve been developing software professionally for 18 years now, for fun about 9 years before that, and have at least 6 assorted Free or Public Domain projects under my belt. Does my “incorrect” answer to that question make me a bad programmer in your eyes? Given that your “correct” answer is something I’d slap someone for trying in any code I have to maintain, I think I’d prefer to not get that job anyway.

As for the issue about recursion, in my experience most software developers (even fairly good ones) are scared of it. I wouldn’t consider that a deal-killer for hiring. I was scared of it too, until I took a Lisp course in college. Its probably a better test of Lisp exposure than anything else.

On the other hand, if you are scared of it, be honest enough to admit it. Don’t throw me some (possibly true) pablum about explicitly using a stack being just as good, and faster in some cases.

If an algorithm is naturally recursive, recursion is probably the best expression of that. As for the speed issue, I agree that a good programmer doesn’t do things that are going to be massively slow. However, they also don’t pervert their source code for optimization purposes. That’s the compiler’s job. If the compiler fails, and you have a known speed problem, and you have tracked a big bottleneck down to that chunk of code, then you may source-level optimize. Otherwise, just make it as understandable as you can, please.

However, I would consider “I have trouble with recursion, and so does nearly every other developer who will have to maintain this code”, a compelling argument.

I interviewed at a place with a fairly stringent testing regime last year. There were many “write on the board” SQL questions and some Java pair programming with one of the team leaders.

Unfortunately, although I nailed the whiteboard part, I did poorly on the pair programming portion. I didn’t handle the context shift between VB (which I was using on the current gig) and Java well enough, and kept foolishly expecting Eclipse to get the case on my variables correct for me, leaving off semicolons, stuff like that. It was embarrassing, considering that six to eight months previously I had been doing a lot of Java.

I suppose I would have done better had I freshened my Java knowledge a little before the interview, but I had an informal offer on the table for a lot more money and was going through with this interview for, shall we say, domestic political reasons (i.e. my wife didn’t think the existing offer was official enough and would have killed me if I’d cancelled this interview. Because of the pay discrepancy and the awkwardness that would have ensued in trying to negotiate an informal offer against an inferior, but formal one, I actually dreaded the prospect of an offer.)

Some of these tests are fine, but I’m sorry… OCTAL? Almost -nobody- uses octal anymore. You’re rewarding programmers for learning stuff they’ll never have to use. If they ever need it for some crazy reason, they can always use google and spend two minutes learning how to interpret it.

These tests can’t determine whether a programmer is economical, which is the secret to what actually makes programmers good. I’ve seen many programmers who are much smarter than I am destroy projects, because they spent too much time hacking on the 20/80 stuff instead of picking their programming battles wisely. Good programmers get the job done, which is why the best test for programmers should be their ability to create stuff (like projects, OSS and whatnot).

I had recently gone through a few interviews - some good and some bad.

I thoroughly enjoyed one in particular for Blackbaud (Charleston, SC) where the team lead asked me through some real basic questions (something like storing people’s favorite activities) that covered relational database, OO, and web-based design concepts. Nothing particular hard - but worthy of actual thinking. Then she went and expanded the basics a few times and had me explain what I would do - which covered nicely aspects of software maintenance that I reasonably expect most get to deal with. I did get the offer, but couldn’t take it (in the end) because I had hoped I would sell a house in another state … it was very complicated :slight_smile:

Then I think back to another interview where there was a programming test. And I just completely bombed it … I mean TOTAL brain fart. How embarrassing! I’ve gone through others and did completely well, but like how some interviews go (or at least for me), some go really well, and some just don’t. Including programming tests. Well, the job was probably too far west (San Francisco) for my family anyway…

We’ve had a fair number of interviewees who couldn’t write a very simple program. But I bet a fair number got home and realized that they could do the task easily under normal conditions, but had freaked out with interview anxiety.

While I understand the problem of programmers who can not program I really have no empathy for those of you doing the hiring.

I went to a little community college and got an A.A. while there I learned to program in C/C++, pascal, cobol, QB, and AS400. Since college I have taught myself 3 new languages and if I were to interview for a programming job would have brushed up on the syntax enough to have easily passed any of the “tests” listed on this page, yet none of you would have let me get that far.

Since I have only an A.A. no one seems to want to even bother interviewing me much less test me to see if I “have the skills”. Yet they fall all over each other trying to “catch” one of the kids that used to come to me for help on their assignments week after week. Because those same kids went on to get a B.A. or a B.S. while I decided I was deep enough in debt and went out into the world to do basic comp. repairs.

It has been my experience that those who programmers who fail your little tests are most likely failing not because they can’t program but because they have a problem applying their knowledge (it is a fine line but a valid one). Much like most high school grads these days seem to know the basics of proper grammar but could not compose a decent letter to save their lives.

That’s my opinion anyway, take it for what it is worth.

quote: it’s the standard a=a+b, b=a-b, a=a-b problem

Hopefully a and b aren’t near MAX_INTEGER. In fact this is a worse solution than doing something obviously wrong as it will only come up in the weird cases making it even harder to debug. This is a terrible way of doing it, you fail!

Toepopper wrote

Very very common, alas. I once interviewed a candidate for a VBA job (yes, you can stop booing for the peanut gallery) whom I asked to swap two variable contents without using a temp variable. It’s the standard a=a+b, b=a-b, a=a-b problem. His answer? Well, I can’t do it in VBA, but if you let me use Excel I can put the values in two cells and swap the cells’ contents using a third cell.
We hired the guy who said, well, “if they’re integers, then I’d do it by a=a|b, b=a^b, a=a^b. But I don’t know how to do it if they’re strings.”

Toepopper on February 27, 2007 01:49 AM
I think Toepopper hired the wrong fellow, because his "swap program"
is logically flawed. After looking up the meaning of the | ^ operators (i.e. | = bitwise OR and ^ = bitwise XOR), I attempted a formal proof. I could not get it to work out. So I tried a simple case. Suppose we have 1-bit words and

a = 1
b = 1

After a = a|b:

a = 1

After b = a^b

b = 0

After a = a^b

a = 1

And you can see, a swap has not occurred.

Hi!

I am writing from India.India is becoming famous with IT and lot of software development stuff happening here.
But,to my surprise,people in large organizations hires the candidates from the campuses with bulk entity and not even asking any fizz buzz questions.
I have given number of test with smaller organizations which requires to pass technical test or code right away at the time of test.
and I opted for such a company.Now,reading this article I think my decision is really good.

Another point to be made is should years of experience really teaches us these things in programming???
and if no then why do all software companies ad mentions the years of experience instead of asking for some other point…

please comment…

It seems to me that most of the comments here are focused on the actual code solution for the FizzBuzz question. I would like to step back and talk about the actual lack of programming knowledge possessed by those that apply for these programming jobs. I would say that the reason that so many numbskulls apply for these jobs is because somewhere in the job requirements it says that applicants must have at least a Bachelors in computer science. Most of the best programmers I have ever known, including myself, do not have a degree of any kind, and in my case, never went to college. Yet, many companies will simply push your resume aside if they see that you do not have the required degree, no matter what you skill level may be. A degree is just a piece of paper that says that you have sat in a class for x number of hours learning about something that you may or may not remember when you leave. If companies want to find real programmers with real programming experience they need to broaden their search or have a little slack when it comes to their job requirements. I guarantee that they will interview many more applicants with a deeper knowledge of the force.

Dave: “Note that the FizzBuzz Test requires at least some simple number theory thinking.”

It’s extremely simple number theory thinking, that people in all fields should know. The word “multiple” is basic vocabulary, and any grown-up with an IQ over 80 ought to be able to understand what it means.

Mike H, the answer to the vowel/even problem is “A” and “3”. It would be all four only if my theory were if-and-only-if, but that’s not what I specified.

Jeff, thanks for posting this one, I’ve found replies really engrossing. Readers identified three problems worth solving:

  1. Write FizzBuzz code
  2. Distinguish good programmers from lousy ones in an interview
  3. Fix the educational system that produces these morans

It’s been a pleasure to read proposed answers for all.

Big Playa - re-read the requirements… you failed.

I ask the candidate to write a simple but full-fledge class from scratch. (Many can’t)

I also provide a series of assertions and ask the candidate to write code that passes those tests.

However, writing code on a whiteboard is hard even for me, and I’ve written a lot of code in the last 20 years. These days I’d provide the candidate with a laptop (if they don’t have one with them) and watch them code and test their code.

Anthony - thats what i look for when hiring - experience and aptitude over qualifications. and i really dont care how many “certified whatever” post-college qualifications you have either.

a portfolio is essential. past experience too and a willingness to learn. some of the best coders i’ve met have never gone to college either. the ones that did go to college and were good coders after , were coders in their teens pre-college.

i think the problem lies with folks that never programmed before college and just did the course to get this mythical enormous “I.T. salary”, without necessarily having any aptitude or love for the subject.

About 8 years ago, after a UK conference on teaching the new language of Java, one of the attendees said that we certainly needed to change something – the final year students on the Comp Sci course at his prestigious university were not confident in writing any program, even one just 10 lines long. Other people there agreed that it was not much better, if any, where they worked. Surprised, I went back to my much less prestigious place where all our students took joint degrees, Computing and Maths, Computing and History etc and and checked with my final year OO class. I had real difficulty explaining the question, even though I upped the size to 20 lines – they just could not imagine anyone on our (half a) degree course, even those who had dropped programming at the earliest opportunity, being unable to write proper programs. What was the difference? Maybe a culture of 100% attendance, and the fact that, not being much of a research establishment, we did not farm out the practical labs to uninterested grad students.

On recursion, I stand by my advice to students. You should know what it is, how it works, and how to program it. But you should never use it in production code, because whoever maintains it may not grasp what is going on.

On swapping the values of two variable without involving a third, I am torn. I agree it is irrelevant to much of modern programming, and is probably not taught in most places. But it does provide a good test to see if someone has read around the subject a bit – and if they haven’t heard of it you could use it like Ben’s test to see if their eyes light up when you say it is possible.