Should Fortran be taught to Undergraduates?

June 10th, 2009 | Categories: Fortran, programming, python | Tags:

Back in 1997 I was a 2nd year undergraduate of Physics and I was taught how to program in Fortran, a language that has survived over 40 years due to several facts including

  • It is very good at what it does.  Well written Fortran code, pushed through the right compiler is screamingly fast.
  • There are millions of lines of legacy code still being used in the wild.  If you end up doing research in subjects such as Chemistry, Physics or Engineering then you will almost certainly bump into Fortran code (I did!).
  • A beginner’s course in Fortran has been part of the staple diet in degrees in Physics, Chemistry and various engineering disciplines (among others) for decades.
  • It constantly re-invents itself to include new features.  I was taught Fortran 77 (despite it being 1997) but you can now also have your pick of Fortran 90, 95, 2003, and soon 2008.

Almost everyone I knew hated that 1997 Fortran course and the reasons for the hatred essentially boiled down to one of two points depending on your past experience.

  • Fortran was too hard!  So much work for such small gains (First time – programmers)
  • The course was far too easy.  It was just a matter of learning Fortran syntax and blitzing through the exercises. (People with prior experience)

The course was followed by a numerical methods course which culminated in a set of projects that had to be solved in Fortran.  People hated the follow on course for one of two reasons

  • They didn’t have a clue what was going on in the first course and now they were completely lost.
  • The problems given were very dull and could be solved too easily.  In Excel!  Fortran was then used to pass the course.

Do you see a pattern here?

Fast forward to 2009 and I see that Fortran is still being taught to many undergraduates all over the world as their first ever introduction to programming.  Bear in mind that these students are used to being able to get interactive 3D plots from the likes of Mathematica, Maple or MATLAB and can solve complex differential equations simply by typing them into Wolfram Alpha on the web.  They can solve problems infinitely more complicated then the ones I was faced with in even my most advanced Fortran courses with just a couple of lines of code.

Learn Fortran – spend a semester achieving not very much

These students study subjects such as physics and chemistry because they are interested in the subject matter and computers are just a way of crunching through numbers (and the algebra for that matter) as far as they are concerned.  Despite having access to untold amounts of computational and visualisation power coupled with easy programming languages thanks to languages such as MATLAB and Python, these enthusiastic, young potential programmers get forced to bend their minds around the foibles of Fortran.

For many it’s their first ever introduction to programming and they get forced to work with one of the most painful programming languages in existence (in my opinion at least).   Looking at a typical one-semester course it seems that by the time they have finished they will be able to produce command line only programs that do things like multiply matrices together (slowly), solve the quadratic equation and find the mean and standard deviation of a list of numbers.

Not particularity impressive for an introduction to the power of computation in their subject is it?

Fortran syntax is rather unforgiving compared to something like Python and it takes many lines of code to achieve even relatively simple results.  Don’t believe me?  OK, write a program in pure Fortran that gives a plot of a Sin(n*x) for integer n and x ranging from -2*pi to 2*pi.  Now connect that plot up to a slider control which will control the value of n.  Done?  Ok – now get it working on another operating system (eg if you originally used Windows, get it to work on Mac OS X).

Now try the same exercise in Python or Mathematica.

This is still a very basic program but it would give a much greater sense of achievement compared to finding the mean of list of numbers and could easily be extended for more able students (Fourier Series perhaps).  I believe that many introductory Fortran programming courses end up teaching students that programming means ‘Calculating things the hard way’ when they should be leaving an introductory course with the opposite impression.

Learn Fortran – and never use it again.

Did you learn Fortran at University?  Are you still using it?  If you answer yes to both of those questions then there is a high probability that you are still involved in research or that advanced numerical analysis is the mainstay of your job.  I know a lot of people in the (non-academic) IT industry – many of them were undergraduates in Physics or Chemistry and so they learned Fortran.  They don’t use it anymore.  In fact they never used it since completing their 1st semester, 2nd year exam and that includes the computational projects they chose to do as part of their degrees.

The fact of the matter is that most undergraduates in subjects such as Physics end up in careers that have nothing to do with their degree subject and so most of them will never use Fortran ever again.  The ‘programming concepts’ they learned might be useful if they end up learning Java, Python or something along those lines but that’s about it.  Would it not be more sensible to teach a language that can support the computational concepts required in the underlying subject that also has an outside chance of being used outside of academia?

Teach Fortran – and spend a fortune on compilers

There are free Fortran compilers available but in my experience these are not the ones that get used the most for teaching or research and this is because the commercial Fortran compilers tend to be (or at least,they are perceived to be) much better.  The problem is that when you are involved with looking after the software portfolio of a large University (and I am) then no one will agree on what ‘the best’ compiler is.  (Very) roughly paraphrased, here are some comments I have received from Fortran programmers and teachers over the last four years or so.

  • When you teach Fortran, you MUST use the NAG Fortran compiler since it is the most standards compliant.  The site license allows students to have it on their own machines which is useful.
  • When you teach Fortran, you MUST use the Silverfrost compiler because it supports Windows GUI programming via Clearwin.
  • We MUST avoid the Silverfrost compiler for teaching because it is not available on platforms such as Mac and Linux.
  • We MUST avoid the NAG compiler for teaching because although it has a great user interface for Windows, it is command line only for Linux and Mac.  This confuses students.
  • If we are going to teach Fortran then we simply MUST use the Intel Fortran Compiler.  It’s the best and the fastest.
  • We need the Intel Fortran Compiler for research because it is the only one compatible with Abaqus.
  • A site license for Absoft Fortran is essential.  It’s the only one that will compile <insert application here> which is essential for my group’s work.
  • We should only ever use free Fortran compilers – relying on commercial offerings is wrong.

I’m only getting started!  Choose a compiler, any compiler – I’ll get back to you within the week with an advocate who thinks we should get a site license for it and another who hates it with a passion.  Let’s say you had a blank cheque book and you gave everyone exactly what they wanted – your institution would be spending tens of thousands of pounds on Fortran compilers and you’d still be annoying the free-software advocate.

Needless to say, most people don’t have a blank cheque book.  At Manchester University (my workplace) we support 2 site-wide Fortran compilers

  • The NAG Compiler – recommended for teaching.
  • The Intel Fortran Compiler – recommended for research

We have a truly unlimited site license for NAG (every student can have a copy on their own machine if they wish) which makes it perfect from a licensing point of view and many people like to use it to teach.  The Widows version has a nice GUI and help system for example – perfect for beginners.  There are Mac and Linux versions too and although these are command-line only, they are better than nothing.

The Intel Fortran Compiler licenses we have are in the form of network licenses and we have a very limited number of these – enough to support the research of every (Windows and Linux) Fortran programmer on campus but nowhere near enough for teaching.  To get enough for teaching would cost a lot.

There are also pockets of usage of various other compilers but nothing on a site-wide basis.

Of course, not everyone is happy with this set-up, and I was only recently on the receiving end of a very nasty email from someone because I had to inform him that we didn’t have the money to buy his compiler of choice.  It’s not my fault that he couldn’t have it (I don’t have a budget and never have had) but he felt that I was due an ear lashing I guess and blamed all of his entire department’s woes on me personally.  Anway, I digress….

The upshot is that Fortran compilers are expensive and no one can agree on which one(s) you should get.  If you get them all to please (almost) everybody then you will be very cash poor and it won’t be long before the C++ guys start knocking on your door to discuss the issue of a commercial C++ compiler or three….

Learn Fortran – because it is still very useful

Fortran has been around in one form or another for significantly longer than I have been alive for a very good reason. It’s good at what it does. I know a few High Performance Computing specialists and have been reliably informed that if every second counts in your code execution – if it absolutely, positively, definitely has to run as fast as humanly possible then it is hard to beat Fortran. I take their word for it because they know what they are talking about.

Organisations such as the Numerical Algorithm’s Group (NAG) seem to agree with this stance since their core product is a Fortran Library and NAG have a reputation that is hard to ignore.  When it comes to numerics – they know their stuff and they work in Fortran so it MUST be a good choice for certain applications.

If you find yourself using research-level applications such as Abaqus or Gaussian then you’ll probably end up needing to use Fortran, just as you will if you end up having to modify one of the thousands of legacy applications out there.  Fortran is a fact of life for many graduate students.  It was a fact of life for me too once and I hated it.

I know that it is used a lot at Manchester for research because ,as mentioned earlier, we have network licenses for Intel Fortran and when I am particularly bored I grep the usage logs to see how many unique user names have used it to compile something.  There are many.

I am not for a second suggesting that Fortran is irrelevant because it so obviously isn’t.  It is heavily used in certain, specialist areas.  What I am suggesting is that it is not the ideal language to use as a first exposure to programming.  All of the good reasons for using Fortran seem to come up at a time in your career when you are a reasonably advanced programmer not when you first come across the concepts loops and arrays.

Put bluntly I feel that the correct place for learning Fortran is in grad school and only if it is needed.

If not Introductory Fortran then Introductory what?

If you have got this far then you can probably guess what I am going to suggest – Python.  Python is infinitely more suitable for beginner programmers in my opinion and with even just a smattering of the language it is possible to achieve a great deal.  Standard python modules such as matplotlib and numpy help take care of plotting and heavy-duty numerics with ease and there are no licensing problems to speak of .  It’s free!

You can use it interactively which helps with learning the basics and even a beginner can produce impressive looking results with relatively little effort.  Not only is it more fun than Fortran but it is probably a lot more useful for an undergraduate because they might actually use it.  Its use in the computational sciences is growing very quickly and it also has a lot of applications in areas such as the web, games and general task automation.

If and when a student is ready to move onto graduate level problems then he/she may well find that Python still fulfills their needs but if they really do need raw speed then they can either hook into existing Fortran libraries using Python modules such as ctypes and f2py or they can roll up their sleeves and learn Fortran syntax.

Using Fortran to teach raw beginners is a bit like teaching complex numbers to kindergarten children before they can count to ten.  Sure, some of them will need complex numbers one day but if it was complex numbers or nothing then a lot of people would really struggle to count.

So, I am (finally) done.  Do I have it all wrong?  Is Fortran so essential that Universities would be short changing students of numerate degrees if they didn’t teach it or are people just teaching what they were taught themselves because that’s the way it has always been done?  I am particularly interested in hearing from either students or teachers of Fortran but, as always, comments from everyone are welcome – even if you disagree with me.

If you are happy to talk in public then please use the comments section but if you would prefer a private discussion then feel free to email me.

