Published in issue 3 of Pyzine
Oxford University has one of the biggest and most prestigious Physics departments in the UK. Aspiring physicists (and those who just want the fat pile of cash a numerate, technically-literate degree offers) come from far and wide to study here. As a part of the course, students are required to take an introductory programming course, which lasts two days.
Computer programming has been one of, if not the principal skills a professional physicist had requires since the 1960s. As experimental complexity increases, there has been an increase in the use of computer simulation. Self-written programs are often required for the appallingly complex calculations theoretical physicists undertake, and computers are used to drive many large and small experiments.
Oxford’s physics undergrads are introduced to programming using Pascal, and have been since the course was made compulsory more than ten years ago. Educational environments like the one in Oxford (where general principles rather than practical skills in a particular language are taught) have largely ignored the exodus from Pascal that was initiated by Brian Kernighan in his devastating debunk of Pascal as a serious language Why Pascal is not my favorite programming language.
The replacement of old hardware (NeXTStep systems) provided the kick up the backside the department needed to undertake a complete overhaul of the teaching of programming within the undergraduate program. Competing factions began to arise, each proposing a Pascal replacement. In the absence of any other ideas with departmental champions, it seemed increasingly likely that C (perhaps with a bit C++ thrown in just to make it even more confusing) was to replace Pascal.
At this time I was an undergraduate in the department, continuing my programming studies for voluntary credit as a part of the second and third-year practical course. I had taken the opportunity to learn C, but was appalled. Was this really the language that supposedly intelligent physicists were suggesting be used to teach a course that was already loathed by many students?
C is of course an incredibly powerful and flexible language, but using it to teach the conceptual shift in thought required to enable students to decompose problems and design algorithms seemed to be making a rod for our own back. For our purposes I saw the argument that C was widely used as a red herring. We are in the business of teaching programming, rather than the use of a particular language. In many ways, the less time spent teaching the language itself the better. Moreover, Pascal’s almost total absence from the real world hadn’t stopped us using it for ten years!
In desperation, I started looking for an alternative to avoid C being used by default. Python presented itself and, in the process of using it for a real project, I quickly became convinced that a syntactically lucid and concise language like Python was not only a realistic alternative to C, but having seen that an alternative existed at all, the idea of teaching a language as low-level as C in two days was not only unnecessarily ambitious but had the potential to scar students for life.
The computing course is run on a day-to-day basis by surprisingly receptive academic and support staff. They offered me the opportunity to create a Python equivalent of the current Pascal course and, crucially, to try it out on thirty-six real students as a part of my upcoming Masters course. At the same time, a C equivalent was designed, with the idea of running a winner-takes-all showdown between the two languages. Unfortunately, time constraints meant the C course was not ready for such a contest (although see epilogue). Would it be unfair of me to suggest that this had something to do with the language?
My course’s handbook was effectively a translation of the excellent Pascal version. Our home-brewed version of PascalTool for NeXT was replaced with IDLEfork, the development branch of the IDLE development environment, which proved entirely satisfactory.
Rumours started to circulate that a funky new language was replacing Pascal and several academic staff (typically the younger ones) offered their support. I even discovered that Python had quietly been in active use in one of our research groups for some time, which abated some of the concerns that a Python course would do little more than replace one toy language with another.
The trial of the proposed Python course was a great success. Python was (unsurprisingly) not found to be without faults as a teaching language but its strengths seemed to allow me to produce a course that increased student’s understanding of the programs they were writing and their enjoyment of programming itself. They were to be able to write larger and more general programs, raising the possibility of increasing the intellectual demand of the current course. In contrast to Pascal, Python is a growing language which is increasingly used in real academic applications. Another important but often-overlooked point in its favour is the ease with which it can be installed by a student on a student’s own Windows PC. Windows implementations of C and Pascal compilers are generally more complicated or more expensive.
The details of the trial and discussion appear in my dissertation on Python, C and Pascal’s relative merits, and don’t belong in this article. I encourage anyone with an interest in teaching computer programming (or anyone with a lot of time on their hands and a penchant for meaningless bar graphs—I had to get some quantitative work in for the dissertation to be admissible!) to take a look. It’s also worth subscribing to the excellent EDU-sig mailing list, where both general Python advocacy and details of its implementation in education are discussed.
Perhaps unsurprisingly and probably not unreasonably, the department has decided that running a course written by a graduate student in a new, trendy language like Python is too big a risk. Now the C version of the course is ready, a larger-scale trial will run next year (one hundred students will take C and one hundred Python!) and more definitive conclusions will be made. Watch this space.