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

Why not fortran?

  1. Jun 23, 2012 #1
    I am a graduate geology student and have been using MATLAB for about a year now. I began learning C a while back to have a broader tool-set to work with but found that it just got in the way of learning material more specific to my major. Besides, MATLAB does everything I need anyway.

    That being said, I do appreciate that free compilers are available for languages like C and Fortran and that they can execute models more quickly. I began to read an introductory text on Fortran the other day and it seems to be easier to learn than C. Perhaps like MATLAB, it is designed more for numerical analysis than general applications.

    My question is this: is there really any advantage for someone like me to learn C instead of Fortran? I do not plan to write programs for a living, the standard tool-set used by the USGS to model groundwater flow (MODFLOW) is already written mostly in Fortran, and C seems to have a steeper learning curve and does not seem to execute programs any more quickly.

    I am probably opening an old can of worms. I guess I am wondering why someone who works primarily with numerical analysis or modeling (in an academic sense rather than industrial) and does not plan to market themselves as a programmer upon graduation should learn C rather than Fortran. Cool tricks aside, why should C be the standard for serious numerical work rather than Fortran?

  2. jcsd
  3. Jun 23, 2012 #2


    Staff: Mentor

    C as a language is more standardized than Fortran and has more uses as a programming language. True Fortran was designed to do numerical computations well. The variations in either language you might see are in libraries on various platforms or how C would interact with a given OS (windows vs unix/linux/macosx...).

    The reality is you learn the language you need to use. If the problem you're working on references other peoples work and they used Fortran then you should use Fortran. If you're thinking of making your work available on many platforms then you might consider C/C++. If you plan to market your work on Android or make it available everywhere then you might consider Java.

    With respect to Java, the Open Source Physics project has a large collection of simulations all done in Java using the the OSP library of ODE solvers, and display components that while not the fastest is more flexible than Matlab especially if you're sharing your work with others who may not have Matlab.

    My language preference right now is Scala, touted as a better Java than Java with Object Oriented and functional programming capabilities merged together interoperating seamlessly with Java and running on the latest JVM.
  4. Jun 23, 2012 #3


    User Avatar
    Science Advisor

    Hey geouke and welcome to the forums.

    Funnily enough depending on the type of work, you have positions which are known as 'legacy programmers', which deal with working with and maintaing codebases that are written in old languages and platforms. In these cases, solid experience with something like FORTRAN or even COBOL is a requirement for getting the job.

    But the reason for using newer languages is many-fold and depends on the specific application.

    One is functionality, another is potential for optimization (very good compilers especially for specific architectures are common for something like C++ as well as FORTRAN), another is readibility, another is flexibility, another is related to development time for creating applications, another is interoperability (using specific OS functionality, communicating with other programs through things like DLL's).

    Interoperability is a very important one because nowadays, you have not only single programs using multiple libraries communicating together, but different applications in their own process space communicating together.

    Finally, and this is a very important factor, has to do with the support of a particular language/technology/operating-system/library/standard. Having something as a standard is critical. Windows is good for developers because of the sheer amount of support that it gets not only from software developers, but also from the hardware vendors themselves. This is one reason why linux wasn't a popular thing in the past, because windows had a much better driver model and framework which is really nice for hardware vendors (not to mention that windows came prepackaged with every new PC and still does which entice hardware vendors to support windows).

    When you factor all these kinds of things and the attitudes of software development as they progress and mature, you get the shift from things like FORTRAN to C++ to .NET to whatever the next generation of development environments will be.
  5. Jun 24, 2012 #4
    Yes, geouke, why not Fortran?!

    For what you have in mind, there is absolutely nothing wrong with Fortran.

    Some of the hype about teaching a particular new language at school which then drives the next generation of programmers to start writing software in another language is sometimes driven by novelty, fashion, or pure financial interest by an individual company. That's why schools, for various reasons, have gone from teaching Fortran to C to C++ to Java and now you see them including Python...talk about becoming the language of choice by your own merits without a marketing engine (Java, Sun Microsystems) behind you.

    Fortran stands for FORmula TRANslation, and it was invented to do math.

    C was invented to write Unix :-) and it is more of a systems kind of programming language.

    C++ is object oriented programming and many people were getting hit with memory leak programs, etc.

    Java was supposed to be answer to C++ problems.

    Python...well, I let you read about Python.

    In any case, in your field and in general for the sciences, Fortran is a lot more popular than the typical programmer thinks.

    There is a lot legacy code, great long standing libraries that do all sort of linear algebra and other simulation that have been around so long that are now pretty much bug free...that's were part of the value is.

    Also, typically, Fortran is more standardized than C...if somebody give a fortran library to something or there is a package out there from a given company, you can comile it along with your program and it typically incorporates a lot easier than if you were programming in C.

    Fortran, for the longest time, did not suffer of memory leaks and things like that...I don't know if that trend continues or whether with Fortran 90 and 2003 with structures, pointers and allocation...it is starting to suffer too.

    Anyway, I do program in Fortran and C...I would agree than Fortran is much simpler to learn and to program in.

    And if you would learn Python...you could do a bunch of things...if it gets numeric intensive, you always wrap your fortran code by executing f2py and simply call your fortran from python.

    Good luck.

  6. Jun 24, 2012 #5
    Thanks for all of your helpful replies!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook