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

Why do you need FORTRAN, C, C++ for physics

  1. Nov 13, 2013 #1
    Okay I get that FORTRAN was made for science and C AND C++ are fast but why do you have to know one of them? (or so I heard). Thanks for any help.
     
  2. jcsd
  3. Nov 13, 2013 #2

    Vanadium 50

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor

    Why do you need more than just a hammer in your toolbox?
     
  4. Nov 14, 2013 #3
    the and was supposed to be lowercase sorry. But I meant why those specific languages?
     
  5. Nov 14, 2013 #4

    jedishrfu

    Staff: Mentor

    FORTRAN came about first for scientific applications and later COBOL was developed for business.

    C was the defacto language for Unix machines and was being used as a cross hardware platform assembly language as newer CPUs came on the market. At one time, Unix machines had a feature that would take C source code transmitted over the network, compile it and update the executable, saving it whereever you wanted which was subsequently disabled when a college student created one of the first worms that infected 6000+ machines (http://en.wikipedia.org/wiki/Morris_worm).

    C++ piggybacked on C (and literally too: where code was translated by the CFRONT program from C++ into C code and then compiled) introduced OO concepts to the UNIX world and became the preferred choice over Objective-C which was proprietary at the time and SmallTalk the first OO language.

    SmallTalk while popular in OO research wasn't adopted for mainstream OO due to the limitation of coding in an IDE like environment where you could change anything in the SmallTalk core and where you had to export the whole workspace to someone else's machine for them to run your program. and they in turn had to import it and hope it didn't change something they had altered.

    Given those choices FORTRAN, C and C++ survived to the present day.

    So if you were writing a computer simulation of some physical problem you'd choose FORTRAN because of the large body of supporting libraries. Later as Unix got more popular you would choose C because it was available on more machines more so than FORTRAN. If you were a CompSci person you'd write it in C++ for greater modularity.

    ADDENDUM: Matlab and Java are now taking over as the preferred languages for simulation. Matlab is primarily used by engineering students who then want to use it when they get a job (smart marketting on Matlabs part).

    Java for many reasons: students learn it, its easier to learn than C++, runs cross-OS and cross-HW including Android HW has a lot of library support including the Open Source Physics library of methods and ODEs.
     
    Last edited: Nov 14, 2013
  6. Nov 14, 2013 #5
    Thanks
     
  7. Nov 14, 2013 #6
    Yeesh, let's hope that's not true. Matlab is proprietary and Java is ill-suited to scientific computation.
     
  8. Nov 14, 2013 #7

    jedishrfu

    Staff: Mentor

    but it is true...

    and the future of Java appears to be heading toward Scala and its syntactical sugar, scriptability and its model of OO + Functional Programming...
     
  9. Nov 15, 2013 #8
    Good, all the new JVM languages (Scala, Clojure, JRuby, etc.) will allow some of the good parts of the Java ecosystem to survive (the JVM itself*, the "cross-platformness") while marginalizing the fundamentally broken part: Java the language.

    * Footnoted because one can definitely make the argument that the JVM class loader is a bit of a disaster.
     
  10. Nov 16, 2013 #9
    I would have thought that mathamatica and fortran/c++ would be more popular than java+matlab. matlab is very limited and has terrible graphics and java just isn't anyone I knows' cup of tea. That was the first OO language me and my friends learned and we all changed soon after.
     
  11. Nov 16, 2013 #10

    jedishrfu

    Staff: Mentor

    Many engineering firms use MATLAB more than Mathematica and buy into the MATLAB libraries as well. Its an expensive solution but MATLAB supports them and that make the firms feel more secure. In addition, MATLAB can interface with Java code although not seamlessly and with C code.

    You will find out more about this when you get out of academia.
     
  12. Nov 16, 2013 #11
    I'm not even in academia yet, thanks for the help.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Why do you need FORTRAN, C, C++ for physics
  1. C to fortran (Replies: 9)

  2. How do you compile C? (Replies: 5)

Loading...