Preface

Computers are changing almost every aspect of our lives. They’re changing how we relate to one another and even changing how we think of ourselves. The very idea that my brain is a biological computer that could be, in some fundamental mathematical sense, no more powerful than the laptop on which I’m typing these words is mind-boggling. The fact that I can program a computer to control a robot, play chess, or find a cure for disease is tremendously empowering.

This book is organized as a series of essays that explore interesting and fundamental topics in computer science with the aim of showing how computers and computer programs work and how the various aspects of computer science are connected. Along the way I hope to convey to you some of my fascination with computers and my enthusiasm for working in a field whose explosive growth is fueled in no small measure by the ability of computers to support collaboration and information sharing.

While not meant to be exhaustive, this book examines a wide range of topics, from digital logic and machine language to artificial intelligence and searching the World Wide Web. These topics are explored by interacting with programs and experimenting with short fragments of code while considering such questions as:

You can read this book without ever touching a computer, but I think you’ll have a lot more fun and learn more if you follow along by running the code fragments in the text. Think of each fragment as a thread in a complex pattern; I try to unravel the thread and explain how it relates to the larger pattern. Then, by making small changes to a code fragment, you can explore some of the nearby threads and test your understanding of the concepts.

Reading a book is different from attending lectures, but a book, like a lecture, adopts a style of teaching and assumes a style of learning. My style in this book is to start with examples and introduce general principles as they seem appropriate. For the most part, I’m hoping that the general principles will come peeking through the examples without my being too heavy-handed. The numerous code fragments invite you to experiment on your own.

I’ve included snippets of code from a variety of languages: C, Java, Perl and Scheme. I’ve tried hard to help you see past the differences in syntax to the basic underlying computations. Despite what you may have heard about introductory courses, computer science has little to do with arcane syntax; instead, it’s all about thinking about problems computationally. Syntax is just a means to the end of communicating with computers, and here we focus first on what we want to say and only second on how to say it.

But it’s no fun if you can’t communicate with the computer, and so you’ll meet lots of code and lots of syntax in this book. I don’t, however, include a comprehensive introduction to programming. You’ll need additional sources of information if your experiments deviate significantly from the programs presented here. Fortunately, much of what you need as supplementary material is available on line.

Many of my examples involve communicating directly with the operating system by using interactive programs called shells. Shell programs are available for most modern operating systems including Unix, Linux, Solaris and the Apple and Microsoft operating systems. Shells provide commands for accessing a great deal of online documentation. For example, manformats and displays the online manual pages for all the basic commands; infoprovides similar services with a somewhat nicer interface.

Of course, you’ve got to know where to look and how to call up all this wonderful information. The web site for this book (www.cs.brown.edu/people/tld/talk/) is a good place to start. It lists resources for setting up shells for different operating systems as well as pointers on installing the other programs mentioned in the book. The web site also lists various online forums and news services that you can subscribe to and post your own questions and suggestions.

Despite all the legends about isolated hackers, programming is a primarily social activity. Programmers use, build on and improve programs written by others. Programmers learn by talking with other programmers and reading one another’s code. Learning to program can be accelerated by learning with others. Even if you don’t initially have close friends who share your programming interests, the web makes it easy to meet other programmers at all skill levels. If you’re shy you can start by reading newsgroups, but don’t miss out on all the fun of sharing programs and interacting with other programmers face-to-face and online.