1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Programming language for physicist

  1. Feb 11, 2013 #1
    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?

  2. jcsd
  3. Feb 11, 2013 #2


    User Avatar
    Science Advisor

    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: Feb 11, 2013
  4. Feb 11, 2013 #3


    User Avatar
    Science Advisor
    Gold Member

    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.
  5. Feb 11, 2013 #4


    User Avatar
    Science Advisor

    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.
  6. Feb 11, 2013 #5

    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.

  7. Feb 11, 2013 #6
    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.
  8. Feb 11, 2013 #7


    User Avatar

    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.
  9. Feb 11, 2013 #8
    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.
  10. Feb 11, 2013 #9
    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.
  11. Feb 11, 2013 #10
    thanks a lot for the replies!!

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

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook