tags:

views:

557

answers:

9

I’m advising another person who has no programming education or background (beyond trying out AutoLISP and Excel VBA once or twice), who runs scientific simulations using Fortran software written by others and who now finds she’d benefit from being able to program in Fortran herself.

I can see two main approaches to this:

  1. Learning e.g. Python as the first language (in order to avoid getting trapped into legacy thinking) and then dive into the legacy of Fortran working backwards in time from Fortran 95.

  2. Skip the indirection with a contemporary language and start directly with Fortran 95 and dig backwards from there.

So my questions are:

  1. Should someone who’d mainly need Fortran just start with Fortran or learn a non-legacy language first?

  2. How much effort one should expect to put into learning before being able to do some useful simulation work in Fortran?

I’ve read the SO question about learning Fortran in the modern era, but it seemed to be about a case where the person learning Fortran is already a software developer.

+8  A: 

I think she should learn the language she has use for immediately (Fortran), and then branch out into other languages from there. An idea that seems to be prominent in programming circles is the idea that exposure to certain programming languages can "scar" a person and make them unable to learn new ways of doing things. This is not really so.

MusiGenesis
I've seen it happen; several people with previous experience with C++/VB/etc. (Java didn't exist back then) at my university program had serious issues with functional/declarative programming languages.
JesperE
Then, maybe they'd have had the same problems if they'd started with modern languages right away, no?
Kena
I would also note, that this person isn't headed for a career in programming. She wants her simulations to run.
Todd
It makes sense to learn the language in which the tools you use are written, regardless of what else you should learn.
MusiGenesis
Real Fortran 77 (not WatFor or the DEC style mid eighties Fortran) is primitive indeed (i.e. all goto all the time), and will tend to teach the kinds of habits decried in "Basic Considered Harmful". But a program still in use is probably in structured fortran, so there is less difference.
dmckee
+1  A: 

You should NOT start with fortran. I have a close friend who found herself in a similar situation. She was writing Physics simulations in C. I taught her python, and she rewrote the simulation such that it executes in 1 hour instead of 1 week. Starting with a legacy language like fortran will limit your ability to reason about problems, and it will make it harder to write fast code. Most anything that can be done in fortran can be done in a more modern language as well or better than in fortran.

Benson
Saying that language X limits your ability to solve problems is a defensible point (all languages are limited in some way), but saying that language X limits "your ability to reason about problems" is a much stronger statement, and not really defensible IMHO.
MusiGenesis
unless you're talking about BASIC ;-)
Steven A. Lowe
In many ways a higher level language (i.e python) lets you reason more about the problem, whereas a lower level language (i.e c) makes you reason more about the details of the solution. In most cases, the less code you have to write, the better.
Tom Leys
I think you may not be familiar with modern fortran. Of course, it is likely that your friend's teachers were also unaware of it.
Marcin
A one week to one hour speedup? I doubt that changing languages alone was responsible for that. If the original implementation ran in a week and the second ran in an hour, I would suspect the implementation was faulty rather than the language made that much difference.Indeed, python programs can make calls to routines written in other languages like c, fortran etc. This is often done to farm off compute-intensive sections to efficient compiled code.
mataap
Yes, the original implementation was faulty. However, the new implementation was better because python provided facilities to make it easy to make it better. It's not about what the language makes possible, it's about what the language makes easy.
Benson
A: 

Learning to program is much easier when properly motivated. Learning Fortran first will naturally affect how she thinks about programming; but this does not necessarily have to be bad. (There has been several studies about how to figure out which people have a "natural talent" for programming, and one study (I've forgotten the details) showed that programming ability was highly correlated to the ability of constructing consistent mental models of problems and being able to follow this mental model (even if it in fact was incorrect.))

JesperE
A: 

If she's going to mostly be working with legacy code in Fortran, I'd stick to Fortran. Knowing Fortran isn't going to hold anyone back from learning other languages. Learning Fortran will get her up and running more quickly and allow her to leverage more of the code she has at her disposal to model from. Fortran was a pretty simple language in terms of the constructs that are available. It's not like she needs to learn OOP in a simpler form before tackling a big project in language X. It's 6 spaces and an IMPLICIT NONE away from BASIC. Start there and get simulating.

Todd
+5  A: 

I think that she should start with modern Fortran. The addition of modules, derived types, array intrinsic functions, and improved loop constructs make Fortran 90 and forward much easier to work with than the older, deprecated, and truly "legacy" FORTRAN 77.

Will her introductory experience affect how she thinks about programming? Of course. If it was FORTRAN 77 you were asking about, I would have to say start with something else. However, with modern Fortran, you can learn about objects, data hiding, recursion, pointers, dynamic memory allocation, and more - techniques that will definitely serve her well when it comes to branch out into other languages.

To directly answer your questions, then:

  1. Someone who will mainly need Fortran should learn modern Fortran.

  2. One needn't put in a great deal of time to be able to do useful simulations, particularly if other code/libraries are available as a starting point. I find that this is where the built-in array support can come in very handy.

Tim Whitcomb
A: 

Have her learn FORTRAN. If she decides to learn other programming languages latter, then go with a more modern language. If she does it the other way around she will be frustrated by the restrictions of FORTRAN. She also would have to expend twice the effort to learn two languages if she starts with something other then FORTRAN. I know many people say that learning the second language should be easier then the first, I think this is only true if they are similar.

contrary to popular belief learning older languages do not cause mental defects (we older programmers were that way to begin with).

Jim C
A: 

If she's got what it takes, then Fortran 95 is probably as good a place to start as any. Fortran 95 isn't a terrible language. It has decent control structures and can support structured programming. Plenty of good programmers started with worse languages, such as Fortran 66 or 77 or microcomputer Basics that only allowed two character variable names and only had for loops and goto for flow control.

Glomek
A: 

For understanding simulations, it might be better to start with something like Smalltalk. Squeak is a free environment. The main advantage of using Smalltalk to start building simulations is that it allows one to focus on getting a well-structured solution. Smalltalks have the best development environment (refactoring browsers, debuggers, live inspection of object memory). Once you run into performance issues, migrate to fortran. One thing to look into is the availability of libraries for the simulation domain. It could be that in a different (modern) language the availability is much better. That might shift my advice to a different language.

Stephan Eggermont
A: 

Why does she think she'll benefit from writing FORTRAN herself?
I am supposing it is so that she can work with the simulations she uses, therefore she should learn that FORTRAN first.
If she then finds that she likes programming and wants to do something aside the simulations, she can come back to you and start the conversation again with a different persepective.

jsfain