Author Topic: Coding Horror: Why Can't Programmers Program?  (Read 12697 times)

0 Members and 1 Guest are viewing this topic.

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
Coding Horror: Why Can't Programmers Program?
EDIT: Added linkies and formatting.

Quote from: http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html
Feb 26, 2007
Why Can't Programmers.. Program?


I was incredulous when I read this observation from Reginald Braithwaite:

Quote
Like me, the author is having trouble with the fact that 199 out of 200 applicants for every programming job can't write code at all. I repeat: they can't write any code whatsoever.

The author he's referring to is Imran, who is evidently turning away lots of programmers who can't write a simple program:

Quote
After a fair bit of trial and error I've discovered that people who struggle to code don't just struggle on big problems, or even smallish problems (i.e. write a implementation of a linked list). They struggle with tiny problems.
So I set out to develop questions that can identify this kind of developer and came up with a class of questions I call "FizzBuzz Questions" named after a game children often play (or are made to play) in schools in the UK. An example of a Fizz-Buzz question is the following:

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".
Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes. Want to know something scary? The majority of comp sci graduates can't. I've also seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution.

Dan Kegel had a similar experience hiring entry-level programmers:

Quote
A surprisingly large fraction of applicants, even those with masters' degrees and PhDs in computer science, fail during interviews when asked to carry out basic programming tasks. For example, I've personally interviewed graduates who can't answer "Write a loop that counts from 1 to 10" or "What's the number after F in hexadecimal?" Less trivially, I've interviewed many candidates who can't use recursion to solve a real problem. These are basic skills; anyone who lacks them probably hasn't done much programming.
Speaking on behalf of software engineers who have to interview prospective new hires, I can safely say that we're tired of talking to candidates who can't program their way out of a paper bag. If you can successfully write a loop that goes from 1 to 10 in every language on your resume, can do simple arithmetic without a calculator, and can use recursion to solve a real problem, you're already ahead of the pack!

Between Reginald, Dan, and Imran, I'm starting to get a little worried. I'm more than willing to cut freshly minted software developers slack at the beginning of their career. Everybody has to start somewhere. But I am disturbed and appalled that any so-called programmer would apply for a job without being able to write the simplest of programs. That's a slap in the face to anyone who writes software for a living.

The vast divide between those who can program and those who cannot program is well known. I assumed anyone applying for a job as a programmer had already crossed this chasm. Apparently this is not a reasonable assumption to make. Apparently, FizzBuzz style screening is required to keep interviewers from wasting their time interviewing programmers who can't program.

Lest you think the FizzBuzz test is too easy-- and it is blindingly, intentionally easy-- a commenter to Imran's post notes its efficacy:

Quote
I'd hate interviewers to dismiss [the FizzBuzz] test as being too easy - in my experience it is genuinely astonishing how many candidates are incapable of the simplest programming tasks.

Maybe it's foolish to begin interviewing a programmer without looking at their code first. At Vertigo, we require a code sample before we even proceed to the phone interview stage. And our on-site interview includes a small coding exercise. Nothing difficult, mind you, just a basic exercise to go through the motions of building a small application in an hour or so. Although there have been one or two notable flame-outs, for the most part, this strategy has worked well for us. It lets us focus on actual software engineering in the interview without resorting to tedious puzzle questions.

It's a shame you have to do so much pre-screening to have the luxury of interviewing programmers who can actually program. It'd be funny if it wasn't so damn depressing. I'm no fan of certification, but it does make me wonder if Steve McConnell was on to something with all his talk of creating a true profession of software engineering.

Due to high volume, comments for this entry are now closed.

Posted by Jeff Atwood  
« Last Edit: February 27, 2010, 10:05:49 pm by Nuke »

 

Offline Turambar

  • Determined to inflict his entire social circle on us
  • 210
  • You can't spell Manslaughter without laughter
Re: Coding Horror: Why Can't Programmers Program?
what's recursion?
10:55:48   TurambarBlade: i've been selecting my generals based on how much i like their hats
10:55:55   HerraTohtori: me too!
10:56:01   HerraTohtori: :D

 

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
Re: Coding Horror: Why Can't Programmers Program?
I don't know... but... I don't claim to be a programmer.   :lol:  Someone who codes...? (can someone who codes answer that...?)
« Last Edit: February 27, 2010, 08:44:26 pm by jr2 »

 

Offline Mongoose

  • Rikki-Tikki-Tavi
  • Global Moderator
  • 212
  • This brain for rent.
    • Minecraft
    • Steam
    • Something
Re: Coding Horror: Why Can't Programmers Program?
We have a lovely little Programming folder located just under GenDisc, you know.

what's recursion?
In programming terms, feeding the output of a function back into itself.  One of the most basic examples would be writing a program to calculate factorials, n! = 1 * 2 * ... * n.  You write the code with two cases: 0! returns 1, and n! returns n * (n -1)!  The code works down the layers until it hits 0! and then goes back and multiplies all of the previous layers together.  It's a very useful concept for any number of problems, and whole languages, such as LISP (the bane of my existence in one particular class :p), are founded on it.  If you're going to work as a programmer, it's something you need to know.

 

Offline Polpolion

  • The sizzle, it thinks!
  • 211
    • Minecraft
Re: Coding Horror: Why Can't Programmers Program?
Somehow, I doubt that ~99.5% of programmers don't know how to program. When a 17 year old kid who hasn't programmed in nearly a year can supposedly program better than people with PhDs in computer science, something other than programming must be an issue here.

Frankly, I think it's much more likely that a handful of people accidentally posted a classified with "no experience necessary" appended than 199 out 200 people misjudging their abilities that much.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Coding Horror: Why Can't Programmers Program?
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Coding Horror: Why Can't Programmers Program?
Quote
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".
Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes. Want to know something scary? The majority of comp sci graduates can't. I've also seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution.

Code: [Select]
for i=1, 100 do
 if math.mod(i,3) == 0 and math.mod(i,5) == 0 then
  print("FizzBuzz")
 elseif math.mod(i,3) == 0 then
  print("Fizz")
 elseif math.mod(i,5) == 0 then
  print("Buzz")
 else
  print(tostring(i))
 end
end

time 5 minutes
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 
Re: Coding Horror: Why Can't Programmers Program?
Recursion is a concept where a problem is broken up into smaller forms of itself.
Someone mentioned factorials, but a better example is fibonacci:

Code: [Select]
int fib( int n )
{
  if ( n == 1 || n == 0 )
    return 1;
  return fib( n - 1 ) + fib( n - 2 );
}

The problem is that without some cleverness in there, something like fib 10 will take a very long time.
So then you move on to a region called 'dynamic programming', which 'memoises' the result of a previous operation, and in the above case can cause it to move from an exponential to a linear problem. Which is something you very much want :)

Nukes solution isn't optimal - as long as you do them in the correct order you don't need the two mods :) (but who cares about optimality in this case :) )
STRONGTEA. Why can't the x86 be sane?

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Coding Horror: Why Can't Programmers Program?
what's recursion?

google it

You fail at recursion. Googling Google is recursion. :p
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Coding Horror: Why Can't Programmers Program?
Recursion is a concept where a problem is broken up into smaller forms of itself.
Someone mentioned factorials, but a better example is fibonacci:

Code: [Select]
int fib( int n )
{
  if ( n == 1 || n == 0 )
    return 1;
  return fib( n - 1 ) + fib( n - 2 );
}

The problem is that without some cleverness in there, something like fib 10 will take a very long time.
So then you move on to a region called 'dynamic programming', which 'memoises' the result of a previous operation, and in the above case can cause it to move from an exponential to a linear problem. Which is something you very much want :)

Nukes solution isn't optimal - as long as you do them in the correct order you don't need the two mods :) (but who cares about optimality in this case :) )

yea i probibly coulda done

Code: [Select]
for i=1, 100 do
 if math.mod(i,3) == 0 then
  if math.mod(i,5) == 0 then
   print("FizzBuzz")
  else
   print("Fizz")
  end
 elseif math.mod(i,5) == 0 then
   print("Buzz")
 else
  print(tostring(i))
 end
end

and the mod statement would have only been used twice at most. but usually when i write code i make the function work first, then i optimize it later. as for what language, its lua.

what's recursion?

google it

You fail at recursion. Googling Google is recursion. :p

and you fail at recognizing a classic google prank. :D
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 
Re: Coding Horror: Why Can't Programmers Program?
From what I remember learning port's version is recursive.... nuke's isn't (not that that's bad, saves on stack space)
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Coding Horror: Why Can't Programmers Program?
From what I remember learning port's version is recursive.... nuke's isn't (not that that's bad, saves on stack space)

well we were solving completely different problems. recursion is what makes fractals so damn awesome, want more detail, just run the output back through it some more.

i kinda use recursion in a couple places in lua to covert arrays (or tables as lua calls them) into function arguments. since you can also stick a reference to the function into a table, i stick the function as a named key and the arguments in order from 1-n (n=number of arguments). so i use a recursive function to convert those arguments into a list of arguments and then call the function, all with a single generic call. this is useful for setting up a call to a function that draws a hud gauge, but in a hook that doesnt have readily access to the screen. instead i setup the table as a global variable that gets passed to hud hook, and then when appropriate i deconstruct it into the function call and arguments, and it gets drawn at the correct time. its a lot neater than making almost every value a global.

Code: [Select]
function toargs(tab)
local len = #tab
if len >= 1 then
return tab[1], nextarg(tab,1,len)
end
end
function nextarg(tab,cur,len)
cur = cur + 1
if cur <= len then
return tab[cur], nextarg(tab,cur,len)
end
end

so if i have a function called drawLine(x,y,x2,y2) and i want to draw it sometime later with data thats only available right now. id do something like this

Code: [Select]
t = {}
t.func = drawLine
t[1] = 10
t[2] = 12
t[3] = 11
t[4] = 9

i can call that function with those args with this.

Code: [Select]
t.func(toargs(t))

since the # operator only counts consecutive neumeric indexes starting at 1, it will only count the numeric values. works pretty well.
« Last Edit: February 28, 2010, 12:39:20 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Davros

  • 29
Re: Coding Horror: Why Can't Programmers Program?
I looked up recursion in the dictionary  and it says the following

recursion
re·cur·sion  [ri-kur-zhuhn] 
–nounMathematics, Computers.
See recursion

 

Offline The E

  • He's Ebeneezer Goode
  • Global Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Coding Horror: Why Can't Programmers Program?
Nukes solution isn't optimal - as long as you do them in the correct order you don't need the two mods :) (but who cares about optimality in this case :) )

The following in pseudo C:

Code: [Select]
for (i = 1, i++, i <= 100) {
    if !( i mod 3) // Using the C assumption that false == zero
        print("Fizz");
    if !( i mod 5)
        print("Buzz");
    println();
    continue;
    println(i);
}
Let there be light
Let there be moon
Let there be stars and let there be you
Let there be monsters and let there be pain
Let us begin to feel again
--Devin Townsend, Genesis

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Coding Horror: Why Can't Programmers Program?
Ummmm. That's never going to output anything other than Fizz, Buzz or FizzBuzz cause iy will always continue before it prints out the number.

This is one of those examples where simple is best. Nuke's first example might not have been optimal but it was about as easy to read and understand as it gets.

I'm actually kinda intrigued as to Portej05's optimal solution actually. I can see how you'd improve the code so that you could add other tests easily but I can't see how you're doing it with less if statements for only Fizz and Buzz.
« Last Edit: February 28, 2010, 08:00:35 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline The E

  • He's Ebeneezer Goode
  • Global Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Coding Horror: Why Can't Programmers Program?
* The E facepalms

Yeah, I probably should have thought this through, shouldn't I?

Code: [Select]
for (i = 1, i++, i <= 100) {
    if !( i mod 3) // Using the C assumption that false == zero
        print("Fizz");
    if !( i mod 5)
        print("Buzz");
    println();
    if ( !( i mod 5 ) || !( i mod 3 ) )
        continue;
    print(i);
}
« Last Edit: February 28, 2010, 12:24:13 pm by The E »
Let there be light
Let there be moon
Let there be stars and let there be you
Let there be monsters and let there be pain
Let us begin to feel again
--Devin Townsend, Genesis

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Coding Horror: Why Can't Programmers Program?
I still think Nuke's first was actually easier to read.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline The E

  • He's Ebeneezer Goode
  • Global Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Coding Horror: Why Can't Programmers Program?
Yeah, that it is.
Let there be light
Let there be moon
Let there be stars and let there be you
Let there be monsters and let there be pain
Let us begin to feel again
--Devin Townsend, Genesis

 

Offline MP-Ryan

  • Makes General Discussion Make Sense.
  • Global Moderator
  • 210
  • Keyboard > Pen > Sword
    • Twitter
Re: Coding Horror: Why Can't Programmers Program?
I still think Nuke's first was actually easier to read.

As someone with no programming background whatsoever [and experience in writing code only in the sense that HTML, CSS, and JavaScript all use a logical code], Nuke's first example is intuitive and easy to figure out even for me.
"In the beginning, the Universe was created.  This made a lot of people very angry and has widely been regarded as a bad move."  [Douglas Adams]

 

Offline Mongoose

  • Rikki-Tikki-Tavi
  • Global Moderator
  • 212
  • This brain for rent.
    • Minecraft
    • Steam
    • Something
Re: Coding Horror: Why Can't Programmers Program?
I remember one of my comp. sci. textbooks mentioning that negligible gains in efficiency can often be offset by substantial decreases in readability.  Unless you're trying to squeeze every last processor cycle you can out of code for some time-critical operation, it's usually a better option to write things up as clearly as possible.  Remember, either you yourself or someone else is presumably going to have to read it and figure out what you did somewhere down the line. :p