Programming language for physicist

Click For Summary

Discussion Overview

The discussion centers around the appropriate programming languages for physicists, particularly for those starting out with little to no programming experience. Participants explore various languages suitable for different aspects of physics, including simulations, data analysis, and experimental work.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants suggest that FORTRAN is a standard for heavy-duty physics simulations, but note the differences between old and modern versions.
  • Others argue that high-level languages like MATLAB, IDL, and Mathematica are preferred for analysis and plotting due to their speed and ease of use.
  • Several participants recommend starting with Python, citing its straightforward syntax and growing popularity in scientific computing.
  • Some contributors caution against learning FORTRAN as a first language, describing it as outdated and suggesting that Python is a better starting point.
  • There is mention of C++ being widely used in computational physics, with some efficient FORTRAN routines ported to it.
  • Participants highlight the importance of understanding programming concepts rather than fluency in a specific language, suggesting that learning one language can facilitate learning others.
  • LabVIEW is mentioned as a necessary tool for experimentalists, though its classification as a programming language is debated.
  • GNUPlot and Octave are suggested as useful tools for data visualization and as alternatives to MATLAB.

Areas of Agreement / Disagreement

Participants generally agree that Python is a suitable starting language for beginners, but there is no consensus on the necessity or relevance of other languages like FORTRAN, C++, or MATLAB, as opinions vary based on specific applications and personal experiences.

Contextual Notes

Some limitations in the discussion include the lack of clarity on specific fields of physics that may favor certain languages, as well as the varying definitions of what constitutes a programming language in the context of tools like LabVIEW.

Who May Find This Useful

Individuals interested in pursuing physics or related fields who are looking to learn programming for simulations, data analysis, or experimental work may find this discussion beneficial.

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
3K
  • · 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
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K