A Gentle Introduction to the Art of Dynamic
Object-Oriented Programming in Python
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. And dynamic scripting languages, such as Python and Ruby have come storming onto the scene.
Monty Karel updates Karel J Robot to provide a means of introducing novice programmers to dynamic object programming. This book maintains the simplicity of the original and yet provides instruction that is thoroughly object-oriented from the beginning. Where the original Karel the Robot used a syntax and methodology derived from Pascal, the present text is 100% Python. 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 like Karel J Robot puts a lot of emphasis on polymorphism, the primary distinction between procedural programming and object-oriented programming. Additionally, languages like Python have many of the characteristics of Lisp/Scheme, in that functions are first-class objects and can be passed as data for later execution. There is also an introduction to simple but important design patterns, such as those that have recently revolutionized software practice.
Like its predecessors, Monty Karel 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. This puts the focus clearly on problem solving rather than language syntax. 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. Python also has the advantage of having relatively little syntax to learn.
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), since 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 object-oriented programming.
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, Monty Karel 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, Monty Karel 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 ++, Karel J Robot, and Object-Orientation in introductory programming courses at the college level. It will contain solutions to most of the in-text exercises.
Software to simulate Monty Karel is available on the Web. http://www.cafepress.com/kareljrobot
Joseph Bergin, Pace University
Mark Stehlik, Carnegie-Mellon University
Jim Roberts, Carnegie-Mellon University
Richard Pattis, University of California, Irvine