Programming language for physicist

AI Thread Summary
For those entering university and looking to learn coding for physics, Python is highly recommended as the best starting language due to its straightforward syntax, popularity, and extensive online resources. It is suitable for scientific computing and allows for easy integration with other programming languages later on. While FORTRAN is traditionally used for heavy-duty physics simulations, it is not advisable for beginners due to its complexity and outdated nature. MATLAB is also suggested for its efficiency in data analysis and plotting. Other languages like C and C++ are valuable, particularly in computational physics, but may be more challenging for newcomers. Learning LabVIEW is beneficial for experimental work, while GNUPlot and Octave serve as useful tools for graphics and MATLAB alternatives, respectively. Overall, starting with Python provides a solid foundation for further programming in physics.
bigerst
Messages
56
Reaction score
0
I will be going into university this summer, and I intend to learn to code during the summer as it is important to physicist. I have virtually no programming experience. Which language is at the right level and can run complex physical simulations?

thanks
 
Physics news on Phys.org
Usually, you'll need two or more different languages to cover different purposes. The standard language for heavy duty physics simulations seems to be FORTRAN. Unfortunately, the old versions of FORTRAN are quite different from the more modern ones, and both are in use. But most of the analysis and plotting is done in some high level interactive language like IDL or MATLAB or Mathematica, since it's just so much faster to work with data. Python is rising in popularity.

If you are just starting out, then you should probably learn MATLAB. You won't need FORTRAN until you are working with huge simulations to be run on supercomputers.

Unfortunately, the languages that are often taught in University, like Java, C, Lisp, and assembly, are not used that much in physics. C is useful for everything, but it lacks the speed of FORTRAN or the conciseness of IDL.

It will also be useful to learn some sh.

Depending on your field, there might already be some dominant languages in the community. For fusion, IDL and FORTRAN are widely used.
 
Last edited:
There is no "correct" language, and what you end up using really depends on what you are doing.
Also, not all physicist need to know how to program "properly"; unless you are actually doing heavy-duty numerical simulations you only really need to know a high-level "language" such are Matlab.
If you are end up working as an experimentalist you will also need to know how to use Labview (although whether or not Labview can be seen as a progamming language depends on what you are doing)

That said, knowing how to write at least some simple programs certainly helps. I'd suggest you learn Python. It is a fairly modern language with lots of free supporting software, and it is also used in the "real world" for scientic computing (look up scipy).

I'd stay away from Fortran unless you know for a fact that you will need it. It is a horrible, outdated language and it is NOT a good first language. Once you've learned how to program in e.g. Python you can easily learn Fortran if you have to.
 
Much programming in physics is done these days in C++ and many of the efficient fortran routines mentioned below have been ported to C++. There are also data analysis and graphing packages available, like the "root" toolkit from Cern.
Python and also Perl are so called scripting languages. They are typically used to glue together the output and input of different programs.
 
Hello,

I would suggest you start with Python, which has a very straightforward syntax. Once you got the gist of it and start getting to the point where the algorithmic part is important, add C or C++ to it.

As a side, I suggest Octave, which is an opensource equivalent of Matlab, and to play with GNUPlot, which will help you with everything graphic related.

J.
 
I would agree with those who said Python. It's not difficult to learn compared to C++, and it is very popular so you can get help easily via online searches.
 
I'd also suggest starting with Python. It's free (unlike some other languages certain areas of physics use) and there are a lot of online resources to help you learn it. It's also becoming more popular in many areas of physics, and the real point of you learning a programming language isn't to be fluent in any particular language - the point is for you to get an idea of how the computer 'thinks' and how to talk to it. Once you learn one programming language, learning another is just new syntax. The hardest one is the first one.
 
Python is very forgiving and good to learn from. Together with LabView it taught me the basics of loops and such. Scilab is also ok as a freeware (windows) alternative to Matlab though the debugger is horrible, but I had to use it for a course.

I now use Fortran for modeling polarized radiative transfer daily and the transition was fairly easy, just have to be a lot more cautious.

GNUPlot is great, fast and free. Takes me on average less than 5 minutes to get something done I haven't with it before, just via googling questions or checking the manual.
 
Based on what I've been told and what I know from experience: Python and C++ are heavily used in physics. C++ is especially important in computational physics. Also, MATLAB and Mathematica (learn the differences), and LabVIEW is used a lot in experimentation. I spent a whole summer working in LabVIEW.
 
  • #10
thanks a lot for the replies!

I guess i will start with python and see where I end up :)

bigerst
 
Back
Top