Should Undergraduates Be Taught Fortran?
Mike Croucher writes "Despite the fact that it is over 40 years old, Fortran is still taught at many Universities to students of Physics, Chemistry, Engineering and more as their first ever formal introduction to programming. According to this article that shouldn't be happening anymore, since there are much better alternatives, such as Python, that would serve a physical science undergraduate much better. There may come a time in some researchers' lives where they need Fortran, but this time isn't in 'programming for chemists 101.' What do people in the Slashdot community think?"
But only if they have to do it on punch cards, like I did. Give each student a can of WD40 to keep the machines working smoothly, too.
--No one-- should be taught FORTRAN. Ever...
*sobs in fetal position*
Are there any cheap but quality tutorial for Fortran? O'Reilly has no contemporary introduction to the language and their last book on Fortran, Migrating to Fortran 90 , came out nearly two decades ago.
Fortran is still one of the best, fastest, most optimized tools for number crunching. It's also very easy to write simple programs in it. No way I'd use Python for serious large data set numerical calculations.
Does it really matter what language they're taught in? They should be learning the concepts of programming, not just a language. However, FORTRAN has the benefit of already having a large existing code base and deployment in the field in which students in those particular disciplines are studying. There's no reason for them NOT to learn it, and if they feel like learning Python later, then then may. Python isn't the solution for every god damned thing in the world, even if it can do it.
What do people in the Slashdot community think?
The easy route is just to let them teach what they want to. Professors will talk and push whatever they feel is valuable and they sure the hell aren't going to listen to a Slashdot user half their age that will get on his knees and write Java for an extra buck. If you get a whack job professor teaching only archaic languages, the University will probably hear complaints from alums about getting into the job market and wishing they had learned R instead of Fortran. I don't know about the other engineering programs but I'd sure rather be a master with R than Fortran. Is Fortran more efficient? Depends on if you're talking about cycles or amount of time it takes to write a quadratic sieve for prime numbers.
... maybe even Ruby?
I had to learn C and I actually like plain jane C in all its simplicity. I think colleges should stick to a low level language for numerical computation courses (in my case C but I believe Fortran would function fine), an intro course to an interpreted language like lisp scheme perl whatever and should of course offer full courses in whatever is the latest craze for usable languages like C++, Java
I wager this will be a hot debate and I think it's fine if people want to teach Fortran, I learned scheme and I've never used it in my professional work! Just so long as when they enter the job market, they're prepared.
My work here is dung.
i spoke to someone studying engineering in 1990 who was being taught fortran. they were using a mathematical library that would solve partial differential equations, by presenting the user with the actual mathematical formulae to them.
these kinds of libraries are staggeringly complex to write, and they have been empirically proven over decades of use to actually work.
to start again from scratch with such libraries would require man-centuries or possibly man-millenia of development effort to reproduce and debug, regardless of the programming language.
so it doesn't matter what people in the slashdot community think: for engineers to use anything but these tried-and-tested engineering libraries, that happen to be written in fortran, would just be genuinely stupid of them.
If all you need is to crunch numbers, Fortran is a good choice even today.
It might not be the best language to introduce someone to computer science, but it is very powerful for anything that has to do with matrix operations.
A few years ago in a physics graduate course we had a simulation project which left the choice of language to the student.
We compared performance between implementations in C C++ and Fortran.
Fortran was consistently faster by a big margin.
It's also very easy to learn.
That said, I do most of my coding in C.
As of Postgres v6.2, time travel is no longer supported.
There's no problem for teaching Fortran if it's the right tool for the job. It was 13 years ago that I took Fortran in College. It went great with physics and modeling courses. These days I write web-based database apps in Java/Perl/whatever language-du-jour is required of me, but I wouldn't want to use many of these languages for scientific purposes. I'll leave that to Fortran and C.
Addlepated - punk & metal
Yes, everything should be written in a fresh, clean language.
I nominate VBScript.
"If still these truths be held to be
Self evident."
-Edna St. Vincent Millay
I work at a university research lab and Fortran is still very much present. If nothing else, students need to be able to work with legacy code. I agree, however, that new projects should make use of more modern languages. Special consideration should be given to functional programming which naturally fits many science problems and is easily parallelizable due to its "no side effects" philosophy.
It's called Scheme.
Meta will eat itself
Are you serious? Python?
I am somewhat a Python fan boy. I love it. Its freaking wonderful for prototyping and really has a great, natural flow that reminds me a lot of pseudocode I might just invent on a napkin. Great language. But its also a factor of 30 times slower than a compiled language like C.
(http://www.osnews.com/story/5602/Nine_Language_Performance_Round-up_Benchmarking_Math_File_I_O/page3/)*
And Fortran is able to do optimizations (due to differences in the language for evaluation of expressions) that C is unable to do. This has to do with guarantees of ordering that Fortran does not give that C does. My point is that Fortran is even faster than C. Why do you think its still around?
The physical sciences aren't using a fast language because they are bored, or obsessed with speed for the hell of it. They use them because the problems they solve are typically deep into polynomial space, like O(n^3) or O(n^4). Having something 30 times faster means they can run 30 simulations instead of just 1. It makes a big difference to them.
I think the author of this article has lost some of this perspective.
That said, what this article should have tackled is, what do we want to teach engineering students about computer science? Right now, they take a class that teaches them C++, Java, Python, or whatever. They get some procedural programming skills with maybe a little tiny bit of object-oriented stuff (without really covering OO fundamentals IMHO, which are a more advanced topic) and they are thrown into a world where they are writing code in C for embedded controllers or Fortran for computational codes. As a result, there is a huge body of code out there written by people who know how to get the job done, but don't exactly write code that is very maintainable. They relearn the lessons of CS he hard way over 10-20-30-40(?) years of experience. Are we really giving these young students (who are not CS majors) what they need? What kind of curriculum would be ideal for someone who is going to end up writing code for something like a robot control system in C?
* I didn't really look too closely at this particular source, but I've seen numerous benchmarks all saying the same thing. If you want a surprise, go look at how LISP stacks up compared to C. It is better than you think.
I did my graduate studies in a university electromagnetics lab. Two of the professors main research area was FEA. By default, we still ended up learning some even if it wasn't our research area. Most the students were pro Matlab, where as the professors were pro Fortran. As a result, if you were doing FEA for your research, you were learning fortran. If you are doing small simulations, then go ahead and use Matlab, since it will be easier to code and debug. Once you start creating 3D meshes, the number of unknowns becomes huge. At that point a compiled language is a better choice. At least fortran has complex numbers native to the language, so its implementation is a bit more elegant than say C/C++.
IMO universities should be teaching core principles and methods, not attempting to impart up-to-date job skills.
If you are going to teach FORTRAN because it's of use in the real world, then why stop there? Why not also (god forbid) teach .NET. JavaScript, C#, etc. May as well teach them Excel macros and how to interact with Microsoft Clippy while you're at it.
No!
Teaching programming should be done in a langauge that imparts the principles easily and teaches good habits. You could do a lot worse than Pascal which was often used in this role, or maybe today just C++. I'd argue against Java and scripting languages as the core language since they are too high level to learn all the basics. You could throw in Perl, Python or any modern scripting langauge as a secondary, and for a Computer Science (vs. Physics, Engineering, etc) it's appropriate to teach a couple of other styles of programming - e.g. assembler, and functional programming.
Nail guns have been around for a while, but a lot of houses still get built with hammers.
If a simple tool does a job efficiently and effectively then why "change for the sake of change"?
I'm a fiscal conservative, it's a pity we don't have a political party anymore
I am a manager in a highly technical organization that relies on computer codes to do our job. In my experience, there isn't ENOUGH FORTRAN teaching in the college level. Maybe its location based, but most of our new-hires (we get most from the northeast, but still get a noticeable amount from as far away as University of Washington, Univ of Hawaii, and USC) actually are NOT taught FORTRAN and instead are taught something object-oriented, typically C++ or Java. I know for a fact that Penn State suggests C++ for all undergrad engineers (FORTRAN is offered though - the classes hold less than 50% total students than does the C++ course). In my organization we also have a 'double-hump' age distribution: lots of people ready to retire (or could have retired 5 years ago...) and lots of people who are within 5 years of their first day on the job. This creates a problem of knowledge management; our new guys need to know the details of the FORTRAN code they are using every day to the extent that our ready-to-retire guys know it, and fast. If they are not taught FORTRAN, this creates an even larger learning curve for them which isn't desirable. So one option would be to 'rewrite the code for the future generation'.. We definitely do not have the resources to rewrite our workhorse codes that have been in use and development since the 70s. I don't know if an organization as large as Microsoft could rewrite Windows in a new language. Also, we can't retire our old codes because they are still actively needed to respond to emergent issues (it is easier to maintain the codes than it is to make a new model to be inputted into a new code). So, our hands are tied (mine specifically!) and my organization actually needs MORE FORTRAN programmers coming from the university just to maintain the status quo.
Fortran hasn't had those limitations for decades - Fortran 90 and later are ideal languages for expressing mathematical algorithms and crunching numbers
Fortran hasn't had those limitations for decades - Fortran 90 and later are ideal languages for expressing mathematical algorithms and crunching numbers. The handling of arrays, matrices are just what they should be.
I wouldn't use Fortran as a general purpose language - having used Python for more 10 years I shudder at using Fortran for string handling, databases, user interfaces and more - but as a tool for expressing math it's the best, and also the most widely used. The alternative would be matlab (much of the syntax isn't that different).
The Mayan Long Count Calendar turns over in 2012. Mayan date 12.19.19.17.19 will occur on December 20, 2012, followed by the start of the fourteenth cycle, 13.0.0.0.0, on December 21st.
The event was first flagged by megalith scientist Terence McKenna. The end of the thirteenth cycle would break many megalith calculations — which conventionally use only the last four numbers to save on standing stones — with fears of spiritual collapse, disruption of ley lines, Ben Goldacre driving the chiropractors back into the sea and the return of the great god Quetzalcoatl and the consequent destruction of all life on earth.
Megalith programmers from 4000 years ago are being dredged up from peat bogs and pressed into service to get the henges updated to handle the turnover in the date. "It could be worse," said one. "I could still be programming COBOL."
http://rocknerd.co.uk
This was clearly written by someone who doesn't actually do any scientific computing.
As hard as it may be for some CS-types (myself included) to believe, Fortran is still the language for scientific computing. I've worked at flight simulation companies for two different companies (and 5 different groups) for the last 15 years. The math required to simulate a flying aircraft in realtime is ungodly hairy. It also has to get done fast. We typically have 50 or so different simulation models (plus all the I/O) that have to run to completion 60 times a second. That's about 17ms, or 8ms if we want %50 spare. In addition, for a realtime app like a simulatior it needs to take the same time to execute every time (no runtime dynamic allocations, GC, etc.) or things "jitter".
Everywhere I've worked, with the exception of Ada mandated jobs, had this code done in Fortran. Yes that includes today. We are today writing new Fortran, and we are not alone. When we request models from the aircract manufacturers, they come in Fortran (or occasionally Ada). Fortran is still, and quite possibly always will be, the language for Scientific Computing.
Suggesting non-CS math and science students learn some other programming language instead is just wrong. Further suggesting that it should be the author's favorite hip new interpreted languge is just laughable.
I'm an engineer with a large aerospace firm. All our major programs are in Fortran and have to be used, modified, and maintained. I remember a few years ago we hired a new grad from MIT; she had studied Basic, Pascal, and C; so of course we had to teach her Fortran so she could do her work. The engineering world is heavily dependant upon Fortran, and to not know it puts you at a huge disadvantage.
Except I'm pretty sure that there are modern languages and libraries that can handle this without Fortran. I don't have much experience with it myself, but I'm pretty sure that's exactly what MATLAB is for, for one.
Dude, what do you think the libraries Matlab uses are written in? Check out netlib to get an idea, ATLAS, BLAS, LAPACK, LINPACK, etc. Matlab stands on the shoulders of the giants of scientific computing (implemented for the most part in Fortran).
The point everyone misses with Python is that Python was designed to play very nicely with external libraries. Python isn't as fast as C at some things, and isn't as fast as Fortran at some things, but is much easier to develop in than either, and can incorporate libraries in both of those languages.
You can eat your cake and have it to.
ad logicam Claiming a proposition is false because it was presented as the conclusion of a fallacious argument.
The Elders feel that if they had to go through it, so do the young'uns gol durn it!
Seriously, though - as far as I know, Fortran has always been the language of those humonguous numerical models because of its optimizations with regard to array handling. I think it makes perfect sense as a first (or second) language for science majors. However I imagine the person asking this question is likely one of the young'uns being forced to learn it; and that person doesn't really have the perspective as to *why* this is so. After all, he's been hacking around in C and Python for years - they're in his comfort zone and have been good enough for the sorts of things he's been dealing with.
#DeleteChrome
I'm a scientist who does the bulk of his programming in Python. Numpy (the numerical package for Python) runs at only a 30% overhead over C. When that's not fast enough, I drop into C/C++ for bottlenecks and wrap that back into Python (using the Python C API more often than swig/boost). When there's a great Fortran library that's fast and battle tested, I wrap that into Python using F2Py--and I don't even know that much Fortran.
Just like it's good to know more than one spoken language, it's good to know more than one programming language. It's a mistake to think one programming language fits all needs. That said, it can also be helpful to know one really well, and others enough to convert them into your primary language. For me, Python fills that role very adequately, and I would highly recommend it be a part (read: part) of the undergraduate programming curriculum.
Matlab stops being a 'slow' language once you learn how to use it.
Matlab stands for MATtrix LABoratory. It loves to do matrix algebra more than any other kind. The worst offenders I see are people that try to use for loops for everything.
for i=1:10
y(i)=sin(i);
end
is much slower than:
y=sin(1:10).
And it just scales up from there. There were only a very few times I've ever had to use for loops and that's because of memory issues (on Win32).
Unless your current state depends on the previous one, there is no reason to use a for loop.
-
I never learned FORTRAN, but I make my living on Matlab. Matlab is good for quick turn around. If I need to make a script NOW that does X for me, I can turn it around in a few minutes. No compiling, etc. If I really want speed, I can write MEX (compiled) code.
Back when I was in college, I maintained a Fortran77 program that was a custom built TCP/IP client-server system. But wait! F77 didn't know what a socket was! right. The network code was written in C and compiled into object code which was directly linked into the F77 project.
Great. So there are these massive libraries written in Fortran to do wonderful things. Best case scenario is you can link them directly into your language of choice. Worst case, call them from the scripted language of your choice with a wrapper
Bottom line? Program in what you are comfortable with. Would your peers would frown on your efforts if you learned anything but ALGOL? Fine. Use ALGOL. There are valuable lessons to be learned in any language. Strong vs weak typed, functional vs object oriented, structure, best practices
The surest way to corrupt a youth is to instruct him to hold in higher esteem those who think alike than those who think differently. - Nietzsche
"Glory is fleeting, but obscurity is forever." - Napoleon Bonaparte
It's definitely not a language for amateurs in the sense of people who like to fiddle with the system, are interested in how the compiler works, or who just want to make gee-whizz web mashups. It's a language for people who don't care a rat's *ss about computers or programming, but who need to get their calculations done without wasting time on fiddling with pointers and who need reliable answers without being bitten by silent array-boundary overflows to boot. So Slashdot might not be the best place to ask for an opinion.
Besides, most of today's numerical libraries (BLAS, LAPACK, ATLAS, EISPACK, FFT) are written in Fortran. If you want to use them, you could do worse than learn Fortran.
True, it's not a language you'd want to do sophisticated datastructures in, or tree-searches or text-processing or payroll accounting or database manipulation. But especially chemists (and to a lesser extent physicists) have more call for numerical software than they have for non-numerical software.
So no. It's not at all ridiculous to teach Fortran as a first programming language to non-computer-science students. Alongside Matlab (or Octave or Scilab) it will do fine for chemists.
Evidently, you don't go out that much. People use interpreted languages in science all the time. At least I do. Where I sit, there is quite a bit of spare capacity waiting. When I try to figure something out it is way more reasonable to write a program in three-four hours and have it run overnight than to write it in two days and have it run in (say) thirty minutes.
I would like to die like my grandfather did - sleeping. And not screaming in terror, like his passengers.
Not all scientific programming is heavy duty number crunching -- I'd suggest that only a minority is. My postgrad research proposal (involving Monte-Carlo simulation) said that I'd use Python for the framework and would swictch to C/C++ where Python got too slow. Python never did get too slow, and I never needed a single line of a C-derivative language. I also used Python for some continuation of Robert Axelrod's classic work on game theory (is that science, math, or psychology?).
Anyway, you're making the classic assumption that undergrads are taught the language for the sake of the language; that it will be the language they will use in the real world. Rather (even in the sciences, not just in computing) it's programming that's being taught, and the language is simply a means to an end. It's futile to try to double-guess what they will be using when they get out into the real world; even if you look at what's in demand now, no language has a monopoly and the language-of-the-moment will change anyway during their career. The person who can program Python will pick up any other procedural language quickly enough, because Python has pretty much all of the relevant constructs, and Python has the advantage of being easy to learn. FORTRAN certainly isn't easy to learn (I did my undergraduate project in FORTRAN), and even the newer versions of FORTRAN that have things like Object Orientation don't present the constructs as clearly as modern languages such as Python. I agree that Python is unlikely to be the only language they'll ever need (don't try saying that on the Python mailing list, though!) but it's at least a contender for the best first language.
Quidnam Latine loqui modo coepi?
If it were a computer science course then I'd say that something in the Lisp family, something in the OCAML or Haskell family, and somthing from the Prolog family. I agree that they're likely to encounter static typing at some point but this isn't a computer science course so it shouldn't try to teach everything, and static typing shouldn't come as too much of a shock. Heck, my first language was FOCAL, and I managed to learn to cope with it.
Quidnam Latine loqui modo coepi?
A program language should be taught on the basis that it teaches the student programming and not that it jigsaws them into the world of business. I student that can transcend languages is likely to be a better programmer anyways, as they'll have more tools and models with which to get a task done. Note that some languages are more suitable than others. For example, Python is useful in the academic setting, where a quick turnaround is important for meeting deadlines and finding solutions. In the business world, languages like C/C++/Cobol/Java might be more suitable for performance or legacy code. That being said, any student interested in programming should be taught languages that are based on different paradigms like structural, functional, object oriented, or shits-n-giggles code (intercal, befunge), that will ultimately enable the student to learn other languages which were not taught, more easily.
My favorite class with respect to this was assembly. It was fairly easy to pick up and taught you how the computer interpreted commands at a relatively low level.
That's because a married man has to spend so much time trying to figure out how to keep his staggeringly complex wife happy.
Python? As an intro language? And I thought people were misguided teaching Java as the first (and often only) language.
Second, while some of these scientific programs can run overnight, a lot of them will take a day or more to run, even when compiled and on a super or parallel computer. I don't know of any highly optimized Python compilers for big metal. Fortran is still the number one language for performance computing.
Third, there seriously needs to be major scientific libraries pre-existing for the language to be useful. An added benefit is being able to support more than one floating point number format.
Finally, the number one most important reason that Fortran is used in the sciences, is because everyone else uses it in the field. Seriously, what good is Python if all your prof's and advisor's and boss's programs that you need to maintain are in Fortran 66? It's faster to learn Fortran than to port it all. This is part of the "dusty deck" problem, where decades old libraries still have to be used and supported. This applies to many languages - many languages are popular precisely because they are popular, not because of inherent elegance or suitability.
In the sciences, the students are not being taught programming for the sake of programming, and they're not even being taught to write good programs necessarily. They're being taught to program as a mere tool for the important stuff being taught. Some classes may not even care what language you use, as long as you can read and understand the sample programs and the math library is correct.
Being in the sciences and not knowing Fortran will be a drawback. In some areas it may not be as big a drawback, but it will be there. This is like trying to do embedded systems without knowing C.
one aim should be to make tools that will serve skilled professionals--not to lower the level of expressiveness to serve people who can hardly understand the problems, let alone express solutions.
But shouldn't we keep an eye toward eventually moving into a Star Trek-like future, where anyone can ask things like, "Computer: is there a compound that is superconducting at 50 deg C? If so, what is the formula?" And the 48-core, terahertz processor cranks through sophisticated molecular models to find the answer.
That that is is that that that that is not is not.
I think you are mistaken regarding what most undergraduate science students actually do (they are not maintaining/upgrading old fortran libraries). Most of the high performance capability that undergrads need involves matrix computations, FFTs, convolution, etc., all of which are included in the python numpy/Numeric module (which is a wrapper around fortran libraries, so they're just as efficient). And since they'll likely spend as much time analyzing data as producing it, python + numpy + matplotlib is a perfectly suitable solution.
I'm not suggesting that fortran isn't of value to some scientists in some situations but many science students will never have to touch fortran code unless they're forced to take a class that teaches it. As you said: "They're being taught to program as a mere tool for the important stuff being taught." Which is why it makes sense that their intro language is one that is easy to learn, supports multiple programming paradigms, has efficient numerical libraries, has easy-to-use visualization tools, an interactive interpreter, and can be used as a general purpose programming language. And while I personally prefer python for a high level language, there are others that could serve the same purpose.