Eight suggestions for Python books (long)

gvwilson at nevex.com gvwilson at nevex.com
Sun Jan 30 15:17:26 EST 2000


One of the most exciting things for me about the 8th Int'l Python
Conference in Washington last week was the growing number of books on
Python.  When I had to choose a language to use in a software
engineering course two years ago, I felt I had to choose Perl, because
there was so much more documentation for it than for any other Open
Source scripting language.  Last October, I finally felt that I could
switch to Python, and feedback since then has been pretty positive.

I heard several people at the conference say that they were also
excited and that they were thinking about doing a book.  That got me
thinking about what books the community really needs, and that got me
thinking about the list of unwritten books that I wrote for "Doctor
Dobb's Journal".  I started doing book reviews for DDJ a few years
ago.  After a while, I decided that the best way to get the books I
really wanted was to write the reviews first, and hope that someone
would come along and fill in the book later.  The result was posted at
http://www.ercb.com/feature/feature.0012.html, and got a very (very)
enthusiastic response from publishers, most of whom stay awake at
night trying to figure out what we're all going to want to buy a year
from now.

So, here's my first cut at what books Python needs, and why.  My main
interests are books that will help new Python programmers be
productive in a hurry, and help make Python look like a credible
solution in both academia and industry.  Your mileage may vary...

1. The Python Cookbook

The most frequent question in my classes is, "How do I do XYZ in
Python?"  Most of the time, the people asking the questions know how
to do what they wants in C or Perl; we need to make it easy for them
to find out what the answer is in Python.  The easiest way to write
this book would be to go through O'Reilly's "Perl Cookbook", throw
away those examples that exist only to help people get around Perl's
syntax and execution model, and re-write the rest in Python.

2. Algorithms and Data Structures in Python

This book complements "The Python Cookbook" by showing how classic
algorithms and data structures are implemented in Python, rather than
how to open a secure socket.  Again, the quickest way to tackle this
would be to take inspiration from books such as Orwant et al's
"Mastering Algorithms with Perl", or any of Mark Weiss's DS&A books.
One caution: remember that CPython and JPython manage memory
differently.  Try to show the best solution for each, rather than
trying to accommodate weaknesses that are specific to one or the
other.  Also try to include more theoretical analysis of algorithm
performance than Orwant et al did --- the long-term goal for this book
is to be usable in a second-year DS&A course.

3. Computer Science Python Style

Logo is to children's computing what C is to systems programming, and
Brian Harvey's three-volume series "Computer Science Logo Style" is to
Logo what Kernighan and Ritchie's "The C Programming Language" is to
C.  Anyone who wants to teach children to program, in any language,
will find "CSLS" a rich source of ideas, and a good guide to what
children (and their teachers) can actually understand.  In particular,
if anything is longer or harder to explain in Python than in Logo,
it's a good sign that an extension library is needed...

4. Software Tools in Python

Unix might not be the most widely-used operating system today, but it
has certainly been the most influential.  One reason for its success
is the ease with which different tools can be combined, and one reason
for that is that most Unix tools use a common data format: tokens
separated by whitespace, terminated by newline characters.  Another
reason was Kernighan's book "Software Tools" (and later "Software
Tools in Pascal"), which explained why and how to build small things
that did one job well.

The advent of XML means that there is now another universal data
format that a wide variety of tools could operate on.  Unlike flat
text, this format is hierarchical, but the principle of connecting
many tools together using pipes is still the same.  That raises three
questions: what are the equivalents of 'wc', 'head', 'grep', and 'sed'
for tree-structured data, what language will those tools be written
in, and who is going to write the best-selling book that explains all
of this?  As with (3) above, a lot of work would have to be done on
software to make this book possible, but anyone thinking about writing
usable XML filters in Python would do well to think about how to
explain them before laying down any code.

5. Case Studies in User Interface Design

Some philosophers distinguish between knowing that, and knowing
how. The former is mostly facts, such as the airspeed of an unladen
African swallow. The latter consists of techniques, like how to ride a
bicycle, or how to design a user interface. Unfortunately, knowledge
of the second type is hard to put into books, since every general rule
has exceptions, and none of the important ideas can be given exact
definitions.