(I am skating closer to my job than I usually do on this blog so here is the hopefully unnecessary disclaimer.  These are my opinions alone and do not necessarily reflect the policy of my employer, The Univeristy of Manchester.  If you find yourself coming to me for Fortran compiler support there then I will do the very best I can for you – no matter what my personal programming prejudices may be.  However, if you are up for a friendly chat over coffee concerning this then feel free to drop me a line. )

  1. Ian Cottam
    June 10th, 2009 at 18:45
    Reply | Quote | #1

    Agree with the Python first + interfacing with Fortran when necessary for teaching.

    Some places (close by :-) ) do teach Excel programming first (and could go on to Matlab or Mathematica as you suggest). But… I suspect the academics have tons and tons of Fortran code and want to create a cohort that can keep it going (putting it too strongly for agruments sake).

    With languages like Python you need academics with time to learn it, which is difficult if not impossible for the very busy senior academics.

    Easier perhaps for the younger ones and I often quote one of the best lessons I learnt whilst working for a while in the Business School: what kids do now, everyone will do soon enough (aka the aging process :-) ).

  2. Arvind Prashant Ranganathan
    June 10th, 2009 at 19:45
    Reply | Quote | #2

    Mike, what’s your take on Fortress? It looks pretty cool, and it’s another languages designed by the Guy Steele.

  3. June 10th, 2009 at 21:46
    Reply | Quote | #3

    I happen to agree, and not just because I’m also a Python fan. My undergraduate physics course included modules on the C programming language. For me, they were rather dull as I’d picked it all up many years previously. For others, C proved too complicated, and you have to go through too many details before you can see the overall structure of a program.

    I firmly believe that what is needed in undergrad science courses is not a module teaching a specific programming language, FORTRAN, C, etc. but a module teaching programming techniques. Maybe using tools such as Mathematica or Matlab as well as more traditional programming environments, or perhaps just focusing on the fundamental aspects of programming. The big ideas, and the important concepts. Of course, you need a language in which to formulate this, and Python lends itself nicely to such tasks. It is expressive, readable, and comprehensible. It looks rather like English, and the significant whitespace forces you to indent properly, leading to readable code and better expression of your intentions.

    As you point out, there are a number of legacy applications using FORTRAN, not to mention a number of academics who still use it for new projects. Similarly, a great many useful applications exist in C and C++, so these languages should not be forgotten entirely. Rather, the course on programming delivered to undergraduates should be structured in such a way as to facilitate the transition to other languages, rather than to block it. Again, Python works well here as it supports a large number of styles of programming, and leads nicely into lower-level FORTRAN, C or C++ programming.

    I find myself using Python more and more, and the experience is hugely rewarding. So my disclaimer is simply that I am not unbiased. Even so, I think Python make a very strong platform for building a course centred on programming as a set of concepts, rather than as language-specific pre-rolled solutions which students merely have to plug together to solve an assignment.

  4. Szabolcs
    June 10th, 2009 at 21:58
    Reply | Quote | #4

    You are giving examples like plotting or data processing. Of course Fortran is usually not the right tool for that. But plotting is not the only thing a physicist does (unless we’re talking about an experimental physicist) with a computer. In theoretical physics, computers are mainly used to run large simulations, and Python will never be the right tool for that, simply because it’s much slower than low level languages, and will always lag behind faster languages by many years in terms of how large a problem it can handle.

    I think that not specifically Fortan, but *programming* should be taught, and that a first programming course for physicists/engineers should not be based on a single language. Mathematica is not really suited for writing simulations, and C or Fortran are not convenient tools for data processing. Once the students know how to program, they should be able to pick up any language on their own as needed. Programming should be taught in this spirit.

    No physics curriculum is complete today without a computational physics course, and knowing a fast, low level language is a prerequisite for that. Whether that language should be C, C++, Fortan, Java, or some other language, is a different question.

  5. June 11th, 2009 at 06:27
    Reply | Quote | #5

    I’m a pretty strong advocate of Fortran, as a language. (Well, the modern versions.) It’s a thriving language with significant development going on in the standards, has a range of really well-done features that address many of the problems in C and C++, and is something that I would recommend that anyone who’s creating a serious numerical program should strongly consider. And I’ve been involved in the GNU Fortran compiler project.

    And I fully agree with you. In 1994, when I was a beginning engineer, it was probably a good choice of language to start with; it’s a simple straightforward procedural language used for real work, and definitely a better choice than C or worse C++. (Whether those are appropriate first languages for computer science students is arguable. They are not appropriate for engineers whose aptitude lies far more with physical nuts and bolts than abstract pointers.)

    This is not 1994. And, even though today’s Fortran is not 1994′s Fortran, it is not the right language to start with.

    Besides which, Fortran wasn’t my first language either. I learned in BASIC on my dad’s computer when I was about 10 or so. It was great. Command-line interactive interface, easy graphics commands for creating impressive-looking output (for the day) with little effort, and reasonably able to do a fair bit of what one would want a computer of the day to do, if rather a bit slowly with some things. I think that’s pretty much what a first language ought to be like.

    So, yeah. Today, that niche is Python.

    I’m still not sure that means Fortran shouldn’t be taught to undergraduates, but if it should, it’s a last-year elective (or, better, part of an elective on serious numerical programming), not a first-year intro.

  6. Mike Croucher
    June 11th, 2009 at 10:17
    Reply | Quote | #6

    @Ian Programming in Excel still makes me feel uneasy but more and more people seem to be doing it. One course in the business school does it because apparently that’s what industry expects! It’s a funny old world :)

    @Arvind I only discovered Fortress a couple of weeks ago thanks to a programmer friend of mine and it is on my list of things to check out. Put another way – I don’t know a thing about it ;) I might be interested in having a guest writer on here soon if I can find one who knows enough about Fortress to say/demonstrate something interesting.

    @Andrew Agree with everything you say too. So, Python for teaching concepts and the basics of good programming and numerics and then let graduates pick up C,C++ or Fortran if they need them?

    @Szabolcs I was a theoretical physicist too (both undergrad and postgrad) and I didn’t hit a problem that needed superfast computation until grad school. Nothing the undergrad syllabus threw at me needed any more computational power then I could get out of a cheap laptop and python these days.

    You are absolutely right – when the problem size gets large enough then you NEED low level languages – no doubt in my mind. I hit upon many such problems in grad school. The main point of this article is that you don’t need such power in your first (or even your second) undergrad introductory programming course.

    The most advanced simulation I had to write for the undergraduate computational physics course (The 2nd level,harder course) I did back in 97 was to simulate the 2d Ising model. Now this is trivial enough that someone has written a Wolfram Demonstration for it in Mathematica

    http://demonstrations.wolfram.com/IsingModel/

    I did a much more complicated problem for my undergraduate thesis which pushed desktop computers back then to the limit (using C) but I bet I could do that in Mathematica now.

    What is the most advanced simulation required of undergraduates these days?

    I happen to disagree with you on the point of teaching multiple languages for a first programming course – that is likely to confuse the hell out of most students IMHO. For a first, single semester course I firmly believe that sticking with one language is the way to go.

    Most people on the first level course won’t go on to be programmers anyway. Those who sail through the 1st course and move onto more advanced courses that NEED C or Fortran can learn it when the need arises.

    Learning your first language is hard – the second is a little more straightforward and after that it’s pretty easy (most of the time)

  7. Mike Croucher
    June 11th, 2009 at 10:26
    Reply | Quote | #7

    @Brooks – you ended up in my spam bin for some reason. My first language was BASIC too, on a Sinclair Spectrum when I was 8 and I had a similar experience to you. I remember learning trig back then because I wanted something to move in a ‘wavy’ line and one of my dad’s friends said – you need to find out about the sine function.

    My math’s teacher was rather surprised when one of her otherwise unremarkable maths students turned up the next day and demanded to be taught trigonometry.

  8. June 11th, 2009 at 13:29
    Reply | Quote | #8

    We went through this discussion 5 years ago in our Physics & Astronomy dept. In the end, we settled on an the simplest elements of C++, partly because a later course, more focussed on numerical methods, also used C++. Note that with C++, you don’t need to teach pointers in a first course: just the basics – loops, conditionals, functions, arrays, etc which are essentially the same as any language. It’s true that C++ is less “forgiving” (1/2 = ?) and hence more painful than e.g. python, but on the other hand you do learn a lot more about fundamental (but low-level) programming.

    On the other hand, more recently we have also thought about switching to Python for exactly the reasons that you describe. Note that its only due to the recent improvement in Python libraries that this makes sense. Going back 5 years I don’t think Python would have been a viable option.

    Finally some of the problems that you cite will be true for *any* language. Let me take your statement and replace “Fortran” with “Programming”. Because of the diverse backgrounds of incoming 1st year students, it’s still true:

    * Programming was too hard! So much work for such small gains (First time – programmers)
    * The course was far too easy. It was just a matter of learning syntax and blitzing through the exercises. (People with prior experience)

  9. Mike Croucher
    June 11th, 2009 at 13:43
    Reply | Quote | #9

    Hi Mike

    Thanks for your comments. I agree concerning the recent improvements in Python – it has got significantly better in the last few years.

    As you rightly say, you can replace ‘Fortran’ with ‘Programming’ and those statements are still true BUT they are less true (hmmm..I bet someone will pick me up on that statement) if you use Python as your beginners language. This is because a lot of the hard work is done by the many python languages.

    It’ll still be hard (because programming IS hard) but beginners will achieve much more impressive results at the end of a 12 week Python course then they will at the end of a 12 week Fortran course.

    I have just come across an article in the journal ‘Computing in Science and Engineering” by A. Bäcker
    http://www.physik.tu-dresden.de/~baecker/pub23.html
    Which shows some great looking Python examples from a computational physics course aimed at beginner programmers.

  10. Tim Allman
    June 11th, 2009 at 16:00

    You can probably relate to my background: PhD in chemistry with a lot of nmr computation and now a software developer. I was first taught Fortran (which by the way, has been around a lot longer than 40 years) but have never used it much. I prefer the C family of languages but will link into something like lapack (a free Fortran numerical analysis library written in Fortran) partly for the performance and partly because it is already written and is probably free of bugs.

    As a teacher (yes, a BEd too) I would never teach Fortran alone although I would show it as an example of a different style of language much as I would assembler.

    I think Fortran is something that can be learned as needed later. It has never really gotten over its Hollerith card origins and a good C compiler will usually give performance which is perfectly acceptable.

    Tim

  11. Brandon
    June 11th, 2009 at 16:03

    This is definately an interesting post. First off, I believe that teaching Fortran in an undergraduate level is actually a good idea. That being said I do not know if it teaching it to students in a Physics or Chemistry program is the right choice. For students in Computer Science or Information Sciences Fortran is a big help because it helps people to get an understanding of basic programming and good programming habits. In your post you said that Fortran is hard, but it is actually one of the easiest languages to learn, if you want something difficult try programming in LISP or SmallTalk.

    In response to your question about what should be taught as an introductory class. Why not do what a lot of schools are doing now. Teach Java as the intro class? It has free compilers, it trys to cause the programmer to follow a good structure, and if you want to be able to create a graph with variable points it isn’t terribly hard.

    I guess overall I think Fortran should still be taught at the undergraduate level, but maybe not to students that are not in a Computer Science or Information Systems degree.

  12. valter
    June 11th, 2009 at 16:50

    Fyi, Prof. Langtangen has written what looks like a very nice intro to (scientific) programming in Python (see http://folk.uio.no/hpl/tmp/tmp.pdf) – possibly as a prequel to his more advanced “Python Scripting for Computational Science” (see http://folk.uio.no/hpl/scripting/index.html).

  13. Mike Croucher
    June 11th, 2009 at 16:50

    Hi Tim

    I completely agree with you about interfacing with libraries such as LAPACK when needed. I recently wrote some notes on how to call the NAG Fortran libraries from Python for example:

    http://www.walkingrandomly.com/?p=830

    NAG were quite pleased about this ;)

    http://www.nag.co.uk/NAGNews/NAGNews_Issue80.asp#Article3

  14. Bob Phillips
    June 11th, 2009 at 17:09

    If an antique (back in the 60′s) PhD Nuclear physicist can have a bit of input. FORTRAN itself is pretty easy to learn when you have a need to learn and use it. I did lots of work (some of it still in use 20-30 years later) with FORTRAN-77. But I found that I can get anything I need accomplished in C or C++. As a general rule I might propose that you consider teaching the students to use Excel (or OpenOffice) to help them understand the physics/chemistry/mathematics/etc they are studying. It is fairly easy even though the spreadsheets will be REALLY U*G*L*Y. It really is the idea that is important, not the programming technique. In the field they will use this technique to develop and debug the programs if they are programmers and to do their job if it is not programming.

    Languages like FORTRAN, Python. C, C++, JAVA, (if you want HARD try APL) should perhaps be taught primarily to those who intend to and want to use them in their professional life. The basics of programming (structure, encapsulation, modularity, etc) are the same whatever language you use. So teach those concepts first then add in a language. For the purposes of advanced placement into college, JAVA is now the standard. So perhaps it should get a slight preference as the teaching language.

  15. Kyle
    June 11th, 2009 at 18:22

    I am a mechanical engineering student finishing a masters degree. I routinely use C, Fortran, and Python for both my schoolwork and the research projects that I am assigned for my student job. Watching my peers struggle to program _anything_ leads me to think that C is not the right language to start mechanical engineers on, since it is such a deep and capable (also read complex) language. When simple imperative programing eludes students, I don’t think that C-style pointers will help anything. At my school we do teach Fortran since it is simple enough that you don’t really need to understand how the computer works on a low level to get decent numerical performance, and in the field of mechanical engineering, Fortran is still used for many things. As a language, it really is among the easiest to learn.

    As for data visualization, Fortran is certainly not the best tool. I solve this problem in one of two ways, depending on what I need to visualize. For fluid dynamics data (CFD) I write the results out to file formats like VTK or CGNS and then use a specialized tool such as Paraview or Visit to look at the data. For simpler things, I can output tables and use gnuplot to look at the graphs, or I can write a Fortran module and wrap it with f2py and then use matplotlibs very nice features.

    What I think is missing from the scene here is the fact that there are many good tools out there and most can be used to solve many different problems. The real task is to pick the right tool for the job. Matlab is great for some things. The controls engineers use it all the time. In fluid dynamics though, it gets almost no use at all since it it far too slow. An engineering computer course should teach programing in some _easy_ language that the students will grasp, and then introduce them to the various tools available and give them and idea of what each is good for.

  16. durks
    June 11th, 2009 at 18:30

    I think the notion of teaching Fortran as the beginner language to students is mostly to into them into the world of itteritive thinking, ex learn to proceduralize and break every little task up into it’s smaller and simpler components. My first college class was also Fortran 77 back in 1994, but I already had a solid understanding of Basic from having grown up with a Commodore 64. The language isn’t really that important as the understanding of itteration, variables, logic tests, and flow. There’s too many bad implementations of Basic to make it a good starting choice anymore (Visual Basic, VBS, QBasic, bla, bla, bla). But that’s probably because LOGO would be a tough sell to a college student in this day and age. And students not going into a CS field don’t need to know about pointers or libraries or object-orientation so the C family is probably out for beginners unless the curiculum will include more programming in the future clasees.

  17. Steve
    June 11th, 2009 at 18:45

    I’m surprised no one has mentioned MATLAB as an intro programming language, particularly for those interested in numerical methods and applications. It doesn’t necessarily encourage good programming practice, as it contains very little object-oriented goodness, but it does give a lot more bang per programming line than Fortran while offering integrated graphics.

    That said, I intend to teach my own kids to program in Python this summer.

    My own background involves decades of programming in most flavors of Fortran at a university, i.e., in the context of simulation-based research and teaching. No apologies! Fortran is quite a fine language for its intended purposes, and it’s only improved with time. Its bashers probably have in mind some dimly remembered F77 spaghetti code when they bad-mouth the language. Totally unjustified. Such folks should get with the times and at least give F95 a whirl before they dismiss Fortran as a totally backwards and passe programming language. Features like interface inheritance (of a sort) have been present in the standard for over a decade.

  18. Alan
    June 11th, 2009 at 20:16

    I never had the pleasure of learning Fortran. The first college course I took as an Computer Science major was taught in PL/C which was a subset of PL/I but with a decent debugger. It was a strongly typed language. I learned good coding practices in that course: modularize, structure and comment well, learn when to write a macro and when to write a function, test the crap out of everything, pay special attention to boundary cases, understand the compiler diagnostics and run-time diagnostics. I never used the language again but the lessons were applicable to every subsequent language that I learned.

    I guess my point is that learning a low level language like Fortran is a worthwhile and time consuming experience for someone whose aim is to write software for a living. If it and programming are taught correctly you will take away valuable lessons that apply to other languages as well. If you just need to solve a problem pick the most efficient tool for the job.

  19. Michael
    June 11th, 2009 at 20:24

    If students need an intro course in programming, then it should be a low level programming language. Python, MATLAB, and the like are no more than really fancy scripting languages. My suggestion would be Pascal or C (not C++, C dammit!).

    Fortran is very good for the purposes for which it was designed (large number simulations, etc) and should be taught to people needing that. Python and MATLAB should be taught to people who can do the work by hand, and then just need a way to speed it up! Too many kids today come out of high school only knowing how to plug number into Mathmatica. They don’t understand the concepts and theory behind the structures of mathmatics.

  20. June 11th, 2009 at 20:29

    Well as some one who started on Fortran IV I think for those types of hard engineering courses Fortran still has major advantages – you don’t have to spend hours debating obscure OO theological debates (if you want to that study theology)

    And replacing it with currently trendy interpreted languages especially of those courses in involving heavy lifting CFD for example doesn’t make sense. The fact that we have much more powerful computers doesn’t mean ooh we can use slower interpreted languages it means you can run computations that would have required the resources of the NSA 20 years ago.

    Oh and you can use Fortran for More general purpose tasks I was part of a team that wrote a Billing system for BT in Fortran as well as working on projects at BHRA like the CFR (commercial fast breeder) means that I am a real programmer the CFR being a mommy Bomb 

  21. Wm Brant
    June 11th, 2009 at 21:21

    Before there were things like pocket calculators and personal computers, FORTRAN was the only computational tool available to undergrads in the mathematics, science and engineering fields.

    However, technology has advanced a bit since then.

    My feeling is that every undergrad, in every field of study, should be required to learn simple programming. As others have noted, Python is currently a decent choice for that area of study. The problem with introductory languages is that historically today’s introductory language is tomorrow’s object of ridicule. See BASIC, Pascal, etc.

    At some point early in their undergrad studies, I think students in the mathematical, scientific, and engineering fields should be introduced to whatever desktop tool is deemed the recommended tool for their field of study. I would hope this is something more powerful than a business spreadsheet tool; but exactly which tool can vary from subject area to subject area, from school to school, and from year to year.

    In regards to FORTRAN; FORTRAN provides mathematical programming capabilities that *no* other standard language provides. You either need the capabilities that only FORTRAN can provide or you don’t. I suspect that given experience with an introductory language and proficiency with a good desktop analysis tool, FORTRAN might not be required until either the graduate or doctorate level, and maybe not even then.

    I dislike the overuse of add-on libraries. They have their uses, but they are a poor second-best to the use of the right language. Plus libraries have a tendency to come and go, and a library is rarely usable with all compilers.

    I also believe that people don’t look at computer languages critically enough. Every language has it strengths and problem domains that it is best for. Conversely, every language has its weaknesses, yet we often employ languages in areas where they are not the best choice.

    At one time, it was very expensive to get a compiler for another language. Today, thanks to the GNU project, it’s easy and cheap to get access to a decent compiler. Learn what craftsmen have long known: there is a particular tool that is best for a given task, but no tool is best for all tasks.

  22. Laurence Perkins
    June 11th, 2009 at 21:33

    I have never in my life written a single line of Fortran. Nevertheless, I have a very large book on my shelf (salvaged from the university dumpster) which contains close to a thousand pages of Fortran routines. I find it to be simple to read, and easy to translate into just about any other language I’ve ever used.

    The most important thing to learn in an introductory computing course is how to think about programming. I spent a lot of time helping fellow students who would buzz through five or six different steps in their heads without realizing it, and then wonder why the computer got the wrong result when they told it to apply the seventh.

    The best thing I have ever found for teaching people how to program is actually a spreadsheet program. (Just about any spreadsheet program actually, it doesn’t have to be Excel.) As long as you can set it to calculate continuously until the values stop changing you can solve any mathematical problem with it. And, for the people who have a hard time wrapping their heads around programming abstractions like variables (and possibly even pointers if you have a *really* good spreadsheet program), it puts it all right there where it’s easy to see the structure. In most modern spreadsheet programs you can even draw on it to remind yourself how it works.

    Once one has the thought process down, just about any language becomes nothing more than a different syntax. Higher-level languages like Python are best for writing code quickly, and lower-level ones like Fortran are better at writing quick code. If one is going to do a large amount of serious programming work, then it is best to learn at least one of each.

  23. Patrick
    June 11th, 2009 at 21:38

    Disclaimer: PhD in physics (with nuclear engineering minor). First language–Basic, 2nd language–Pascal, 3rd language Fortran.

    My opinion is the language doesn’t matter, it’s the teacher. I first learned Fortran in my grad school nuclear engineering courses. We used Fortran because our professor used it in his research on neutron transport, and wanted us to be up to speed before we started our thesis/dissertation research. I did my research in another subject area with another advisor, and the Fortran came in handy when I needed to learn MATLAB and Python.

    Our professor was a superb teacher on programming, numerical methods, as well as the physics. I learned a lot about programming from being in his class — lessons I would later apply to my students when teaching a Visual Basic for Applications course for financial analysts.

    My experience is you’re 90% up the learning curve on any language when you master two things: “Hello World” and file I/0. The rest is details.

  24. hp
    June 11th, 2009 at 22:16

    Mike,
    I believe that Intel Fortran compiler is free when you use Linux. They have the non-commercial license compilers for both Fortran and C++, plus the package comes with Intel Math Kernel. All at no charge :-D… So go and convert all your students to us Linux :-)

  25. Mike Croucher
    June 11th, 2009 at 22:31

    Hey HP

    It’s free for personal use only I’m afraid. Personal use does not include academic research unfortunately and probably wouldn’t include classroom use either.

    http://software.intel.com/en-us/articles/non-commercial-software-development/

  26. Alex
    June 11th, 2009 at 23:19

    Unfortunately, I wasted a semester on learning Fortran (and never using it again). I hate the moron who was in charge of the curriculum at the Colorado School of Mines (yes, the world-renowned “cutting age” CSM) who forced this atrocity of a programming language upon the students at a time when C and C++ were in full swing and with Python on the horizon. FORTRAN is good… I can’t think of of what it’s good for. Anyone who tries to argue for it’s calculation power is fighting a loosing battle. A lot of other languages offer similar mathematical abilities and precision along with flexibility of being actual programming languages. And, for example, Python could be used by a “non-programmer” within about 5 minutes of learning what Python is.

  27. Anonymus
    June 11th, 2009 at 23:34

    I have learnt fortran myself in high school , and must say that it is an useful language to teach concepts of programming at least. Compared to C , you just struggle against the ideas of programming , not the language itself (low level) as it is intuitive , it is not loaded with prebuilt routines with names several lines long like VB, it is imperative unlike python or other fancy new stuff, it is fast , and allows you to do enough with the things under your control so that you will learn some machine peculiarities (such as the way numbers are stored in memory) , and get a bit of a grasp on what is really happening without it being too complex.
    Overall it is a good first language i think, and as a bonus it is still used widely

  28. ROY WALLIS
    June 12th, 2009 at 01:12

    I left scientific programming for law 20 years ago, so I can’t compare recent developments. I learned Fortran II on punch cards in the late 60′s, and programmed in langauages such as PL/I, but by the end I was using Fortran 77 with an Emacs editor. Structured programming was in vogue, at least then. With its modularity, loop structures, and with judicious use of comments and indenting, etc., I could write pretty complicated programs (thousands of lines) that could actually be read, understood and maintained by other people.

    There are probably better tools now to accomplish actual results, but I was able to learn and develop a lot of good programming practices (and results) using Fortran.

  29. Alan
    June 12th, 2009 at 16:23

    As I mentioned before, my first exposure to programming was in college to PL/C. My second language was assembler, and one of the programs had to be written in machine code. Yes, that’s op code, register, base and displacement for every command translated into hex. No variable names, no command names. Just straight hex commands. The program didn’t do much, but the lesson was beautiful. When you understand programming at that level you can handle anything. But that is for Computer Science majors. I wouldn’t even recommend it for engineers. Not enough payoff.

    I like to compare programming to cabinet making. I can do it all with hand saws, hand planes, and chisels. It took me years to learn. When I have to build something I use power tools because they’re faster. There are still times when I use hand tool skills (setting hinges) because the result is better.

    I can’t recommend the teaching of Fortran or any other old language (even considering newer versions) for the simple reason of maintaining an existing code base. How many of those learning the language will go on to use it in their career? It doesn’t make sense. If you want to teach a low level language for the purpose of learning CS basics, that’s a different story.

  30. June 13th, 2009 at 10:11

    The title may have benefited by including the use of the word “ever”.

    When I was a postdoc in the early 1980′s, I read articles then about the demise of Fortran. I recall one article making the point that people said that language X is better, but whatever X is depended on what was in fashion. and the article noted that X appeared to be changing rapidly. The various candidates for X back then are no longer talked about, and since then we have been through a number of different candidates for X. But Fortran has survived.

    In my view there are there are four reasons for the survival of Fortran in science: a) it is well-embedded in the scientific community, b) it works well, c) it is relatively natural for scientists to program in and doesn’t use too many short-hands or clever tricks, d) it has the capacity to evolve. I don’t think that any of these reasons stand alone, but together they have helped Fortran survive. (Aside on point a, it isn’t that we are all using legacy codes, although some do exist, but communities in science are choosing to start new projects in Fortran).

    So in answer to the question of whether Fortran should ever be taught to undergraduates, the answer has to be “yes” if the particular undergraduates will need to learn it as a core skill for the science they are training for.

    But in answer to the question about whether it should be the language of choice for teaching programming, that is a very different question, and the answer will probably depend on the latest fashion. Python seems to me to be the candidate language of today, but it could recently have been Perl or Java or C++.

    There is one significant change between the 1980′s and today, and that is that we work in a very different computing environment. Computers are fast, we have good displays and graphics tools, and we have much richer data sets. Fortran is good at what it does, as also are Python, Perl, Java etc, but no one language is good at everything (because our understanding of “everything” is constantly expanding). Today’s computational scientist ideally should now know more than one language in order that they can perform many different functions. Students will be ill-served if they think that they can learn programming based only on a single language.

    I would also suggest that we have to see a difference between a course to teach people how to think like a programmer, and a course that is designed to teach the mechanics of a given language. These are not the same, and should not be mixed (at least, not if you want to ensure your students are not confused). I suspect that you could more-or-less teach a course on programming using any language, but the simpler the better (which probably argues for a language that is interpretative and which allows you to write one-line programs). I suspect that the problems people are discussing here arise because the course aims were not clear in the eyes of the institutes giving them.

    Finally, I would make the comment that it is increasingly easy to avoid ever having to write programs, and I am not sure that is a good thing. It seems to me that one problem that results from this is that people are no longer looking at raw data, but only at what is produced by pressing a few buttons in a GUI. I am seeing several bad analyses now being published that only arise because people don’t have the capacity for being critical of their data.

  31. MJC
    June 14th, 2009 at 06:43

    Ed Prescott the noble prize winner at ASU uses Fortran and would always get his grad student to learn it – even when we were taught GAUSS and Matlab.

    GAUSS is big with the econometrics people (along with EVIEWS)- always fun to begin in GAUSS spend 30 minutes getting it to run a simple regression that EVIEWS does in 10 seconds.

    Matlab with the macro guys and the micro guys scoff at them all.

    Interestingly in consulting if you have someone who is an expert at excel they can earn a packet. Got to love goal seek.

    Also the add in @risk is used a lot (especially in the finance world) – not the best endorsement!

  32. Jordan
    June 16th, 2009 at 07:27

    Well you got slashdotted but as usual it seems no-one RTFA.

    Your arguments are all accurate. I was a Maths student at university who took courses in Computer Science and Physics to round out my degree, and when I came to do a third year maths school course “Introduction to Numerical Methods”, the horror of Fortran – the first half of the course was learning the language, and we seemed to spend weeks just on the arcane string output formatting – made me drop the whole subject like a hot stone. A friend who persisted told me the actual mathematical/computational content in the second half of the course was worthwhile, but I was long gone by that stage.

    Python’s a very good choice – in fact the more science undergraduates learn scientific Python, the more they’ll be motivated to write Python wrappers to other Fortran numerical libraries when they actually encounter heavy number crunching in their postgrad research, making the power of those libraries accessible to a much wider range of people and reducing the need for all but a few specialists to even know about the existence of Fortran. Which is a Very Good Thing.

    Although maybe Guy Steele’s work on Fortress will change the terms of this debate…

  33. June 27th, 2009 at 23:02

    As a retired Portuguese engineer I can say that in Numerical Methods I studied one week Fortran in 1970.

    In 1974 I bought an American book on the subject and read it almost entirely doing at the same time most of the exercises. I liked the book very much. The book title is “A Primer on Fortran”, if I remember well. I do agree that one needs much time for learning the “arcane string output formatting”.

    Python is only a word for me which I know nothing about.

  34. June 28th, 2009 at 08:27

    Just to say as a retired Portuguese Engineer that:

    1) I know knothing about Python, so I have no informed opinion.

    2) Concerning Fortran I studied it for a week in Numerical Methods, at IST, part of the Technical University of Lisbon, back in 1970. A couple of years later when working as a designer engineer in automation/control I bought a book by an American author on the subject.
    I loved it, read it almost entirelt and did most of the exercises. If I remember well the book is “A first Primer on Fortran”, a lovely one. Only later I learned other programming languages.

  35. Rusi
    June 29th, 2009 at 03:27

    I think Fortran is even more relevant today specially on multi core CPUs. It is much easier to auto parallelize Fortran code than C++/Java code.

    The language is designed keeping compiler optimization in mind (with things like ‘Forall’, Pure/Elemental Procedures, Support for whole array operations etc.)

    Moreover it is so much easier to teach Fortran than C++ which has a tremendously high learning curve.

  36. June 29th, 2009 at 15:50

    I agree that python would be a good choice to be taught in a scientific computing class for beginners (CS departments might prefer Java). Due to e.g. the size of matrices often dealt with in scientific computing I think it would be necessary to learn a slightly more “low-level” language like fortran in order to better understand the concepts of e.g. memory allocation. It would be easy to blend in a single lecture on how to use such a “low-level” language to write modules for python.

    I would even suggest experienced scientists to start new projects in python, which I think is useful for prototyping new algorithms (running the code interactively helps debugging – might be easier than using an external debugger) and to replace heavy-duty routines by C or Fortran once the code has matured.

    It is true that Fortran has been around for quite some time (and still is – thanks to us), probably for a good reason – the focus on FORmulas without sophistication for other programming issues. C will probably also be around for some time due to its importance for OS’s (or the major part of open source apps), but in general programming languages will come and go (as well as software design/programming paradigms). So I think that there shouldn’t be much too much focus on a single language during the education (as Martin pointed out), but more on the basic programming concepts and how to come up with algorithms (which python should be optimal for).

    I think that if there are both students with previous programming knowledge (which might be quite advanced among young engineers/physicists etc.) and without, two different courses might be better, which could be too much workload for a single department. When I attended computing classes myself, a course was offered at the CS department by for all students who majored in other fields.

  37. Phil Bergmaier
    July 9th, 2009 at 20:08

    Hi,

    As a senior with a major in the atmospheric sciences, I was required to take Fortran as well back as a sophomore. However, the reasoning behind this was due to the fact that IDL, a VERY relevant and useful programming language for my field of study, was also required. My department also offers a numerical modeling course, so Fortran is merely used as a bridge to other similar and more useful languages that are used extensively in the atmospheric sciences. No, I doubt I will ever use Fortran again, but without it, learning IDL would have been a nightmare, especially considering the two are very, very similar.

  38. Some one
    July 22nd, 2009 at 10:49

    Fortran compilers are expensive? gfortran works perfectly in almost all cases.

    Scripting languages (Python/matlab) should not be compared to low level languages at all. It is important to learn both a high and low level language for numerical computing. I have seen people running matlab simulations on clusters that would run in a few minutes on an entry level desktop if not written in extremely inefficient matlab!

  39. Mike Croucher
    July 22nd, 2009 at 11:56

    If gfortran worked in almost all cases then I would never have had a hoard of people demanding the Intel Fortran Compiler. If gfortran worked in almost all cases then some senior academics wouldn’t insist on teaching using the NAG compiler….or the Silverfrost compiler. If gfortran worked in almost all cases then I wouldn’t be getting emails asking for yet more compilers such as PGI and lahey.

    gfortran may well work for you but when you are dealing with 100s of Fortran programmers you get to see that there are plenty of people who need more.

    I agree you should learn both high and low level languages for numerical computing but the whole point of this article was ‘When you have never programmed before…I mean ever…maybe, just maybe learning Python is a little less scary and more productive.’

    When you know the difference between a loop and an if statement – then you can take the training wheels off and dive into Fortran or C or whatever else floats your boat.

  40. Some one
    August 11th, 2009 at 07:42

    > If gfortran worked in almost all cases then I would never have had a hoard of people demanding the Intel Fortran Compiler.

    gfortran can produce the same link level object code as IFC. The assembly produced may differ, and you may need to rename f90 files to .f90.

    A small bash script can be used to hijack most toolchains by placing it in /usr/local/bin/ifort (EG abaqus, which is what I do) to make for savings on your compiler costs.

    Something like:

    PARAMS=`echo $* | sed s/-w90// | sed s/-w95// | sed s/-auto// | sed s/-WB// | sed s/-cxxlib-gcc// | sed s/-threads// | sed s/-parallel//`

    will drop the flags passed to ifort by abaqus. You may need the -ff2c flag.

  41. Mike Croucher
    August 17th, 2009 at 10:12

    Thanks for the tip – it’s an interesting technical workaround and one that I will try out in the future. However, I would much prefer to use the fully supported option in applications like Abaqus.

    When you have people designing components for bridges and planes you tend to get jittery advising anything other than the fully supported option and the fully supported option is the IFC.

    Cheers,
    Mike

  42. Jon
    April 28th, 2010 at 16:16

    I’m taking Fortran right now. I absolutely despise the class, and I know for a fact that I will NEVER USE IT. But because I’m not passing the course, much to my 30+year veteran programmer father’s chagrin, I’m going to have to RE-Take the damned thing and get held back in other courses that require it as a passing grade.

    I F!$#%NG HATE THIS %$D !%MN$$ “PROGRAMMING” LANGUAGE. T_T

  43. Dan
    May 15th, 2010 at 00:09

    A first programming language is a tough choice. It seems everyone has an opinion. However, if you took or are taking Fortran as a first course and you think it’s hard. Well… IMHO, it’s likely hard because you don’t have a good teacher or simply because you “just don’t get it” (and I’m not saying this to sound mean or uncaring). If basic fortran coding is hard, then… well… pretty much any language is going to seem hard to you until the right light bulb goes off in your head. I mean, in fortran, the syntax you need to write a loop that iterates some whole number between 1 and 100… come on. The fortran mental model for that type of thing really doesn’t get any easier does it???

    Sure, you’re not going to jump into drawing graphics using fortran without some add-on software, etc. Of course, most languages aren’t going to have you drawing graphics. A language with built-in graphics generally means it’s a proprietary language or a slow one and it rarely is a portable language. But, then again… if you’re writing “simple” graphics code in your first programming course, then… you’re not doing rocket science either. And… you may even be spending your time learning “frills” rather than actual good programming techniques.

    The purpose for teaching a future engineer or physicist fortran or some other language in a first course on programming is not about showing the person a good time with a few extra colors on the screen (not that that is a bad thing!!). It’s about making them better at what they will be doing in the future. They can always do that graphics later. It’s a LOT easier to write code to draw a few lines and curves than it is to write a nice iterative solver routine. So… you can teach them to solve complex problems and they’ll easily figure out how to add graphics to their code later or you can teach them to do simple graphics and they can get a job writing the graphics code for the smarter guys out there who wrote the complex mathematical code.

    Dan :-)

  44. Mohammad
    December 7th, 2011 at 08:04

    I agree to use simpler tools for simple computational tasks. But what you stated and what you concluded is not true! As some other people commented above Fortan is not the right tool for visualization! It is like you want Powerpoint to do what Excel does for you! Fortran is the language of scientific computation, the first programming language for number crunching!
    If you like to teach students simple computer calculation with quick and interactive visualization, don’t waste money! Matlab is not needed and Mathematica is more than enough here! Simply download a free spreadsheet like GNumeric or Calc from Openoffice and do all your computational / visualization job for those beginners.
    But we should remember, Calc or Excle or GNumeric cannot be used for a real number crunching problem. You even cannot use Matlab and never Python, it is Fortran. Well engineers/researchers also use C or C++ but not Python.
    I agree that Python or Visual Basic or Matlab are great for introductory courses! But for Physics, Chemistry and most Engineering students, Fortran shall be taught as an intermediate course in Programming. Fortran 2008 has most of the modern language features while it stands on the shoulder of many high performance / high quality scientific libraries available free on the net.
    Let finalize the word that, to have your lunch, you need not only a knife on the table, but also you need a fork and a spoon! Every tool has its unique function. Today science and engineering students shall not only learn spreadsheets, but also Matlab and Fortran.

  45. December 9th, 2011 at 23:26

    I’m a researcher and I learnt Fortran at University. It was absolutely useless. In the last six years I bet for Java and now I can only say that I cannot live without it, I use Java everyday for almost every task. Learning curve is slow, right, but productivity rises exponentially after the first year and never stops increasing. In fact, in astronomy it is today the preferred language in new projects, and I started using it a long time ago in a project called JPARSEC, a library for ephemerides calculations and advanced charting in Java.

    I think there are two concepts to separate. One is to teach a student to use certain tools for charting and being productive (as a student), and the other is the research itself. A student usually needs something easy to work fast, and now there are a lot of tools for that. Matlab free clones like Octave or Scilab are useful, as well as other tools like R of processing (I wouldn’t recommend Excel for research). These tools are good for a student or for the computational/graphic requirements of basic research. Most people will never need more than just that. R is a good choice between student/basic research requirements.

    For serious research these tools are not enough flexible for some people. In this case, Python and Java are in my opinion the best choices. Should Java or Python be taught in universities? I think so, because it is very important to teach students or future researchers what is the best way to be productive in science. Java is better because it has more libraries and excellent free tools for development, like Eclipse IDE, but Python has a faster learning curve and is rising (in developers) quite fast. Fortran is a waste of time, is the kind of language one would use because he/she doesn’t want to be ever worried about how to be more productive, or if that is even possible. I remember I laugh 20 years ago when I learned Fortran because I was using BASIC before and realized Fortran has no support at all for graphics. In fact, I continue using BASIC at that time, even exporting charts to a printer using an 8-bit Amstrad for my school homework, simply because it was possible, but not with a PC and Fortran. Today this hasn’t changed.

    There are also deep reasons to bet for Java in science. Apart from the easy of error tracking, documentation and language writing rules (javadoc), and for being the first choice (in fact only, as I saw when I worked as a consultant) in new projects in any industry, it is the only language with an accurate maths library that produces exactly the same output for calculations in every operating system and CPU. The other languages use CPU instructions to approximate trigonometric functions, giving wrong results (but maybe faster) in some cases. Faster is fine, but unaccurate results is unacceptable in science.

  46. Yannis Bonis
    January 20th, 2012 at 03:15

    I believe that there are certain things that you need to learn young, so that they can develop roots into the way you function. Among these is riding a bike, swimming and programming. The first 2 example tasks you learn at a young biological age; programming you need to learn at a young scientific age. If you learn how to program later, because you need it in your work or study, you will probably be able to do it, but chances are you won’t like it and be great at it. The approach of only teaching students what the majority of the professionals in the field use is dangerous, as it produces short-sighted graduates. It’s one thing to teach anthropology to engineers and another to teach them mathematics or programming, giving them knowledge which may not be used directly after their study. Therefore, I strongly support the existence of programming modules, or at least computational programming tutorials integrated to numerical analysis modules, at the early stage of study for undergraduate degrees.

    I also believe that languages can be classified in programming ones (Fortran, C, etc.), scripting ones (Python, Perl, etc.) and numerical packages (MATLAB, R, etc.). If one wants to do scientific/numerical computations, probably the “best” package is MATLAB, in the sense that it can perform many functions, it is widely used (although very expensive) and there is a lot of peripheral material available (toolboxes and functions), often for free. On the downside it requires too many computational and memory resources, especially in comparison to Fortran or C. In some sciences, like computational Biology, knowledge of Python could be good enough, but in engineering it probably isn’t. Legacy codes are all over the place and more often than not they need tweaking before execution. If students are taught to like the ‘simple’ python and be scared of the ‘stiff’ fortran, the legacy material which does not work out-of-the-box, will probably just stay in the shelf.

    I believe that students should be taught how to perform computations, both by hand and using a computer: they should be taught MATLAB. But they should also be taught a programming language, so that they can get some insights on how “to get the black box with the Dell logo do what you want”. Teaching Fortran or C/C++ makes hardly any difference, the most important is to teach what programming is all about. Every school should really choose the dominant language in the field.

    The choice of compiler is secondary. From experience I know that execution times of the same code can vary significantly between compilers. However if it’s teaching we are talking about, the students will notice no difference and the cheaper option would do fine. For research purposes things are very different. For a university like our own, which supposedly supports research, a choice of compilers should be available. This service to researchers is not one they get for free, (high) overheads are paid by every single research project brought in.

  47. T. Orhun
    January 5th, 2013 at 04:58

    I am a junior student in aerospace engineering and we had a 1st year intro fortran course which I can say that we learned absolutely nothing than what if loops does and a non-useful goto # statements.

    In my 3rd year, we try to solve elliptic-parabolic PDE’s such as 1-d wave equation or laplacian of a potential flow around an object in a test section to find the steady state distribution. In these homeworks, we are supposed to complete 4 parts of the incomplete fortran(77) code such as defining proper boundary conditions or an if loop which is needed to solve the problem in the domain etc.

    What I believe is, fortran is a straightforward language in terms of its actual statements. Its coding is easy to understand the solving procedure of a complex problem and I think the main aim of this 3rd year numerical course is to make students understand the procedure to solve a complex problem (such as flow around an a/f or cooling of a fan blade) with numerical methods, rather than giving the students ability to compose their specific fortran program to run random questions.

    It was a hard course for me, I must say, and format stuff of fortran is a mess imo since we,students, didnt focus on those issues but rather on the solution algorithm and how its done with do and if loops.

    I believe, fortran77 is cool for an aerospace engineering program IF the undergrad students are not held responsible developing the whole code but instead of parts like completing subroutines. And also my professor said that nearly all the codes out there about aerodynamics are written in fortran and therefore we should learn it.

    Thank you all for this discussion, it was really useful for me since I was asking myself the use of each programming language you mentioned above, and it is good to have professional points of view as an undergrad student can’t get much in their years in university..

    Best Regards

  48. Other Jon
    June 30th, 2013 at 22:05

    I’ve found that Fortran is a beautiful language for numerical work. Do you want to solve the Navier-Stokes equation in 2D? Write the solver in fortran (77/90+) first. Then try to write the same thing in c/c++ (you can even use the boost library, or anything else you can think of to make the process faster). Now ask yourself, which task was less frustrating? At the moment, my answer to that question is that in fortran this was an easy task, in c++, well… we’ll say that it was very frustrating; people with anger problems and little programming experience may be left bald from the incident after tearing their hair out. Score one point for fortran!

    The thing is; the later species of fortran can handle object-oriented programming (albeit not very well). Many of the veteran fortran programmers are suspicious of OOP and assume that it will make their code slower. Whether this is mere superstition or if it is grounded in reality, I’m not qualified to say. What I can say, however, is that fortran, all of the dielects that I’ve seen have an extremely simple syntax. It is so simple that a clever person or team might be able to write a library in a really good language-parsing programming language like ruby or python and have it spit out highly optimized and screaming-fast, readable fortran code.

Comments are closed.