Karel J. Robot
A Gentle Introduction to the Art of Object-Oriented Programming in Java



The programming landscape has changed significantly since the initial publication of Karel the Robot in 1981. Today there are new programming languages, new programming paradigms, and new and more powerful computers. Pascal no longer enjoys the popularity it did in the 1980s. However, the concepts of Karel are still as vibrant and valid an introduction to the programming and problem-solving processes as they were when first introduced. However, the object-oriented programming paradigm has begun to dominate the world of commercial software production.

Karel J. Robot updates Karel the Robot and even Karel ++ to provide a means of introducing novice programmers to object-oriented programming (OOP). This book maintains the simplicity of the original and yet provides instruction that is thoroughly object-oriented from the beginning. Where the original used a syntax and methodology derived from Pascal, the present text is based closely on Java. In object-oriented programming, a computation is carried out by a set of interacting objects. Here, the objects are robots that exist in a simple world. There can be one or several robots assigned to a task. The programming task is divided into two parts. The first part is defining the capabilities of the robots that are needed. The second is providing a description of the task for the robots to perform. The programmer uses his or her problem solving skills on both parts of this task. This version goes beyond the earlier Karel++ to put more emphasis on polymorphism, the primary distinction between procedural programming and object-oriented programming.

Like its predecessors, Karel J. Robot is a Turing complete language that can be mastered in a few weeks. While not convenient for many tasks, it is theoretically possible to solve any computer programming problem in this simple language. This gives it educational power. Instead of using many many language features to solve problems, students must apply a few simple tools in combination to solve some hard problems. At the same time they are learning the core of an important modern programming language and the core concepts of the object-oriented programming paradigm.

We believe that most people will not actually have to program a computer as part of their everyday lives, either now or in the future. However, many people will need to be able to use a computer and will occasionally need to do something with the machine beyond the "ordinary." Simply put, they will have to solve some type of computer problem. We solve various kinds of problems every day; problem solving is part of our lives. This book will introduce you to problem-solving approaches that can be used with computers. Unfortunately, some people believe programming requires a "different" way of thinking. We don't agree with this statement. Instead of changing the way you think, this book will change how you apply your problem-solving skills to different kinds of problems.

The original Karel the Robot used procedures as the fundamental problem solving medium, as is appropriate in procedural programming. Here we apply our problem solving skills, instead, to the design of classes that describe objects (robots), as classes are the primary means of breaking a complex problem into manageable parts in object-oriented programming. The skills of procedural programming and object-oriented programming are very similar, though we look at problems from a slightly different perspective when using OOP.

For the experienced student programmer, this edition should provide insights into the problem-solving and program design processes that will make the student an even better programmer. It will also improve understanding of computer science concepts such as polymorphism, loop invariants and recursion. For individuals who want to begin a thorough sequence of training and education in programming, computer science, or both, Karel J. Robot provides a solid foundation on which to begin your work.

For novice programmers, this book will give some insight into the programming process from two distinctly different points of view: the planner's and the implementer's. All the problems can be thought about, discussed, and planned in English. Once you have developed your plan, the actual syntax of the robot programming language has very few rules to get in your way as you become the implementer or programmer.

For individuals who do not want to program but need to have a feel for the process, Karel J. Robot is an excellent tool for providing that insight.


An Instructor's Manual will be available for the text, and contains numerous pedagogical suggestions for teaching the material based on many years of using Karel the Robot, Karel ++, and Object-Orienation in introductory programming courses at the college level. It should contain solutions to most of the in-text exercises.

Software to simulate Karel J. Robot is available on the Web.

Joseph Bergin,		Pace University
Mark Stehlik,		Carnegie-Mellon University
Jim Roberts,		Carnegie-Mellon University
Richard Pattis,		Carnegie-Mellon University

August, 2002

Back to the Book Karel J. Robot