The biggest fail was the for loop. I hadn’t realized how confusing this syntax was. I don’t remember ever having any problems understanding for loops, so this hit me like a ton of bricks. A new programmer’s model of a program is like a line-by-line interpreter. He reads one line and updates his understanding of the world, then repeats on the next line. So if he reads

for (count = 0; count < 5; count++)

he probably believes these three statements happen one right after the other, which is incorrect. Furthermore, it is not immediately clear what the bounds of count are unless the programmer iterates through the loop in his head until he learns the idiom. The problem is that this for loop looks too much like normal code. Let’s look at this same thing in Python syntax.

for count in range(0, 5):

or Matlab:

for count=0:4

These syntaxes are much less ambiguous. In either syntax, we can unambiguously see that count ranges between two values. Python is arguably less clear due to 0-indexing but at least it’s in basically English. Matlab probably has the least ambiguous syntax.

The next thing I had to explain was the integer declarations. This led into a discussion of integer sizes and memory. Do I want to be explaining this to a newbie programmer? Consider that the programmer doesn’t really care. He just wants to take input and add his numbers.

He also had questions regarding the package declarations on line 1, the import statements on line 3, and the access modifiers on the class and the main() method. I wasn’t really comfortable explaining scoping and software engineering best practices to a programming newbie so I basically had to tell him to keep putting it there for now and I can explain it when his understanding of Java increases. (I’ve always been taught in the same way so I’m not the only one who believes this.)

This was unsatisfying to my student. He’s trying his best to understand this black box in front of him and the one person who can help him has to say “no”.