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!

Programing language for quantum mechanics, optics or plasma.

  1. Jul 25, 2012 #1
    Hi, i'm student of physics, i want to specialize in the areas of optics, quantum mechanics or plasma, but i want give an approach computational physics, therefore, my question is, which programing language is advisable for these areas of physics?. The options that most i read were fortran, C, C++, phyton; also, specialized software in numeric calculus such as matlab, mathematica, maple, etc.

    Thank you for your answers, i want choose the better option.

    P.S: I have basic knowledge about C.
  2. jcsd
  3. Jul 25, 2012 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I would say that it really depends on the specific application. For a quick analysis or simulation where you want to be able to play around and quickly change parameters of a system, esp. one that requires generating some sort of visualization (plots etc.), it's definitely handy to know MATLAB, or Mathematica, or Maple, with different people advocating each one, according to personal preference. If I recall correctly, Maple (and I think Mathematica?) can do symbolic algebra, whereas MATLAB cannot? (But there may be some sort of MATLAB add-on module for that). On the other hand, I think that python is starting to supplant these three as a quick and versatile higher-level language that is equally powerful in terms of available visualization tools, and has the advantage of being cross-platform, open-source, and free of charge.

    On the other hand, if you're creating a complicated data analysis pipeline, there are some other considerations that enter in, including: 1. you want it to run fast, and 2. you want to be very very sure that you know what's going on numerically, and can avoid common numerical errors. For these reasons, I know of a few examples where data analysis pipelines are written in C or a similar language. There are all sorts of library packages for scientific data analysis in C (and FORTRAN too) each specific to a certain type of mathematical analysis (e.g. linear algebra, or fast Fourier transforms, or numerical integration, or ...)

    Unfortunately, you can't get away with knowing only one language and using it exclusively, I don't think. One the other hand, if you invest the time to learn how to *program well* in one language, the marginal cost of learning the syntax for another is less. Personally, I use C regularly, and I've started to use python for some stuff. In the past, I've used MATLAB and IDL. (I've also used Mathematica and Maple, but only because each was required for a particular undergraduate assignment). I know nothing about FORTRAN and don't wish to touch it with a 10-ft pole. But I know that some people will strongly disagree with me and extoll its merits above C.
    Last edited: Jul 25, 2012
  4. Jul 25, 2012 #3


    User Avatar
    Science Advisor

    My advice is that you need to know:

    (1) One symbolic/visualization tool - Mathematica, MATLAB, or Maple. Personally I use Mathematica.

    (2) One quick to write, interpreted language. I strongly recommend Python.

    (3) One compiled "number crunching" language. This should be either C or Fortran, and as cepheid said, you will find proponents of both. If you already know C, I would recommend you stick with that. I thought that Fortan was dying in favor of C, but I no longer think that. Lots of people are still using Fortran, and many swear that it is much easier to learn and debug than C.

    My experience is that most technical computing today is written with a Python wrapper which does the file handling and plotting stuff, and calls compiled components written in either C or Fortran for the computationally intensive pieces.
  5. Jul 25, 2012 #4
    You use whatever language the people around you use, and then you learn enough CS so that you can switch whatever language it is.
  6. Jul 25, 2012 #5


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Excellent advice. One of the worst things a physics grad student can do is to focus on coding instead of physics. And even if you do insist on getting heavily into programming, understanding computer science better really has very little to do with learning more languages. Languages are interchangeable. They all do pretty much the same thing.
  7. Aug 15, 2012 #6
    You should focus less on which language you learn, and more the methods that are used to solve the complicated problems that need computers, as well as their pseudo-code implementation. In other words, you should be able to write in (engineering/physics) english how you will solve a problem.

    I've worked in computational plasma physics as a graduate student for over a year and a half now, and I rely heavily on Python and MATLAB. If you want to do something relatively complicated (something it would take one person ~1 month to do) then C/C++ come in very handy. Anything that is extremely complex though (modeling a whole system) will require a code that has been developed for many years (even decades). L3 has a code as well as the Air Force Research Lab.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook