Why Can't Programmers.. Program?

Having in the past been tortured by clueless candidates, I can believe the claim. Phone screening with simple as simple can be questions is amazingly (and disturbingly) effective. Where do these people come from?

While you may not have used recursion to solve a problem, if you know what it is and how to code something simple then that is enough, me thinks. There is a stunningly large population of people who describe themselves as ‘professional software developers’ who have not the faintest idea about recursion, bit masking, hexadecimal maths…or how to code a simple for loop that does something like FizzBuzz.

Over the years I’ve built up a loose theory on these “pretenders”–they are the people that know tinker and tweak and copy and paste and fidle and, when left alone for a while, some how manage to produce a bit of code that passes as productive.

Non technical people just cannot distinguish between them and us, and many times we technical people don’t ask the right questions. What are we asking if not the FizzBuzz question? Surely it varies, but inevitably we are asking questions whose answers have nothing to do with problem solving and the mechanics of coding.

One of my FizzBuzz questions is, when a candidate has “SQL” on their CV, is to draw a simple table (Person: last, first, sex, DoB), populate it with four or five rows, and ask them to write some SQL that returns all the males, or everyone born after a given date. Simple enough problem, very real world, and relevant to someone working in ‘web development’. Two out of three cannot do it! Ask for an insert or update? Four out of five, if not fewer!

Our profession is full of frauds and incompetent fools. And I feel safe saying that here because, if you are reading the comments on Jeff’s blog, then you actually take an interest in both the nitty gritty of computers and programming…and the higher level fluff, like hiring. :slight_smile:

@Ade: My point is that the many ‘programmers’ do not know anything about bit masking, and other core concepts. None. Zip-o. Nada. I did not mean to imply that all coders should have an encyclopaedic knowledge of all CS! :slight_smile: Please don’t obsess on my mention of bit masking alone.

Good for you on the SQL, but then again it is domain specific and I qualified it as such above. (‘web development’)

@rien: hehe, i agree on the urge to post code…it is funny…especially when it is incorrect

I’m very impressed with all of these FizzBuzz developers posting here in the comments!

Has anyone thought of creating a web page where we can see cross-language solutions to the FizzBuzz problem? Once there are enough solutions (and optimizations) posted, perhaps it can be spun off into the Great FizzBuzz Programming Shootout. And don’t forget a job board and forums to connect with prospective employers.

This is an exciting time to be in software development.

When testing for language competence in my graduate class, I have the students write a program at home, but then ask them to modify it in class. While they could cheat and use a “tutor” to write the code at home - if they can’t change it and run the resulting program in front of me then there is no way they can code. This eliminates a lot of the test anxiety stress which affects about 1/4 of the students while accomplishing most of its purpose.

Back in the dark ages when I was a contract programmer for about 6 months the contracting company had a neat way to do a similar test. They let you get familiar with the system and environment for about a week and then gave you a realistic problem. If you did it you were still there next week. (I don’t know what happens if you didn’t).

It is sort of funny that a lot of people who posted solutions here did not print the actual number on the condition of (i % 3) == (i % 5) == 0. Just goes to show you, being a good developer isn’t just about writing code, it’s also about reading comprehension! READ THE SPECS!

I also wasn’t familiar with the “xor trick” of swapping variables that Toepopper mentioned in his first post and that others have mentioned here. However, I’d like to think it’s an indication that I’m a good programmer that I immediately noticed it was suspicious, and a quick google search confirmed that it was in fact wrong (all three operations are xor, whereas the one posted used an “or” on the first one). If that is actually what the interview candidate stated, it would have been a bad sign to me, a sign that either they’d seen the trick before but didn’t understand it, or understood the form but not the function (cargo cult).

As others have said, though, the only time I could ever see this being used is in an embedded system. Outside that domain, it’s essentially just another brain teaser, one of those things that when you know the answer you go “oh, that’s so easy!” but could spend days thinking about if you haven’t seen it before. Those of you who keep saying that every competent programmer should know this, please ask yourselves what it says about you that you can’t tell the difference between a simple problem with a mundane solution and a “gotcha” question.

