Picking a language

One of the thorniest questions in the teaching of physics at degree level, is which computer language to teach. There is no consensus on this, and I am not sure that there will every be. Getting everyone to agree on the best computer language to teach at first year would be harder than getting everyone to agree on a favourite ice-cream flavour. However hard you tried there would always be one person holding out for pistachio.

There are two problems. The first is that no language is perfect, all languages have some weaknesses. They all have at least one thing that is clunky, easy to mess up, and not intuitive. The second is that some properties of a language are a strength from one viewpoint, but a weakness from another. Computer languages are like knives, just like a bread knife is great for slicing a bread but would be clumsy for peeling an apple, a computer language is typically great at some things, less great at others.

At the moment we teach mainly Fortran, which has strengths: simple to learn, fast, ideal for custom number crunching, and weaknesses: input/output is a bit limited, plotting has to be done separately, and there are no native packages to do standard tasks. A quick survey of universities in the south east shows that Kent also teaches Fortran, while Queen Mary teaches C++, and Southampton, Sussex and Royal Holloway teach python.

As I said at the start, there is no consensus. If you, for example, Google “python vs C” or similar, you’ll get hundreds of pages debating the pros and cons of the two languages.

We are currently debating switching to python. Python has advantages and disadvantages, it is better at pulling in data, plotting, and has an enormous range of packages to help do many standard tasks, but is slow so is not suitable for heavy duty computational physics. I would vote for switching from Fortran to python. The switch has advantages and disadvantages, but I think for most students python will be more useful.

For most of what they want to do, typically light data analysis and simple computations, python should enable them to get a code up and running faster than Fortran. Also, python is very widely used outside of science, so for our many students who get data jobs outside of science, it would help them. If we teach python at first year, students who go into computational physics will have to learn C or Fortran as well, but no choice of first-year language is perfect.

Some of the debate has been about which language is best for helping students learn how to translate a science problem into a code that will give answers. There are many many languages out there, Wikipedia’s list goes from A#.NET to ZPL, and students we teach now may end their careers in the second half of this century coding in languages not yet invented.

So we should try and teach students skills that are independent of any one language, but it is not really clear to me what language is best for teaching these skills. Python here is probably as good as any, if taught in the right way. So I would say that this should not be a big factor in the decision, but I guess some will disagree with that — as I said there is no consensus on computer languages, in the department or on the web.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s