Programming language for physicist

Click For Summary
SUMMARY

The discussion emphasizes the importance of programming languages for physicists, particularly for running complex physical simulations. FORTRAN is identified as the standard for heavy-duty simulations, while MATLAB and Python are recommended for beginners due to their ease of use and extensive resources. C++ is also noted for its significance in computational physics. The conversation highlights that while FORTRAN is useful for large simulations, Python is a more accessible starting point for those new to programming.

PREREQUISITES
  • Basic understanding of programming concepts
  • Familiarity with scientific computing principles
  • Knowledge of numerical simulations
  • Awareness of data analysis techniques
NEXT STEPS
  • Learn Python programming, focusing on libraries like SciPy for scientific computing
  • Explore MATLAB and its applications in data analysis and simulation
  • Investigate C++ for computational physics and its advantages over other languages
  • Familiarize yourself with GNUPlot for data visualization and graphing
USEFUL FOR

This discussion is beneficial for physics students, researchers in computational physics, and anyone interested in learning programming languages relevant to scientific simulations and data analysis.

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
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
6
Views
2K
  • · Replies 36 ·
2
Replies
36
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K