A little bit more searching indicates that the xor swap may perform worse than a temporary variable anyway, due to processor pipelining. I’m not sure whether or not that’s true, but even if it isn’t, compiler optimization would make the two methods at least equal in performance. I also found a post (http://blogs.msdn.com/rick_schaut/archive/2004/03/06/85357.aspx) which asserts that an optimizing compiler might just change all subsequent variable references after a temp-variable swap, which would make the xor swap slower. Stupid code trick indeed.

Bottom line - if I ever saw this “clever” trick used in modern non-embedded code, I would consider it and everything else around it to be suspect. I can’t imagine anything worse than a developer using one of these lame tricks and making a typo or getting it wrong, then having to spend days or weeks searching for the source of the problem. That trick is an antique, completely irrelevant to today’s programming problems (except maybe if you’re writing an optimizing compiler).

I give coding tests to every developer I interview, along the lines of implementing a single method. The method is passed a string of characters, e.g. AABBBBBCCCCDDDEEEEEEEE and it has to return a string holding the longest reocurring character sequence (i.e. “EEEEEEEE” in this case). This is a 10 min exercise, which at the time I started it I tested on colleagues to make sure it was reasonable. You have to allow a lot of leeway for nerves in interviews, and some for unfamiliarity with tools, but it has been absolutely astonishing how few candidates have been able to complete it in 45 minutes. I have even had one guy who seemed absolutely job worthy until this test - and after an hour had only produced an (incorrect) flow diagram on a white board, not even touching the computer.

The fizzbuzz test requires basic programming knowledge of loops, which anyone with a CS degree should be able to do. The Modulus operator would probably be missed by very new programmers, but you could still write the loop and test the condition with more code without using the modulus operator, although with a code review, this code would be optimized to use less lines with the modulus.

I am not sure if a programming test is the best test to give a developer. If one does give a test, it should be only used to gauge overall level of expertise, not as the sole basis of hiring.

Today’s programming world is a vast expanse of knowledge, just the .Net Framework contains 100s to 1000s of classes.

At a previous employer, I made a quiz for C# becuase we needed people who had programmed in C#. It had some questions on the language (framework and Object Oriented questions) as well as a few coding questions.

For example, spot the error

if (a = b)
{
//Do Something
}

Nothing too hard (I don’t think), but it was comprehensive enough to week out the people with very little experience which is what it was designed to do.

The final question was a coding test that was very simple:

Write a method to add two numbers together.

When I looked at the test results, usually I would get back something like this:

public int add(int a, int b)
{
return a+b;
}

Now, this works most of the time, but usually what I would do is to engage the candidate and ask them the following after they had provided the answer:

What happens if you add int.MaxValue + 1?

Now the “test” is more of an interaction between me and the candidate and it becomes more interactive. After some back and forth, the final question was:

How would you write a program to add any 2 numbers regardless of size? At this point, it is no longer a programming exercise but becomes more of problem solving exercise.

I wanted to see how the candidates would act and problem solve, and how they would respond, if they would ask questions about the exercise, etc. Something as simple as adding 2 numbers together can tell you alot about a person’s programming and problem solving skill.

The side topic of recursion…

Recursion is usually illustrated by the Tower of Hanoi problem. Usually you have to move 8 disks from one pole to another. The exercise I did was for C++ a few years back and it worked great to move 8 or so disks. Then I tried 20 and 100. You know what happened? Stack overflow!

Now, just by experimenting with more disks I broke the program. Additionally, I learned that any any recursive code can be solved iteratively. So, this changed my outlook on recursion in general.

Recursion is very clever which produces a solution with very few lines of code, but try debugging it when there is a problem. Nightmare.

Clever works in academic environments, but I’ll take maintainable and supportable over clever any day. Plus, recursion is destined to fail at a certain amount of iterations because there is only so much space on the stack.

Coming to Theater in 2008 - Toy Story 4 - Buzz Lightyear and the attack of the FizzBuzzers.

(Wonder who’s going to read this far…?)

Need a requirements clarification (seems like Mr Dieterich was the only one that picked this up!?)

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Should the last requirement be:

'.... *instead* print "FizzBuzz".'

or

'.... *also* print "FizzBuzz".'

?

Lame. That golf.shinh.org thing accepts the whitespace language, but not MSIL? Lame, lame, lame!

Jeff Atwood wrote:
My friend, the internet is your huckleberry. The FizzBuzz programming competition in any language of your choice.

Unbelievable though … no job board! And all that talent concentrated in one place too.

@Bob: “I can’t add in hex. And I really don’t care…Does that make me a bad programmer?”

It makes you prime fodder for either management or sales. Pick your poison.

@Ken “but I have no freaking idea what Hexadecimal maths”: OK, maybe it is just my terminology. Do you know what a hexadecimal is? Do you know what 0x0F + 0x01 is? If not, I give up…there is no hope. Maybe you and Bob could start a consulting company together?

With respect to FizzBuzz, if an interviewer ask the question of the phone, and the interviewee can understand it, recognize that some sort of loop is involved, recognize that some sort of logic is inside the loop to determine when to print ‘Fizz’ and ‘Buzz’, and is able to communicate this back over the phone in under ten minutes…well, the interviewee just passed the “has a pulse” test for a programming position.

Arguing about what language, syntax, IDE, programming best practices, etc. is way out of scope. The test is to see if some has, at a bare minimum, the raw magic required for programming. I know it is hard to believe, but many people just cannot comprehend things like ‘variable reassignment’. Seriously!

Ego has nothing to do with it. We are talking about basic, low level questions that weed out the utterly clueless from the potentially clued in. That’s it. And doing so saves countless hours of the interviewers time.

@Bob: You are making that kind of money, have a technical degree, call yourself a ‘software engineer’, have been doing this for years…and still cannot add 0x0F + 0x01? Sounds to me like you went into sales a looooong time ago.

Whatever, good for you.

But you should not mistake FizzBuzz, the great hexadecimal maths question of 2007, or any other similar basic aptitude/knowledge test as an intelligence metric. There are plenty of brilliant people out there who cannot program, and there are lots of full blow morons who can. (I have a link to a great paper on the subject of “programming aptitude” from a university, but can’t find it at the moment. If someone knows what I am talking about, please post! Basically, some people have “it” and some don’t…and the correlation with intelligence is weak. The paper was from a CS academic and was an analysis of his/her students’ performance on an aptitude test that focused on variable assignment concepts.)

People interviewing for a position frequently find themselves with 25, 50, or even more CVs to consider. As anyone who’s hired more than a few people can attest to, the ‘perfect’ CV does not make a perfect candidate. We have to look at folks with a wide range of experiences and we have to weed out the time wasters who’ve some how managed to deceive their way into software development. Bringing everyone in for a one, two or three hour interview? Have one, two or three people from the team in on the interview? It adds up. So we do phone interviews with trivial questions. It works. I am completely comfortable with my tactic of asking a few basic CS questions to see if they are a pretender or not.

“…how many “great” choices did you pass up [that cannot do FizzBuzz, add 0x0F + 0x01, etc?] Not many, that is for sure.

Wow, I don’t think I’ve seen THIS many responses in Jeff’s threads yet! 8^D

It has probably been mentioned amongst the code, but in my mind, there has always been a clear distinction between semantics and syntax in programming. Semantics is the WHY if our trade, Syntax is the HOW.

While this may seem moot, it is important to remember that the semantics will always be around while the syntax is ever evolving. It doesn’t matter if its .NET, Java, LISP, or Eiffel, a FOR loop solves one issue while a recursive call will solve another and the nuances of why they do it are important. Once you know this, hashing it out using the proper terminology becomes moot. I have picked up a few new languages along the way quite easily since I took the time in college to master the semantics of programming.

I think the web has gone a long way to put a lot of the semantics into the syntax. Since web oriented programming/apps (the field I work in) is pushing itself around data parsing/presenting/storing, a lot of the tricks that SQL gives us solves the issues for us. I could only imagine what things are like if you’re working for JPL or somewhere else where you’re designing the software to respond within a certain time frame to an event. The speed and resources used could mean life or death out in space and the use of an If/Else vs. a Switch statement means a heck of a lot more.

Today’s environment is being heavily dominated by web based/oriented apps and if you know where to snag some code, or drag in that nifty control in Visual Studio/Eclipse, most of your work is done for you. The third/fourth tier languages make everything practically verbal, so its not too hard to see folks coming into the ranks that know how to put two and two together. Give them a challenge out of the norm, or for which they don’t have resources readily available, and then you can see what kind of “programmer” they are.

Speaking of which, did anybody use a Case/Swtch statement yet in their FizzBuzz solution? I would have gone that route 8^D

@jadawin:

"
Well, since the friend was the test author, and one of the graders, I decided I’d do what it said, and use an obscure language that, pretty much, he was probably the only one to ever have seen; the embedded language in most TinyMUSH-derived games.

@create FizzBuzz
C-FIZZBUZZ FizzBuzz=$fizzbuzz:@dolist lnum(1,100)=@switch/first 0=mod(##,15),@emit FizzBuzz,mod(##,3),@emit Fizz,mod(##,5),@emit Buzz,@emit ##
"

Dude, (dudette?)

How old are you? That was probably the LAST language I expected to see on here. :slight_smile:

That’s pretty much the first language I learned (well, to be fair, I was playing with C at the same time), but I was like 15 or 16 at the time, so in all fairness, it was because it was a game that I got so into it.

I don’t recognize the MU* variant, but it’s very similar to what I played with.

Thanks for the flashback.

-Samson (my old MU* name)

I’m a completely self-taught programmer in high school (with a job as a programmer as well), and sadly this is something even I’ve observed in my limited scope. It really is scary when the company I work with is trying to hire guys who know less than the autodidact twelfth grader with only five-years experience. I could write this program with 5 languages in probably 10 minutes total. Heck, I could even add a Windows GUI with API for the C++ version with another ten minutes. It’s only too sad this is not true for those graduates with supposed ‘degrees.’ According to the ever-wise Carlos Mencia: “Let’s lower the standards!”

I have met a lot of programmers who just suck. However, I don’t think you can weed them out through simple tests or pedantic questions. In fact, I have seen where really good programmers are either weeded out or just get pissed off at the wasted time and go someplace else.

For example, I went to two job interview where they asked me questions like, “How could you tell if a binary file was a compiled Java file or not?” I said I didn’t know. They said, that you could tell because the first few bytes in a compiled Java file say some phrase like “Hot Java” or something.

First of all, who the hell cares? And secondly, as a programmer at your company, am I going to spend significant amounts of time looking for hidden messages in compiled Java files? If so, you can hire somebody else.

While I use recursion regularly in code to search a directory tree for specific file-types that I want to parse, I can understand that many good programmers have had no need for recursion. I can teach a good programmer to write recursive code, so why would I want to throw them out just because they haven’t ever had to write it before?

I do like the FizzBizz test though. It is simple and any coder should be able to figure out a way to make that happen.

Just to state the obvious but all fizzbuzz really tests for is whether someone is familiar with the modulo operator or not. Arguably any good programmer should know about it, but I think it’s not a very comprehensive check on the knowledge of any one particular individual.

Suppose for instance, that the only bit of code someone has ever written was something which required them to get very familiar with the modulo operator, but virtually nothing else. They could pass fizzbuzz, but not much else.

Jeff,

good to have your site and comments back.

Your post is interesting but you fell into a trap of blatant generalization.

199 out of 200 can’t write code? Really? Maybe you (or that other guy you are referring to) should reconsider your “source” or where you are finding candidates. Let’s see the job ad which attracted “199 out of 200” who can’t code.

Don’t forget that smart people avoid crappy jobs like a plague. If job sounds mind-numbing, that’s what it is going to attract.

For disclosure, I interview people daily, from entry level to senior level for our teams. Very, very rarely did I come across ignoramuses. It happens but it is not a significant occurrence. Do you know why? Jobs we are hiring for are advanced from the get-go. They require people who are not afraid to roll up their sleeves and learn quickly.

Please, post the job ad (or ads if there is more than one) that “generated” such negative statistics you are writing about in your post.

No unit tests? I’d fail you all!! Okay, maybe not, but it would be more impressive with a unit test.

I find it amazing how many of the solutions I have seen (both above and on other related posts) are still wrong. They print the number AND either “Fizz” or “Buzz”. The problem said to print “Fizz” or “Buzz” or “FizzBuzz” INSTEAD of the number. Several I have seen print “Fizz” or “Buzz” only - no numbers at all. It’s hard to translate simple English (or your native language) requirements into code - because natural language is misunderstood.

Easy requirements are still often misunderstood. And the little problems lead to large software-engineering related issues at test and integration. Which is why being able to correctly code simple problems is a good test of your programming (not just coding!) abilities.