Some Questions and Answers about using Java in Computer Science Curricula

By Doug Lea.

[Mostly written winter 1996, and not updated lately.]

We in the Computer Science Department at the State University of New York at Oswego have been using Java in the freshman CS majors-oriented introductory programming course (``CS1'') since September 1995, and in the second (freshman/sophomore) programming course (``CS2'') since January 1996.

Lately, many people from other Computer Science departments have been asking me how it is going. I never quite know what to say beyond ``so far, so good''. Instead, I'm collecting some particular questions and answers here. I'll update and add items as I get the chance.

First, here is some quick background: These are 13-week semester-long 3-credit lecture courses with programming labs. The CS1 (and some CS2) labs include structured, supervised exercises. Craig Graci is teaching CS1. I'm teaching CS2 this semester to students who (with a few exceptions) learned Java in CS1. We've also used Java in a few other CS courses, and many of our junior/senior students are choosing to use Java for projects in advanced courses. But CS1 and CS2 (and to some extent CS3 and related courses) represent our main current efforts in evolving our mostly ACM-style undergraduate-only BA/BS Computer Science program with a general emphasis on systems and software engineering. CS1 and CS2 are also taken by Information Science majors, CS minors, some math and science majors, and other interested students. Besides the CS1/2/3 prgramming-based sequence, we also require majors to take courses in (1) computer architecture and low-level programming, (2) an introduction to formal methods, (3) a comparative programming languages course where students learn non-Java-like languages like ML and their associated programming paradigms, (4) an introduction to software engineering based around Watts Humphrey's PSP (that was taught most recently using Java). Before using Java in CS1/2/3, we used (most recent first order) C++, Modula2, Pascal, and Fortran for core courses. We standardize on languages only for the CS1/2/3 sequence. Beyond there, instructors require or suggest using any language that makes sense for their courses, or just leave it up to the students. We do not yet use Java in any way in any of our ``service'' courses for non-majors.

  1. Should we use Java in our CS program?

    I really cannot think of any good pedagogical reason not to. Some obvious advantages are:

    There are of course some differing opinions out there. It's not hard to find articles, web pages, and mail saying that Java should have been more like Ada or Eiffel or Smalltalk or ML or ... probably even Cobol.

  2. Isn't this just a faddish response to popular trends?

    We don't think so. We don't for example bother to teach Visual Basic, even though it is probably the most widely used programming language in the world.

    But Java is different. Java supports a minimal set of constructs that together reflect the bulk of technical advances in programming methodology that have occurred over the past fifteen years or so. Its status is analogous in many ways to that of both Pascal and Unix in the early 1970s. Pascal, Unix, and Java all arose as simpler, more understandable, and more practical alternatives to existing technologies (Algol68 etc, Multics etc., and C++ etc respectively). Further, each contributed new ideas, and ultimately served as the technical substrate for further theoretical and technical advances.

    Thus, it is not so much Java language itself, but the programming concepts and skills that are inseparable from the language that affect CS curricula. (In this sense, the fact that Java is relatively easy to learn, and that it is becoming immensely popular in commercial and other everyday use are mainly just added incentives to rethink curricula.) These include:

    Compositional Software Construction
    Nearly all programs are made from parts, most of which are not written by the program author. Locating, understanding, and using external components are valuable, demanding technical skills in which CS students need training and experience. Java accentuates the importance of such skills, since programers now need to cope with instantly-reusable components (Java ``.class'' files) that can be found over the entire internet.

    Object-Oriented Design and Programming
    Most CS programs have over the past ten years increasingly integrated OO concepts into their curriculum. But language issues have in part been to blame for the hard-to-defend tendency to teach OO programming after traditional procedural programming, rather than before -- a phenomenon akin to teaching structured loops only after teaching raw jumps. The OO aspects of Java are tightly enough integrated, and easy enough to learn that there is no reason not to teach them first. At the same time, unlike other thoroughly object-oriented languages, Java is (at least syntactically) similar enough to raw C that students should have little trouble later learning C in courses on low-level and systems programming.

    Reactive Programming
    At all levels of scale, most software that people use is reactive -- programs responding to UI events, incoming phone calls, external stimuli of all sorts. Students who learn only to design and implement self-contained single-purpose programs are ill-prepared to build entire categories of useful software. Java provides a simple and fun entry point into reactive programming via Applets -- UI-based programs that can run from HTML pages. Further, because Java directly integrates concurrency constructs into the language itself, larger scale multithreaded reactive programming techniques can be introduced relatively early and naturally, without needing to switch to other languages or tools.

    The Broadening Role of Programming and Programmers
    It's impossible to predict how extensively or for how long Java will be used in WWW, multimedia, and information appliance applications, and the like. However, it's a safe bet that the kind of integration of programming into everyday life seen with Java will not soon subside. Programming a WWW-accessible Applet that happens to be run by people halfway around the world provides a gentle introduction to some standard engineering issues: the impact of software on society, the need to work with other professionals (if only a fellow student who knows a bit about graphic design) in producing artifacts, and engineering responsibility and ethics.

    One commonality across these notions is that ``ordinary'' programming increasingly relies on design and engineering principles in addition to those surrounding algorithmics and computation. The need to understand classic data structures, algorithms, formalisms, and analytic techniques has not at all disappeared. However, such topics cannot be studied in isolation, or to the exclusion of others. Perhaps it was once true that implementing a good data structure was tantamount to implementing a useful program. However, as the application, scale, and pervasiveness of software have grown, so too has the need to encapsulate, structure, and coordinate such implementations as components of larger systems.

    In short, we believe that it would be a disservice NOT to provide courses introducing, as early as reasonable, concepts and skills that happen to be well supported in Java. The introduction of Java provides a timely vehicle for re-examining these aspects of standard ACM-like CS curricula.

  3. Isn't it a problem that there aren't any good CS1/2/3-style textbooks based on Java?

    We haven't found this to be a big problem; just a minor nuisance. (To quote Jim Waldo quoting someone else: The language just isn't all that hard!) We don't currently use a text at all in CS1. In CS2, I use a language-independent data structures text mainly just as a reference, without coordinating too tightly with lectures. As of this writing, none of the books out on Java that I have seen (which is by no means all of them) can be recommended as course texts. However, books such as Arnold and Gosling's The Java Programming Language can serve as useful auxiliary texts.

  4. Do you have students programming entirely using Applets?

    No for CS1; yes for CS2. In CS1 we use Java in a standard text-based edit-compile-run environment, writing programs with standalone mains. In CS2, all assignments are written as Applets. This was originally done mainly just for logistic reasons -- our campus doesn't have enough SparcStations or Windows95 PCs to guarantee sufficient access for all 70-100 CS1 students per semester.

    However, so far, this looks like it has turned out to be a pretty good arrangement. It is very hard to describe Applet construction mechanics to complete novices until they have had some experience with Java expressions, variables, methods, classes, and so on. But once they know these things, it is easy and fun to introduce Applets. (All this will surely change as better Applet development tools and environments become available. But even when these become available, it might still provide a better foundation to delay their introduction until students have a better idea of what's going on underneath. Or maybe not. Given that appropriate tools aren't available, I just don't have any opinion.)

  5. CS1: Do you start off covering classes?

    Pretty much. Actually, we start off talking about problem-solving more generally, and computing more generally. But objects and classes are introduced almost simultaneously with expressions and statements.

  6. CS2: Doesn't covering things like Applets take away from class time that could be better spent on data structures and other standard CS2 material?

    Yes, it does take time. No, I don't think it is wasted time. It actually fits pretty well into the way that (at least my OOish version of) CS2 is built upon modeling:

    Emphasizing such things before and while attacking classic data structures and algorithms has worked pretty well.

    On the other hand, there is some overhead that doesn't fit in all that well. Too much class time on logistics matters about using Netscape and Solaris and Win95 and so on. Plus, teaching enough HTML and related WWW mechanics to survive.

  7. Do you cover the whole language in CS1? CS2?

    No; it's not even a goal. We teach concepts and skills appropriate to the course, and how to express them in Java, not the other way around.

  8. Do you ask students to work through the Sun Java Tutorials?

    No. Sun's (and other WWW) tutorials aren't all that useful for students learning Java in the context of learning Computer Science.

  9. What's the impact on equipment and facilities?

    You'll want more computing power and better connectivity. But then, you always do. You'll also have to live with installing regular updates of JDK, HotJava, etc.

  10. What's the biggest mistake you made?

    In our first year, we probably over-exploited how easy it is to learn basics; sometimes forgetting that it still takes time to gain minimal ``programming maturity'' in any language.

  11. What's the most surprising thing?

    For me, the way in which CS2 students so readily adapt to the notion of building reactive, distributed programs on the internet, and how this, as much or moreso than the object-oriented aspects of Java programming, so fundamentally governs their attitudes on what programming is all about.

  12. Do you cover concurrent (Java threads etc) or distributed programming (for example using Java RMI) in CS1? CS2?

    No, mainly because we haven't figured out yet how to do justice to these aspects of programming within the context of these courses. But see Lynn Andrea Stein's Rethinking CS101 project (MIT) that is attempting to do so.

  13. Do you have a long-range curriculum plan?

    Nothing formal. (Although some of my departmental colleagues strongly disagree, I think it's counterproductive to do any kind of long-range planning of Computer Science curricula beyond ensuring enough structural freedom to be able to adapt, evolve, and experiment with courses. The main undesirable consequence is that students in advanced courses have uneven backgrounds. So what.)

  14. Do you have any course materials available?

    Most notes, outlines, examples, lab exercises, support code, etc., are being written as we go along. Some under-construction materials are available from my home page, Craig Graci's home page, and Rameen Mohammadi's home page.

  15. Can you give any quantitative results about differences between Java-based versus C++/Modula/...-based courses?

    Nothing beyond the tentative observation that so far, we've seen less attrition than when we used C++.

  16. What other colleges, universities, or high schools are using java in CS Courses?

    Sun used to maintain a list online, but it seems to have vanished. The ACM SIGCSE site also contains some related links.

    Also, see some of the exchanges on Using Java in the ETS AP CS Exam .

Additional questions and comments would be welcome! Send them to

View this page in Romanian courtesy of azoft

Doug Lea
Last modified: Sun Apr 5 17:06:21 EDT 1998