Should students learning an object oriented programming language start out with a “Hello, world” program? That’s the question David H Steinberg asked in an onjava.com article this week. He does a pretty good job of covering the tradeoffs in the article, and I think that the question is worth some thought. As a writer of technical books, I guess I should attempt an answer.
As far as I’m concerned, “Hello, world” is a fine example, even though it doesn’t really teach you anything about what differentiates Java from other languages. Heck, the most striking thing about “Hello, world” in Java is that it’s more cumbersome to write than it is in most other languages I’ve used. The main purpose of the first program you learn is not to teach you the language, but prove that your environment is set up correctly, that you can successfully compile a program, and that you can execute a program. You can start teaching the student about the language in the next program.