On the teaching of programming
Thanks to my friend Peter Boothe, I found a blog post urging me (and anyone who read it) to make a pledge that they wouldn’t teach Java at the college freshman level or earlier.
Intrigued as to why java was singled out (but not say, C++), I continued reading. The author makes a great point:
Here’s a common error — it’s a faulty method declaration.
public void foo(); { // blah, blah blah }The error you get is: missing method body, or declare abstract. Sure, that message makes sense if you understand about semi-colons and blocks, but if you don’t…”What’s abstract?!? I have a method body there — why doesn’t it see it?”
Here’s the one that I saw multiple times (both versions), which I find just infuriating.
while (a < 4); { // do something in here, and probably change "a" } if (sometest()); { // do something if true }These are infuriating because there is no error — the first generates an infinite loop, and the third one just always executes the body, ignoring the result of the test. Programs don’t work, and the compiler gives no clue that the students did something that only experts can handle correctly.
Fortunately, there are solutions to this problem. The clang project has shown us that we can have excellent error reporting for C++ (I use it at least once a week), and if we can do that well on C++ errors, Java, with it’s relatively easy-to-parse spec should be a piece of cake. Anyone know if there’s a project to drastically improve Java errors?

