We share with you and interview with scientist, professor and author Hans Petter Langtangen about his well known book A Primer on Scientific Programming with Python. We delve into the story behind the book, future plans and, as always, the importance of free/libre software in science. On to the interview!
F4S: Hello Hans. Please, give us a brief introduction about yourself.
I am a professor of mathematical modeling at the University of Oslo, but for the last 10 years I have been on 80% leave to work at Simula Research Laboratory, which carries out long-term basic research in ICT. At Simula, my main responsibility is to be the manager of a Norwegian Center of Excellence, named Center for Biomedical Computing. Our aim is to develop mathematical methods and software tools to study biomedical phenomena and thereby help clinicians in improving diagnostics and treatment. I am an active scientist and participate in several of the center’s projects. More information is found on cbc.simula.no.
F4S: How did you get involved with open source software?
In the 1990s I was one of two developers of the Diffpack programming environment (diffpack.com) for numerical solution of partial differential equations. Diffpack was commercialized in 1997 and I worked closely with the company that developed and distributed Diffpack. My experience with commercializing Diffpack led me to the belief that the open source software model was better model for development and distribution of such advanced mathematical software. The software itself can benefit greatly from openess, while the competence needed to apply it to solve particular industrial problems is naturally offered in a commercial setting.
F4S: Tell us the story behind your book A Primer on Scientific Programming with Python.
At the University of Oslo, we started reforming science education in 2003. Our reform consist in using numerical methods and programming as basic tools in science courses, from day one in the programs at the bachelor level. The students must then learn to program, and to solve mathematical problems via programming, when in the very first semester. Before 2007, our first programming course, given by computer science professors, taught Java in the context of examples with no mathematical content. Such a standard course is not well suited for introducing the computer as an effective tool to solve mathematical problems. Therefore, we decided to design a new course tailored to the needs in the reform. We wanted to use a high-level language, much because of the huge success Matlab, Octave, Scilab, IDL, and R have had in computational science. Moreover, we wanted to teach “Matlab-style” programming as well as Java/C++-style object-oriented programming. Python, with its growing popularity and support for scientific computing, was then the language of choice. We needed a book that reflected the contents of the course: learn Python in the context of solving mathematical problems. As such a book was not available, I decided to write it.
F4S: Who will benefit from reading it?
The book and the corresponding course were designed for beginning students. However, the book goes quite deep into Python and various programming styles and tools, so it has become popular also among graduate students, scientists and engineers. I would say that anyone who is not already an experienced programmer and who needs to program to solve mathematical problems, will benefit from reading this book.
F4S: How will you describe your experience writing the book?
The book was born and written in very busy times. Since the course was to be launched in the fall semester of 2007, a first draft of the book had to be available by then. Such deadlines are effective. Afterwards, I used the experience from the teaching in 2008 to adjust the draft and rewrite sections. The final version was submitted and printed in 2009. The tight coupling of writing the book and using the material in teaching, with much feedback from students, resulting in an efficient book writing project.
F4S: Do you have plans for other books?
There are several vague plans. First I will need to make a 4th edition of a book on Python scripting, i.e., use of Python for doing administrative tasks related to computational science. One specific book project is to make a light version of the “Primer book” that is better suited for a short course on Matlab-style programming with Python for students in their 3rd or 4th year at the university. It seems to be a great need for such a book. Then I plan to write a book numerical solution of partial differential equation via finite difference and element methods with emphasis on developing associated software using a combination of modern tools like Python, Cython, NumPy, SymPy, C++, and existing numerical libraries.
F4S: Why is free/libre open source scientific software important for your field?
I see four reasons. First, open code means that what you compute is documented in every detail. People can inspect the code to see exactly what the mathematics behind the calculations is. Moreover, the quality of the code, including layout, design and testing, becomes much improved when the source is open. All these features are essential for reliable and reproducible science. Second, open source code invites other people to test it. This is an important point where open source is likely to lead to higher reliability of the calculations compared to closed source. Third, open source code invites people to contribute to further development, either of the code itself or applications built on it. Both contributions are of great importance. And fourth, open source code gives more visibility of the group behind it than closed source, a fact that also provides explicit credit for comprehensive work with scientific software.
F4S: Which projects, blogs or sites related to open source software for science can you recommend?
There are far too many very useful sites than what can be explicitly mentioned here. Let me instead emphasize the importance of project hosting sites like github.com, bitbucket.org, launchpad.net, code.google.com, and similar. These sites host open source code projects with associated discussion fora, mailing lists, and other services for social interactions. The impact of such sites on promoting, developing and using open source software is fundamental.
F4S: Where people can contact you?
- Email: firstname.lastname@example.org
- Homepage: http://folk.uio.no/hpl, Hans Petter Langtangen at Facebook and LinkedIn.
Hans Petter Langtangen
F4S: Hans, thank you for letting us know more about you and your book.
A Primer on Scientific Programming with Python