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 for physics

  1. Apr 7, 2007 #1
    I'm thinking of continuing my education in physics(I'm half way through my master, then getting my Ph.D).
    My question should I know more programming language or be an 'expert' in a chosen few?And how important would it be?
    I know average c/c++(don't study it anymore), and average Matlab(learning it right now).
    Programming was never a problem to me, I like it and very good at it, my problem is practice, so pretty much I can handle anything thrown at me.
    Any recommendations?
  2. jcsd
  3. Apr 8, 2007 #2


    User Avatar
    Staff Emeritus
    Science Advisor

    One should certainly be somewhat proficient at programming and use of computer programs/languages. These days, there are many commerical programs, so one really only needs to understand the input/output and how to use special functions/features. On the other hand, some programs may be deficient in some models, so it is beneficial to be able to develop the model and program it oneself.

    Programming (or writing code) is absolutely necessary for a computational physicist and experimentalist, if the latter wishes to be able to model an experiment.

    The ability to do a simulation (numerical model) is a great skill to have.
  4. Apr 8, 2007 #3
    So what I understand from you, that it's not that important to know a lot or be an expert as long I have certain abilities in general..
    But I have a question, putting on my application to grad schools, that I'm an average programmer in what I stated above, should be enough ?
  5. Apr 8, 2007 #4
    I don't really think its what language you know, if you have problem solving skills is whats important. You can solve a problem with pencil and paper.

    if you can design a good method on implementing the program, then programming itself should be trivial, its just syntax.
  6. Apr 8, 2007 #5
    That What I was thinking, I believe I have that skill.
    Sometime ago my prof gave me a series of programs in Qbasic and asked me to transform them into Matlab, it took me more time to type them in matlab then it took me to read about Qbasic syntax and to understand the code itself.
    Came to think of that, I feel if you know one language the rest is easy, it's just translation, like different accents of English.
  7. Apr 8, 2007 #6
    Exactly, going from a procedural language to a concurrent language is a little different though but you won't have to worry about that as a physics major.
  8. Apr 8, 2007 #7
    Thank you a lot
  9. Apr 8, 2007 #8
    I personally believe it is important for any scientist to be proficient in at least one programming language. For that which any researcher wishes to write an advanced program, it would be difficult to convey to a general programmer all that is required in terms of the science and the mathematics involved. The downside is that no scientist is likely to create his or her program using good software engineering practices, making it difficult for others to work with the product.

    C and Fortran are the two mainstays of the procedural or imperative paradigm, while far more work would be required in any C++ effort, it being of the object-oriented paradigm.

    Depending on the complexity of the work, you may also wish to consider writing any Fortran, C or C++ program with parallel computing in mind. For example, look at Message Passing Interface (MPI) and how Fortran, C or C++ can interface with it for implementation on a multi-processor system or supercomputer. Good luck.
  10. Apr 8, 2007 #9
    I was thinking of learning Fortran, I know it's old, but I see it's still widely used..
    The reason I asked this, because I was thinking of taking some more C++ training, to be more proficient..
  11. Apr 8, 2007 #10
    To be proficient in C++, you need to understand object-oriented design (OOD). If you seek additional training for C++, seek it in OOD.

    My personal favorite object-oriented programming language is Smalltalk, but there you program and execute your program within an environment that may not be portable. Smalltalk is easy in which to program, and the programs are readable and understandable by even non-programmers. To my knowledge, however, it does not lend itself to parallelism.

    Fortran, C or C++, however, is compiled into an executable that can be run on almost any computer, and is therefore more portable.

    For a non-programming professional, my recommendation is to concentrate your efforts in C. You can quickly go through a book on good programming practices in C and be far more productive with less effort than you would in C++.

    Fortran remains a good language, but I suggest you make a choice between C or Fortran. Many similar programming constructs are different in the two, and why confuse yourself and waste valuable time tracking down bugs when that time could be devoted to your research.

    The differences between C and Fortran that can trap unwary programmers are many, too many to enumerate here. Each language has its own learning curve. Since you started with C, stay with C, until such time at least that there is a compelling need to work with Fortran or some other language.
  12. Apr 8, 2007 #11
    Ok I understand what you are saying.
    It will be C then.(I'll try to look at (MPI) in c)
  13. Apr 8, 2007 #12
    There are numerous MPI manuals downloadable from the WWW. For example, http://docs.sun.com/app/docs/doc/805-1556?a=load [Broken]
    Last edited by a moderator: May 2, 2017
  14. Apr 8, 2007 #13
    It doesn't look easy at all, but the manual seem to provide a good level of help, and I think I'll check my library and my university library if I can find anything more advanced on C and on MPI.
    Thank you very much for your help.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook