Writing Scientific Software: A Guide to Good Style

Image of Writing Scientific Software: A Guide to Good Style
Author(s): 
Release Date: 
September 25, 2006
Publisher/Imprint: 
Cambridge University Press
Pages: 
316
Reviewed by: 

Not every programmer may be a scientific programmer, but all programmers will at some point have to deal with correctness, efficiency, and requirements changes, and some may have to deal with floating point, and the scaling of data sets. If so, then Scientific Software: A Guide to Good Style is for you.

The authors prioritize their concerns as follows: 1. Correctness. 2. Numerical stability (when a problem scales the algorithm doesn’t) 3. Accuracy, 4. Flexibility (i.e. if your code can’t do something the user wants, the user will use something else), and 5. Efficiency. This book will be useful all programmers, scientific and otherwise. In illuminating the importance of correctness, the authors provide a short chapter on software caused disasters, including failures with the Patriot missile, the Ariane V rocket, and the collapse of the Sleipner oil rig.

The book also provides a chapter on an analysis of floating point from the programmer’s point of view covering common pitfalls including round-off, overflow, and underflow errors. The book also has chapters on computer architecture, on software design, on data structures and software lifecycle issues, and a chapter on the comparison of languages in respect to a varying syntax of arrays.

There is also a chapter on modularization and other good programming techniques, such as avoiding global variables. There is a chapter on the pitfalls of functions, including issues with recursion, passing pointers, call by value versus call by reference, and unwanted side effects of constructors and destructors. There is a chapter on debugging and testing, a chapter on efficiency with an emphasis on matrix math (as compared to what the typical computer science student sees, i.e. sorting and searching).

Scientific Software: A Guide to Good Style covers how computer architecture can affect language efficiency, and there’s even a chapter on optimization. These last two topics are not typically covered by computer science undergrads but are essential for understanding “beneath the hood” methods of optimizing compiled computer programs. And there’s more. There are chapters on the pitfalls of memory allocation and garbage collection, on memory bugs, on memory leaks, on dangling pointers.

As well, there is a chapter that identifies sources of scientific software and Unix tools, along with a (perhaps biased) claim that Microsoft operating systems are scientific programmer unfriendly. The very last two chapters work out in detail in both C++ and FORTRAN, scientific programs using matrices.

An appendix is provided containing a review of matrices and vectors. There are numbered problems at the end of several of the chapters indicating the intent of this book for classroom instruction. Perhaps not directly in the mainstream for CS students, this book appears to be more appropriate as a secondary text for introductory courses on programming or data structures, or perhaps programming for undergraduate physics or chemistry majors although as previously noted there are several aspects of an advanced computer science nature discussed within.