Section 1.8
Why Java? Why not C++?
IN THE PAST (before Fall '96), Computer Science 124 was taught using the Pascal programming language. Although Pascal is a very nice language, the tide of fashion in computer science had turned pretty definitively against its use as a "serious" language. Most professional programming is done using the languages C and C++, and students were eager to learn these languages. Large numbers of college computer science departments had already made the switch. And so after much discussion and with some regret, the Department of Mathematics and Computer Science at Hobart and William Smith Colleges decided to make the switch to C++ as the language of instruction in its introductory programming classes.
The decision was made with some regret because, in fact, C++ is just not a very good programming language for learning about programming. It is a very large and complex language with lots of features to delight experienced programmers. But for beginning programmers, those features just get in the way. So in fact, a beginning programming course can only cover a small subset of C++. But all the other features are still there, and it is not possible to avoid all of the complications that they cause.
Enter Java. Java is a fairly new language, but it already seems likely that it will become a very important language -- perhaps even more important than C++ in the long run. Java shares many basic features with C++. However, it leaves out some features that are useful for advanced programming but that tend to cause a lot of confusion and problems -- especially for new programmers. Because they share so many features, it should be relatively easy to move from Java to C++. In fact, C++ is used as the language of instruction in Computer Science 125 (Intermediate Programming), the course the follows Computer Science 124 in the computer science program at Hobart and William Smith Colleges. Chapter 9 discusses some the advanced features of C++.
Now, you shouldn't jump to the conclusion that Java is an inferior language, just because it's simpler than C++. In fact, Java has some features that make it an improvement on C++ in some ways. Its major strengths, of course, are its abilities to be downloaded over a network, to be run on many different computing platforms, and to work seamlessly with Web browser programs. It is these abilities that have caused all the excitement.
Furthermore, Java has built-in support for "threads," as mentioned in Section 2. Such support makes it easier to write programs that have to do several things at once (such as a Web browser, which should be able to download a file, redraw a window, and follow a new link all at the same time -- while running a few Java applets for good measure).
There is one other feature of Java that most people would see as an advantage: garbage collection. I won't try to explain this now, but it has to do with the way computer memory is used by a program. In C++, programmers have to do a lot of work to manage that memory, a difficult and error-prone task. Java uses garbage collection to automate a lot of this memory management. (The "garbage" is memory that has been used by the program but is no longer needed.) Of course, a C++ programmer would say that the Java programmer has given up a lot of control over the machine. This is true, both for garbage collection and for other features of Java. This makes Java both easier and safer to use, but it means that it will almost certainly never replace C++ entirely.
Overall, Java is a well-designed language that is pleasant to use while still offering a lot of power. Whether or not it ever becomes as important as I think it will, it seems like a good place for the beginning programmer to start.
End of Chapter 1
[ Next Chapter | Previous Section | Chapter Index | Main Index ]