This book on user interfaces would try to teach the "how" by working
through a series of examples. The starting point for each would be
either an existing interface that needs improvement, or a set of
requirements and a blank canvas.  Each design would be iterated
several times, or try to satisfy different constraints (e.g. hand-held
vs. desktop platforms).  The focus would not be on Python per se, but
implicit in the book would be the message that Python facilitates
rapid experimentation, prototyping, and evolution.

6. C for Python Programmers

As many people have pointed out, Python is an excellent teaching
language.  It runs almost everywhere, is used in industry, is
object-oriented, and checks for a lot of simple errors, including bad
type casts, dangling pointers, and out-of-bounds array indices.  If
Python becomes widely used in grade schools, and if highbrow features
like generic programming and type inference are added, it will start
to look very attractive as a college-level language.

The problem, however, is what to do with students in their second
year. As a sophomore, I took two courses: one on data structures and
algorithms, and one on machine architecture and assembly-language
programming. The first is easy to translate into Python, but what
about the second? Going from Pascal to PDP-11 assembler was bad
enough; going from an interpreted, garbage-collected language to
today's pipelined RISC architectures would be impossible.

This book's premise would be that C has always really been a
high-level assembly language, and that we should teach it to students
in relation to Python as we taught assembler in relation to Pascal. It
would show readers how to build a simple Python interpreter using C,
and would cover pointer arithmetic and array indexing, allocating and
freeing memory, garbage collection, signed vs. unsigned arithmetic,
and machine-dependent data sizes. Along the way, students would be
introduced to the quirks of C, including the use of preprocessor
directives to handle platform-dependent code.  By the time they were
done, students would be ready to tackle higher-level courses in
networking, operating systems, computer graphics, and other topics.
They would also have learned how to structure complex software systems
in layers and modules, and how to deal with a variety of real-world
software engineering issues.

(Note that this book would teach C, rather than C++, so that students
would learn what computers really do --- C++ sweeps far too much under
the rug for this purpose.)

7. Object-Oriented Analysis and Design Using Python and UML

The aim of this book is to teach analysis, design, and patterns as if
they were as important as language syntax or basic data structures.
The book would be aimed at sophomores who have learned an
object-oriented language (not necessarily Python) in a first-year
course. It would introduce both the idea of design patterns, and the
basic elements of the Unified Modeling Language (UML), and then show
how to apply both to a variety of web-enabled applications.  The
emphasis of the book would be how to analyze a problem methodically,
and how to design a program, or set of programs, to meet users'
needs.  Liberty's "Beginning Object-Oriented Analysis and Design", and
Rosenberg and Scott's "Use-Case Driven Object Modeling with UML",
would both be good inspirations, but in order to really be successful,
this book would have to include many more examples, sample questions,
and back-of-the-book answers than either.

8. Software Tools for Scientists and Engineers

I have a confession to make.  I sat down to start writing this book
four years ago, and found that I couldn't, because existing software
engineering tools were so hard to learn.  I found out the hard way
that most scientists and engineers have better things to do with their
time (like science and engineering) than learning how to write
non-trivial makefiles, or re-installing Gnats.  They're not stupid ---
many of them really are rocket scientists --- but they can tell the
difference between intrinsic and accidental complexity, and don't have
a lot of respect for how much of the latter there is in modern
computing.

The aim of the Software Carpentry project (www.software-carpentry.com)
is to create tools that are worth describing.  If it succeeds, I hope
that someone will take those tools, and Python itself, and use them to
show computational scientist and engineers how to capture software
requirements, write up designs, create test plans, accommodate special
features of different platforms, and everything else that makes up the
"other 90%" of programming.

----------------

Greg Wilson is an independent software developer and author.  He is
currently managing the Software Carpentry project on behalf of Los
Alamos National Laboratory and CodeSourcery, LLC.  You can find out
more about the project at http://www.software-carpentry.com, or reach
Greg at gvwilson at nevex.com.


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list