|Back to 'My Vision Teaching of Computational Physics|

Further thoughts on the choice of languages

Languages

Overall aims and principles

I think it's reasonable to aim for every student to be fluent in one programming language and familiar with at least one other, so they are confident that they can pick up any language in the future.

Students should also be happy making different programs work with each other - for example, writing programs that write results to text files that are then plotted with another package.

If we intend to promote group work on computer projects, we will have to choose one main recommended language at that point.

If possible, all the software tools used should be free, so that students can put them on their own computers without cost.

We should introduce students to at least one language that prospective employers view as an asset. (eg C, C++, java, python(?))

Languages that can be run interactively are great for beginners.

We should introduce students to a programming language that we can imagine they will use as a matter of course to help their learning during their 2nd, 3rd, and 4th years.

At some point, we should introduce ideas of good programming style.

I think it would be good to introduce both Object-oriented programming as well as imperative programming. python is an attractive options since it can be used in either style.

Options

I am not religious about languages.

I have taught C, octave, and python, and would be happy with all of these. I would also be happy to learn to teach C++ or java.

C and C++ are industry standards; there are good debuggers for them; C is a stable and simple language. Down-sides of C: it's perhaps too low-level; and it has no interactive mode. Down-side of C++: it doesn't work with my favourite free interactive debugger, ups.

octave is very accessible to a novice. It does not lend itself to high quality structured programming however, nor object-oriented programming.


trace3.50

Python

python comes with many packages that provide powerful functions such as rendering. Python comes with numerical libraries, and it can interface seamlessly with software written in other languages.

It's very easy to make good-looking demonstrations that are extremely educational. For example, what happens if one mixes large spheres and small spheres in a box of small volume? (There are no potentials at all, except infinite potentials preventing overlap of spheres.) It was easy to write a 186-line program yielding the accompanying screenshots. trace20.50 Statistical physics predicts that at equilibrium all energies should be Boltzmann-distributed, independent of particle locations, and that all valid locations are equiprobable. The consequences of this uniform distribution over state space are profound: the marginal distribution of the location of the one big sphere is highly non-uniform, for example. The second figure shows where the centre of mass went during half an hour's simulation. The big sphere is very likely to be close to the wall because such locations increase the entropy of the little guys. The same simulation also gives deep insight into fluctuation-dissipation phenomena.


Computer algebra systems

I think we should introduce students to the idea that occasionally computers can help by solving algebra for us. I wouldn't make this a high priority, since I would guess that computer algebra is used by only a small minority in the Cavendish.

Maple and Mathematica are both good, but are not free.

Maxima is free. Maxima manual.

For an example of a tiny example solved in Maple and Maxima, see this page.


David MacKay
Last modified: Mon Aug 20 09:45:35 2007