Careers: Physics/Role of computer programming in physics research.
Expert: Daniel Mazur - 6/16/2009
QuestionHi Daniel,
A question related to the preparation for doing physics. Do I need to learn (as a physics student) how to program in a computer language say C# or some new language in order to solve differential equations, etc? In other words, for people who want to get into physics, is it necessary that they should have learnt to work math algorithms via computer programs?
I ask this because I read somewhere that physicists used to learn FORTRAN and other languages to do equations in 80's and 90's. Is it still so? I would have thought that we have ready-made software for these purposes now.
Thanks for answering well in advance :)
Cheers,
Siddharth
AnswerDear Siddharth,
thank you for this very interesting and useful question. The short answer is that yes, during a physics curriculum (the earlier the better, in the freshman year even) physicists should learn a programming language AND the basics of at least one specialized scientific application.
The range of the specialized software is great, in many common uses they are equivalent and your choice is usually driven more by what is easily available (pricing and licensing) rather than that one is objectively the best of them all. But that was not your question. You ask, if it is really necessary to learn a general programming language like FORTRAN to be able to do your job. Yes, it is, and the reasons are many. In principle it is possible to do science without programming knowledge, good 300 years passed since Newton's time without computers at all. But the computers are an everyday tool in science now and they are much more than clever typewriters to us.
To know a programming language is needed in order to:
1) understand the way the physical data measured are transferred and processed before they reach your graphs; many times something on the line doesn't work correctly and we need to troubleshoot, which often involves programming
2) to tweak programs, implementations of successful algorithms implemented by your predecessors years ago, when even the ready-made commercial tools were primitive and/or buggy; we inherit part of our instruments, sometimes rendered obsolete by their manufacturer, yet still fully functional. The only way to keep using them (we must, as money is always a rare resource) we must tweak their old control programs to work with new data-acquisition computer, new programming language etc.
3) in basic research almost every experimental system is in some respect unique. While a large part can be purchased with all software bells and whistles, there are always "little things" that you wish for on top of the commercially available solutions. Example: Imagine you have a temperature and pressure sensor, which work fine, but you'd like to be able to see the current values also when you are at your desk in an office two buildings away from your laboratory. There comes some serious programming to access those values (in this case probably via intranet).
4) certain types of data processing can produce artificial effects (called "artifacts" in our jargon) due to finite resolution/precision of digital data and other reasons. Ready-made commercial programs often lack documentation of the implementation of their processing functions (the Black Box approach) and trust me that differently implemented functions that "theoretically" should do the same give different result. A good example is trying to implement [f(x)-f(x+d)], where f() is the Fermi function - while theoretically the result is symmetrical about x=d/2 line, computer's result will be asymmetrical unless you implement it right. This comes down to two cases: A) the commercial Black Box gives you something that looks artificial and you need to check -> you need to run the same processing by an equivalent transparent (!) procedure; B) you need some very specialized function that is not worth the industry to hardwire (like my Fermi function difference) in a commercial scientific tool -> you program it by yourself, where you need at least a knowledge of the "scripting" language of your scientific processing tool.
5) when we apply for a scientific job, the "Computer Programming Skills" is an important section in our Resume or C.V.; this may not be a scientific reason, but it is a fact, an implication of all the reasons above.
The list could perhaps continue, but I think I put the bits down that are most important to me. There is really little difference between all the programming languages that you might consider learning. It probably pays best if you learn ANSI C and basics of C++. Scripting languages of the scientific tools (Igor, Matlab, MathCAD, Origin, SciDAVis...) often inherit the basic coding structures from C. FORTRAN is still alive, but you can put learning it off until you need it - just like Python, LabVIEW, Java,... At the same time you really should study some course on numerical methods in science. It will give you an idea of what options there are in implementing a particular task and it will also teach you about the limits of the computational methods. During your career you will need to learn more programming languages anyway depending on what is given to you by your employers.
Good luck!
Daniel