If you're new to the wonderful world of Java, you may be looking for a good reference/introductory guide to get you started. In his latest article, Simon reviews Ground-Up Java. Read on to find out whether it's a suitable book for those looking to learn Java.
Book Review: Ground-Up Java by Philip Heller - Part 1: Introduction to Programming (Page 2 of 5 )
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.
Figure 1: While Lab
As a new programmer, chapters 5 and 6 are where things start to heat 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 (Figure 1) or nested loops (Figure 2) without ever worrying about text editors or compilers.
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.