I’m almost done with my first semester teaching a high-school Java programming class.
My perspective on teaching Java is different now than it was after I had just finished going through my classes in college that taught Java. Some of it is that there is a substantial difference between a college class and a high school one; a difference that leads me to the following conclusion: Java is not a good language to teach high-school kids that haven’t been exposed to programming at all.
Take the “hello world” Java program, for example:
import java.io.*;
public class Hello {
public static void main(String args[]) {
System.out.println(“Hello World\n”);
}
}
Right off the bat, I have to explain what a class is. These kids don’t even have any pre-knowledge at all of programming, and I’m supposed to get them to understand class? Also, notice that “String” is used, as well as “System.out.println” and “java.io.*”. That’s three more concepts that are hard to explain when you have no foundation to build on: user-defined data types (which is really the same as class, but I digress), nested classes, and packages. I understand that a valid method of teaching this is to tell them to simply “accept this or that, and we’ll understand it later”, but almost everything in even the simplest of Java programs is one of those things.
By contrast, look at the C version of “hello world”:
#include “stdio.h”
int main(int argc, char *argv[])
{
printf(“Hello World\n”);
return 0;
}
There’s only one thing in this program that I would instruct my students to simply accept – the array of pointers, argv. The rest of the program can be explained in a straightforward way.
Object-oriented programming, which in my opinion is unavoidable if you want to teach Java, is quite a large thing to swallow for kids who have not been previously exposed to programming. And, I might add, if you teach programming with Java and don’t teach object-oriented programming, then you aren’t teaching Java at all, but rather something else that has Java-like syntax.
I think, given two semesters to teach (a two-part course, or however you want to structure it), I would make the first semester be a language learning semester. We’d learn the syntax and structure of 3-4 structured programming languages like Basic, C, Lisp/Scheme (ok, ok, these aren’t exclusively structured, but enough so for my purposes), and maybe even some languages used in web-based design like PHP or Perl. The second semester would be oriented around programming projects, in which the student uses one or more of the languages learned in the previous semester. That would appeal to people who find different languages more intuitive for various reasons, and it would allow us to get some good experience in at least one language instead of zooming through material that isn’t appropriate just because AP says it’s good and because colleges are teaching it.
I’d say that a person going to college with a solid basic understanding of structured programming will fare far better than a person who knows Java syntax and only has vague conceptions of both structured programming and object-oriented programming.
I should let on that I don’t think Java is all bad, though. One of the best things about Java is that once a student is ready to learn object-oriented programming, Java makes that as painless as it’s going to get, I think. Java is a relatively small langauge, and doesn’t take a terribly long time to learn, and it can be used to learn to program in a variety of application domains. It’s a very good language to know; I just happen to think it’s a poor language to teach in high-school.