Catalysoft   Turtle
home products articles about us contact us

Recent Articles

What's Good About Clojure?

Clojure is a relatively new language to appear on the Java Virtual Machine (JVM), although it draws on very mature roots in the form of the LISP langu ...

Should You Care About Requirements Engineering?

Recently, I (Adil) was invited to participate in a one day seminar on the subject of Requirements Engineering. Whilst I have no direct experience of t ...

Tips for Setting Up Your First Business Website

To attract all potential customers to your business you need a presence on the web. The problem is that if you haven't set up a website before, you p ...

What's Good about LISP?

LISP is a general-purpose programming language and is the second-oldest programming language still in use, but how much do you know about it? Did you ...

Open Source Tools for Developers: Why They Matter

From a developer's point of view use of open-source tools has advantages beyond the obvious economic ones. With the open-source database MySQL in mind ...

Book Review: Ground-up Java by Philip Heller

Discuss this article >>>


'Ground-Up Java' was published in November 2003 and is aimed at those with little or no programming experience who wish to learn Java. "Not another Java book!" I hear you cry. Well, yes - but this one's different. Apart from assuming no prior knowledge of programming (where many Java books assume prior knowledge of C or C++), this book makes an earnest attempt to engage the newbie Java programmer in well-bounded activities of programming discovery right from the start. I say 'well-bounded' because the software supplied with the book sets limits on what you can do. And for someone at the start of their programming career, this should be seen as a virtue rather than a real limitation. For example, it means readers have no need to fix a syntax error until they are better equipped to deal with it. If you are teaching yourself programming from the book (and don't have a more experienced programmer at hand to help you out if you get stuck), then this is exactly what you would want.

The book has 393 pages in 17 chapters, but in my opinion these chapters can be grouped such that the book divides into three parts:

Part 1: Introduction to Programming (chapters 1-6)

Part 2: Introduction to Object-Oriented Programming (chapters 7-11)

Part 3: Core Java Packages and Using Java in Practice (chapters 12-17)

Part 1: Introduction to Programming

Perhaps this book should be called 'Ground-Up Programming in Java' rather than 'Ground-Up Java' because it doesn't just teach Java - it teaches programming, and quite a bit about computing in general too. Java just happens to be the language the concepts are expressed in. For example, the book progresses through the following topics in the first chapter:

an introduction to computers that explains how 1s and 0s can be used to represent almost anything in a computer's memory

the relationship of binary numbers to opcodes and the limited instruction set of an assembly language

how CPUs use registers to temporarily store and manipulate values

a simulation of a computer (called 'SimCom') that processes assembly-level instructions

the close correspondence between the SimCom simulation running on a real computer and the Java Virtual Machine.

That's quite a lot for the first chapter! In fact, by page 13, you'll be programming in assembly language, which is surely impressive by anyone's standards. Here's one of the exercises from the end of chapter 1:

'Write a SimCom program that computes the square of the value in byte 31 and stores the result in byte 30. What happens when you try to compute the square of 254?'

Don't be too concerned if this exercise sounds difficult - there are nearly 60 pages of annotated solutions to the book's exercises in Appendix B.

Chapter 2 introduces the notion of data type, and includes a first very simple Java program. Chapter 3 moves on to operators and operator precedence, progressing to methods and scoping issues in chapter 4.

At certain points of the book, Heller drops in an anecdote or story from the real world that relates to a particular programming concept. Such analogical explanations, when appropriate, really aid understanding, especially for those new to programming. For example, the following delightful little anecdote introduces the concept of short-circuit Boolean operators, which avoid fully evaluating an expression if the answer is already known:

'When I was a little boy, I was allowed to go out and play if I had made my bed and finished my homework. I didn't mind doing my homework, but I hated making my bed and often wouldn't do it. When my mother asked me if I had made my bed, I would start to say "No, but I…" I was going to say that I had done my homework, but my mother would interrupt me. She was a busy person and she had heard all she needed to hear. Our agreement was that I would do two chores. As soon as she knew that I had not done one of those chores, there was nothing I could say about the other chore to convince her that I had lived up to my part of the agreement.'

I really like this portrayal because it is so accessible, and offers a very good analogy to the computing idiom. The boy's mother is evaluating a Boolean AND condition using a short-circuit operator, and using the knowledge that false AND <anything> is false.

Ground-Up Java: While Lab
Figure 1: While Lab

As a new programmer, chapters 5 and 6 is where things start to hot up, with the introduction of looping constructs and arrays. In my opinion, this is also where you really start to see the advantage of the animated illustrations. For example, you can modify and run Java programs that contain loops (While Lab) or nested loops (Nested Loops) without ever worrying about text editors or compilers.

Ground-Up Java: Nested Loops
Figure 2: Nested Loops

A few years ago, I taught an introductory programming course at a university to a cohort of 'virgin' programmers. I found that one of the main problems for those just starting to program is that they must learn not only the programming language, but simultaneously how to use related tools (such as editor and compiler) and recover from errors. These additional tasks are really distractions from the main business of learning the programming language, so Heller's approach really makes a big win in this respect.

Part 2: Introduction to Object-Oriented Programming

Chapters 7 through 11 introduce the concepts of object-oriented programming, so here's where you'll meet such fashionable terms as inheritance, construction, overriding, overloading and polymorphism. The book explains the idea of data hiding and show how a Java program can be structured into packages. It also shows how interfaces are useful in an OO language without multiple inheritance.

Chapter 11 covers a topic that is probably too often overlooked - exceptions. The principles of the topic are particularly well explained. However, I have one minor gripe on the accuracy of the text. Heller states 'All exception subclasses in the core Java packages have two forms of constructors: a no-arguments version, and a version that takes a text message as an argument.' Although this was true up until Java 1.3, Java 1.4 added two more constructors to the Exception class. There is now a constructor that accepts a Throwable as the cause of the Exception, and another that accepts both a message String and a Throwable cause. (Compare Sun's JavaDoc for the Exception class in Java 1.3 with that for Java 1.4.) The advantage of these two new constructors is that you can partially deal with an Exception, and then re-throw it, if necessary constructing a different Exception class when you re-throw it.

For example,

try { 
} catch (BareCupboardException bce) {
    String msg = bce.getMessage();
    System.out.println("Bare Cupboard Exception: "+msg);
    throw new ResourceNotFoundException(msg, bce);

Part 3: Core Java Packages and Using Java in Practice

To describe the core packages in Chapter 12, Heller first explains that there are three kinds of packages:

the special package java.lang, which is so fundamental that you never need to import its classes into your programs;

specialist packages such as java.awt, which are only useful for particular kinds of programs (in this case those with a graphical user interface);

general packages such as java.util, which could be useful in any kind of program.

He describes very few core classes in detail (java.lang.Object, java.lang.Integer and java.lang.Math being the exceptions). Instead, he explains how to navigate your way around Sun's JavaDoc to find more detailed explanations of the classes. I like this approach. Heller acknowledges that there is not enough room in the book to explain all (or even many) of the core packages and classes, so he helps you to help yourself. Navigating the JavaDoc is also standard practice for Java programmers, so it's worth introducing it as a valuable skill. Perhaps Heller should have also mentioned that you can download the source code for the Java core packages. Maybe it's just a little too scary for beginners to go rummaging around the inner workings of Java, but on the other hand it's reassuring to know there aren't any secrets.

Chapter 13 does a good job of explaining File Input and Output, and contains some great animated illustrations of chained streams (see Chained Data Streams).

Ground-Up Java: Data Streams
Figure 3: Chained Data Streams

Chapters 14 and 15 provide a good introduction to programming graphical user interfaces in Java (a huge topic in itself), and chapter 16 focuses on events and event-driven programming. Before introducing event-driven programming, Heller first gives a brief introduction to Threads:

'I was eight years old. I was waiting my turn to get my hair cut, and I was reading a Superman comic book. The Man of Steel was entertaining some kids at an orphanage by playing ping-pong against himself. He would serve the ball, then run at super-speed to the other side of the table to return the ball. Then he would run back to the original side, and so on. Each time he changed sides, he ran so fast that nobody could see him, and he ended up exactly where he had been before. This created the illusion of two identical supermen.'

The point is, of course, that computers can create the illusion of doing several things at once by rapidly switching from one task to another.

The discussion of event-driven programming leads you through the development of a graphical user-interface for the game of Nim. It starts with a button-driven input and a simple textual output, but ends with a fully graphical user-interface in which buttons are only enabled when their input is allowed.

Chapter 17 brings together knowledge from the rest of the book to present a longer example that contains a graphical user interface, uses loops, arrays and conditional statements, and makes calls to methods that throw exceptions.


In conclusion, I think Ground-Up Java is a really good introduction to programming. It is not so much a Java programming book, because I feel that it gives a good grounding in computing and teaches concepts that are transferable to other languages. My main criticism, if I must have one, is that in the early parts of the book, I believe there is too much detail for some of the lower-level concepts, such as assembly-level programming and bit-wise shift operations.

I can think of only one other area where the book might be lacking as an introduction to programming, and to be honest I have never seen this in any other book either. I think it would be good to see a list of, say, the top 10 most common programming errors, together with explanations of the problems and their solutions. There are many errors that almost every programmer will meet and it seems odd that methods for tackling such errors are so poorly documented. This is especially important for new programmers.

If you are already a competent programmer in a language other than Java, especially if it is an object-oriented language, then this book is not for you. If you have not programmed before, or perhaps just done a bit of web scripting, then Ground-Up Java could be a good book for you. If you teach Java and are looking for a book that provides a solid foundation for eager students, then look no further. In my opinion, it's ideal as a teaching course because the book already provides much of the support material in the form of the animated illustrations. Well actually, it's almost ideal. The software license agreement for the accompanying software grants only a single user license for personal, non-commercial use. So you'd better check with the publishers if you require more than this for your course.

Discuss this article >>>

Simon White