Author: John V Guttag
Publisher: MIT Press
Audience: Students wanting a thorough grounding in Computer Science
Reviewer: Mike James
Python and computation - what else could go together so well?
This is a really good book provided you are the right reader. It is not a dummy's book and it isn't exclusively focused on teaching you to code in Python. This is a more general book on the ideas and practice of programming and algorithm construction - it also has a slightly academic feel to it, even though the style is casual and there are lots of encouraging words.
Don't buy this book if you are looking for a primer on Python or something that will show you the tricks of Python or how it is applied. The book uses Python 2 but this is largely irrelevant and the language takes second place to more general ideas.
It is also worth mentioning that this is the text book for the Introduction to Computer Science and Programming Using Python MOOC on edX, which is co-taught by its author John Guttag.
Chapter 1 is a vague introduction to the book and its aims. Right from the word go you are confronted with difficult and sophisticated ideas - the Church Turing thesis is explained on page 5, for example.
Chapter 2 is the usual getting started and it outlines how to use IDLE to write programs but it also deals with objects, expressions, types, branching and strings. This isn't a book for the slow or for the non-mathematically trained. You don't have to be a math genius but you certainly can't be a math denier either. This is all clearly spoken, but technical, stuff.
Chapter 3 is about numerical programs and again you need a bit of math to help you out. Here we learn about for loops and the difficulties of using floats.
Chapter 4 is we we start to learn about functions and subtle ideas such as scoping. The author uses the simplifying idea that everything is an object and all variables are references to objects. This avoids the distinction between objects and primitive types and it is simpler. Chapter 5 moves on to data structures - tuples, lists and dictionaries. Here the student has to master the idea of references and mutability.
Chapter 6 is a look at testing and debugging - the hypothesis experiment approach where you state what the program should do and work out a way to verify that it is doing it. The other side of the debugging coin is exception handling and this is covered in the next chapter.
Chapter 8 introduces the idea of object oriented programming. Classes, objects, inheritance and encapsulation. It also deals with the sort of theoretical topics that are usually ignored in learn to program books - the substitution principle for example.
From here on in the book shows its true colors and dives into computer science. We haven't been learning Python with an eye to doing anything deeply practical with it. We have been learning Python as a way of examining computer science concepts.
Chapter 9 explains, very gently the ideas of algorithmic complexity - log, linear, log-linear etc and a comparison of complexity classes. From here what could be more natural than to move on to searching and sorting.
Chapter 11 explores drawing graphs using PyLab but we are quickly back into general theory with chapter 12 and stochastic programs including statistics. Next random walks, Monte Carlo proper, experimental data and statistics.
The next two chapters bring us back to more mainstream computer science with a look at graphs - knapsack problem, disease modeling and shortest path algorithms - and dynamic programming. The final chapter takes a mad dash into the realm of machine learning - mostly clustering.
Overall this is a well-written book, but it doesn't make any attempt to drop the intellectual level. You are expected to read and think about what you are being told. Right from the start the focus is on learning Python so that you can get to grips with even more interesting ideas. Don't expect to find anything about writing your first game or graphics for fun. This is serious stuff aimed at the serious student.
The range of topics explored leans towards the statistics side of the science and it would make a good book for any student studying almost any STEM subject. Expect to learn as much about stats as computing as you progress.
As long as you are the right reader, this is the right book and comes Highly Recommended.