Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Choosing a programming language - physics

  1. Jul 11, 2005 #1
    If I'm going to attempt creating computer programs for simulating theories as complicated as string theory, what language should I be looking at? I have some experience with C++, but if I'm going to devote a large part of my free time to learning a language, I'd like to learn something that will be specifically useful for what I need. I'm sure this question has probably been asked before, but I didn't find any search results. Thanks in advance.
  2. jcsd
  3. Jul 12, 2005 #2
    Many of the physics type people i know, like matlab for most simulations. The best thing abt it (according to them) being that you dont have to waste time writing graphics packages. ( Otherwise ofcourse any general software development language like C/C++ or Java should help you, ofcourse the amount of effort will the relatively too much )

    -- AI
  4. Jul 12, 2005 #3


    User Avatar
    Science Advisor
    Gold Member

    I concur with that, first do as much as possible scripting in packages such as Matlab, Mathematica - "next level" could be to use subroutine libraries and programming languages in conjunction with general packages such as those 2 above (it's pretty ease to interface stuff), before going all the way and writing from scratch with C++ or any other related language (and in this case picking code from libraries etc. is highly recommendable IMHO, for getting things done as much as getting them working properly - quite a bit of the really "serious software" seems to be written in C++, in "rough" computing fortran still prospers, but would recommend you'd just go deeper with C++ if you've a handle on it).
  5. Jul 12, 2005 #4
    Thanks for the recommendations. I didn't realize C++ could be used in conjuction with Matlab/Mathematica - do you know of any sources out there that describe how to do it?
  6. Jul 12, 2005 #5
    depends on what you want to do...if youw ant to simulate in Realtime 3D i don't think matlab can support that...I've been looking for a port from matlab to C++ and vice versa if you've found one can i have it...Matlab utilizes its interface to run doesn't it? How can you export an exe?

    As for C/C++ it depends on what you want to do ..again if you want to do REALTIME 3D there are APIs out there for you to use OpenGL/Directx being the standards...also look into GLUT and SDL to maintain the active window...you could also use 3D (game) engines like Quakes/Unreal/Torque/Irrlicht/Ogre3D and it also depends on the methods you want to use for you scene management like BSPs/OCtrees/Particle mesh methods.

    There are also numerical packages out there LAPACK(think this was for fortran) but there are others NIM i think was the acronym of one...but you shouhld still learn the basic techniques in numerical methods before moving onto the pacakges.
  7. Jul 12, 2005 #6


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    For symbolic and some numerical calculations, Maple and Mathematica are good.

    If want a physics-friendly real-time 3D, with a minimal learning curve [and minimal programming overhead], try http://www.vpython.org.

    Certainly, if you need higher-performance, you can prototype in python, then port to C/C++. (Python does have some scientific library packages [e.g. SciPy, Numerical Python] and some ways to interface to C/C++ [e.g. Boost Python].)

    Oh, yeah.... Python and VPython are free and run on numerous platforms.
  8. Jul 17, 2005 #7
    If you're doing stuff that requires a lot of numerical calculations, I suggest using classic FORTRAN (i.e. FORTRAN 70). It's not really good for more than basic math computation, but it works very fast and has some neat built-in distributive computing functions (to make use of those university clusters).
  9. Jul 19, 2005 #8
    Use matlab to prototype. If you still need more speed or need to cross a platform,
    FORTRAN and C are still the fastest. For numerical work with complex vairables
    FORTRAN is better than C unless you prefer programming to physics.
  10. Jul 27, 2005 #9


    User Avatar
    Science Advisor
    Gold Member

    The Matlab external interfaces & compiler manuals are good sources (can view at mathwork site), containing the principles of interfacing with fortran, C and Java.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook