It blows my mind that anyone hired to write code full time would struggle with this. It took me two minutes to write the FizzBuzz quick from that page, and about 85% of that time was typing :)
public class FizzBuzz
{
public static void main(String[] args)
{
for (int index = 1; index <= 100; index++)
{
if (index % 3 == 0 && index % 5 != 0)
System.out.println("Fizz");
else if (index % 5 == 0 && index % 3 != 0)
System.out.println("Buzz");
else if (index % 3 == 0 && index % 5 == 0)
System.out.println("FizzBuzz");
}
}
}
And this just scares the hell out of me because I know how true it is:
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!
Now, the only language I know "like the back of my hand" is Java because I use it everyday, but I am comfortable with C, C#, PHP and Python. I can not only write loops in all five, but write at least fairly useful code in them. Despite having a math learning problem, I can do basic arithmetic without a calculator and can use recursion when I need to. For example, it never occurred to me in college that many of my peers would struggle with this:
public void getFullListing(File startPath, ArrayList list)
{
list.add(startPath);
File[] contents = startPath.listFiles();
for (File file : contents)
{
if (file.isDirectory())
getFullListing(file, list);
else
list.add(file);
}
}
In 12 lines of code, I just listed the contents of an entire folder in rough order (listFiles() doesn't return an ordered array). I've seen code like this, turned into two-two and a half page monstrosities:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
FILE *alphas = fopen("alphas.txt", "w");
FILE *digits = fopen("digits.txt", "w");
FILE *miscel = fopen("miscel.txt", "w");
FILE *inputf = fopen("inputf.txt", "r");
while ( !feof(inputf) )
{
int c = (char)fgetc(inputf);
if (isalpha(c)) fputc(c, alphas);
if (isdigit(c)) fputc(c, digits);
if (!isalpha(c) && !isalpha(c)) fputc(c, miscel);
}
fclose(alphas);
fclose(digits);
fclose(miscel);
fclose(inputf);
return 0;
}
I don't speak that language. My computer does though. And I am glad. :)
Actually, technically, your computer doesn't understand either of them. They have to be compiled first into machine instructions that your hardware will understand. Oh, and the first two examples are written in Java and the second one is written in C, so it's actually two languages.
I can still write it in COBOL, BASIC, Pascal, Dyl-260, Dyl-280, IDEAL, FOCUS, and maybe one or 2 others.
But NOT Assember. No way, no how.
My brain has a very small storage capacity. To make room for stuff that is useful, I constantly have to delete stuff I haven't used in a while.
Consequently, I don't remember names or old programing rutines. If I need them, I can always look them up on the internet.
The first example is fundamental enough that if you write code for a living, it shouldn't take you longer than about five minutes to complete. It's just too easy to get right if you know what you're doing.
I use my computer knowingly - I press the keys on the keyboard and typically the computer communicates with the keyboard typing out words and sometimes full sentences for me.
What else is there to know ;)
I am not comfortable with C, C#, PHP and Python, but I am comfortable with a Colt Python.
They didn't even have any of this crap back when I was in college, they were still trying to figure it out.