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

Help me choose a language

  1. Apr 30, 2007 #1
    Regarding programming, I'm a bloody beginner. I came in contact with BASIC as a child and learned some Pascal in high school. I never bothered to learn more, and I'm realising now how big of a mistake that was.

    So, as a little side project of my master thesis, I want to do some programming. Never mind the details, but I'd like to visualize a 1D, 2D and 3d mesh and maybe some mechanical properties between the mesh points.

    So, my question is, what programming language should I use? Which one is right for the task and practiacal enoough for me to learn? Someone suggested Python to me, because there are lots of tutorials out there. Would that be a good choice? I'm willing to buckle down and spend some time to learn how to do this computer thing but I would be even more enthusiastic, if the acquired language is actually useful for me in the future..

    Thanks a lot for your suggestions..
  2. jcsd
  3. Apr 30, 2007 #2
    and in any case go object-oriented
  4. Apr 30, 2007 #3
    sorry for stupid questions, but what's object oriented?
  5. Apr 30, 2007 #4
    OO is a software design paradigm that makes use of "objects" - which are data structures encapsulated together with methods (like complex numbers with ther operations) - that model the real world.

    At this stage, OO is a stetch. If you want to be a programmer, learn C and C++, if you want to program as a scientist, learn Mathematica and C.
  6. Apr 30, 2007 #5


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    I think Python is easier to use than Java. For me, I can more quickly whip a physics animation in 3D with Python/VPython than any other language. While Python isn't the fastest, certain features can be encapsulated in an external routines written in C or C++.

    http://www.vpython.org/ is a good visualization module, which caters to the physics student. One can worry more about the physics of the problem rather than other programming details. http://numpy.scipy.org/ is very useful. This looks like fun: http://kineticskit.sourceforge.net/

    Of course, nothing pins you down to one language. For me, when given a programming task, I sometimes decide to write it in a new language that will force me to learn aspects of the language. I started with BASIC, then Assembler, Fortran, C, Java, C++, Perl,... right now, for my work, I use Python and Maple more than any of the others.
    Last edited by a moderator: Apr 22, 2017
  7. Apr 30, 2007 #6
    It should also be known that most scientific programs are still written in fortran.
    However, a lot of OO scientific librairies are now available.
  8. Apr 30, 2007 #7


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Is this because of Fortran's long history and early widespread use?

    Are most newly-written scientific programs in Fortran?
    (By the way, here are some freeware Fortran compilers: http://www.freeware-guide.com/dir/softdev/fortran.html .)

    Hopefully, with access to the source code, those old Fortran programs can be translated into newer, more modern languages [without GOTO statements!].

    Interesting reading:
    "Choice Of Language" from (what was formerly called) "How To Write Unmaintainable Code"
  9. Apr 30, 2007 #8
    My two cents worth:

    C/C++: If you are not going to use it regularly and seriously then you will find it difficult and fustrating and inevitable programs will be bug-prone.

    Fortan: Good choice, but limited these days unless you purchase one of the top versions with GUIs etc.

    Java: Good choice as programs are more likely to be reliable owing to the OO constraints. Performs almost as well a C++ these days.

    Python: Very good choice for a part time user because it is relatively easy to pick up. Performance is slow as it is interpreted, and I mean a good order of magnitute slower at least than the other laguages mentioned here.

    Powerbasic: Very good choice also. The Windows version performs almost as well as C++ but it is much easier to learn. This is a lesser known breed of Basic but it is the best, highly versatile and with good community support. You will have to pay for it but it is worth every cent.

  10. May 1, 2007 #9
    Look at it positively, it could have been worse: you might have not realized it at all :)

    Am I to conclude that you are some sort of engineering person? In that case, for several reasons, Python is a very good choice. And let me make this claim even stronger: regardless if you would later go into some other languages which people have suggested above, you should absolutely know one swiss-army-knife, ubiquitous scripting language, that Python is.

    There is an excellent book on Python, that coveres not merely Python as such, but what you can and should use it for as an engineer or physicist: Langtangen, "Python Scripting for Computational Science".

    More generally, if in the future you intended to use programming for own custom problem-solving, then a scripting language, like Python, plus a computer algebra system, like Matlab or Maple, would make a near full complement (as robphy nicely illustrates). If you intend to work on development of computational codes, or you really come to need raw speed, than C/C++ are a must, and Fortran may be too (though I was able to dodge it so far ;)

    Chusslove Illich (Часлав Илић)
  11. May 1, 2007 #10


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    GOTO's don't make bad code. People make bad code. :tongue:
  12. May 1, 2007 #11
    robphys...can you host your physics simulations with python online? or are the animations for your own personal use to show otheres at work?

    and yeah gotos are fun.
  13. May 1, 2007 #12


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    http://www.phy.syr.edu/~salgado/software/vpython/ [Broken]

    (If you put up a webpage with http://www.vpython.org/" [Broken] applications, let me know and I will add you to my list [at the bottom of that page].)
    Last edited by a moderator: May 2, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook