Is FORTRAN still relevant in modern programming?

  • Fortran
  • Thread starter Tone L
  • Start date
  • Tags
    Fortran
In summary, the conversation discusses the use of FORTRAN in scientific computation and its advantages and disadvantages compared to other programming languages such as Python, Julia, and C/C++. While FORTRAN is known for its speed and powerful numerical libraries, it is not as popular among younger programmers due to its outdated syntax and lack of flexibility for other types of programming. However, it is still preferred by many scientists and engineers for its ease of use and proven reliability in certain applications. The conversation also mentions the possibility of using a combination of different languages (such as FORTRAN, Python, and Julia) for optimal performance and flexibility in programming.
  • #71
FactChecker said:
Yes, Lisp has an 'eval' capability. I admit that I forgot about Lisp, but I suspect that most of today's CS majors are less familiar with Lisp than they are with FORTRAN.
I doubt that there is a two line example of Lisp code that will define a list of variables (all others protected) and read any subset of them in from a text file. It should have properties similar to those I mentioned in post #68 above. I also doubt that engineers and scientists would happily switch to Lisp from FORTRAN.
There were some nifty applications which still used Lisp, but it's on the wane, too.

There was a symbolic algebra package called Derive which used something called muLisp, and it was surprisingly easy to use. Derive eventually got gobbled up by Texas Instruments and is no longer available as a stand-alone piece of software, but its symbolic algebra is used in some of TI's calculators.

The drafting package AutoCAD was originally written in Lisp, but I understand the core program was eventually re-written in C at some point. Because users could write routines in Lisp to add their own features to early versions of AutoCAD, the non-Lisp editions still had a Lisp interpreter built into the software to allow backward compatibility.

I didn't mean to insult CS majors, I just wanted to point out that there are things in FORTRAN that are useful to engineers and scientists but are not readily available in other popular languages today.

I wouldn't sweat it.

CS types have always been dissatisfied with any computer language which existed before last Tuesday. They've been trying to kill older languages like Fortran almost since they day they were introduced, and it must be galling to them that Fortran is not only still around, but it's been updated with a lot of their recommendations as to what features a "modern" language should have.

Of course, the newer Fortrans are a lot more bloated than say, Fortran 77, and it's becoming harder to write compilers capable of digesting all the new features and still generate reasonably efficient code, but it still bugs the CS types even more it seems that someone actually listened to them, and poured all that additional effort into extending the life of one of the first computer languages.
 
  • Like
Likes FactChecker
Technology news on Phys.org
  • #72
FactChecker said:
Yes, Lisp has an 'eval' capability.

That's not what I meant. EVAL and similar functions will blindly evaluate arbitrary Lisp code. I understood that you meant something more specific and controlled.

I was pointing out that, roughly, variable names are a supported data type in Lisp that you can manipulate just like numbers or arrays. For example, you might have a variable var whose value is the symbol x. Then doing (set var 3) would set x (not var) to the value 3.

I doubt that there is a two line example of Lisp code that will define a list of variables (all others protected) and read any subset of them in from a text file. It should have properties similar to those I mentioned in post #68 above.

Well there isn't a two line example for Lisp for the same reason there isn't a two line example for sorting an array in Fortran: there doesn't happen to be a predefined function in the language that will do it. You could write one though.

Here's a simplified example that meets the most basic condition you asked for (a function that will read variable assignments from a file stream, and only assign the variables that are also in a user-supplied sequence), just to show it's possible:
Code:
(defun load-namelist (namelist &optional (stream *standard-input*)) 
  (dolist (assign-form (read stream))
    (destructuring-bind (var . val) assign-form
      (when (find var namelist)
        (set var val)))))

For example, suppose you have a file "vars.txt" with the contents
Code:
((b . 20)
 (c . 30))
You could use the function I defined above like this (example REPL session, return values omitted):
Code:
> (defparameter a 1)

> (defparameter b 2)

> (defparameter c 3)

> (format t "a = ~d; b = ~d; c = ~d~%" a b c)
a = 1; b = 2; c = 3

> (with-open-file (fs "vars.txt")
    (load-namelist #(a b) fs))

> (format t "a = ~d; b = ~d; c = ~d~%" a b c)
a = 1; b = 20; c = 3

This sets a few variables, runs the load-namelist function on a file, and prints the variable values both before and after processing the file. Notice that a retains its original value (because there isn't a new value for it in the file) and c also retains its original value (because it wasn't in the supplied vector #(a b)).

Of course, this could be refined to do more sophisticated things, like assign individual array elements and/or scan an input stream only for a specific, named, namelist, but you get the idea.
 
Last edited:
  • Like
Likes FactChecker
  • #73
wle said:
That's not what I meant. EVAL and similar functions will blindly evaluate arbitrary Lisp code. I understood that you meant something more specific and controlled.

I was pointing out that, roughly, variable names are a supported data type in Lisp that you can manipulate just like numbers or arrays. For example, you might have a variable var whose value is the symbol x. Then doing (set var 3) would set x (not var) to the value 3.
I didn;t know that about Lisp. I admit that is very powerful and would give you the desired capability. Even though it would take some work to make a namelist tool, that would be very possible.

Well there isn't a two line example for Lisp for the same reason there isn't a two line example for sorting an array in Fortran: there doesn't happen to be a predefined function in the language that will do it. You could write one though.
I agree. But one nice thing about FORTRAN was that they recognized that easy I/O to text files was so valuable for engineers and scientists. I consider namelist one of the best text I/O capabilities in any language.

Here's a simplified example that meets the most basic condition you asked for (a function that will read variable assignments from a file stream, and only assign the variables that are also in a user-supplied sequence), just to show it's possible:
Code:
(defun load-namelist (namelist &optional (stream *standard-input*))
  (dolist (assign-form (read stream))
    (destructuring-bind (var . val) assign-form
      (when (find var namelist)
        (set var val)))))
I stand corrected. That is very good. I like it a lot.
 
  • #74
Well, this " Fortran, is it outdated? " thread certainly triggered a lot of replies...keep it up, guys, we don't want the " is Latex still relevant? " thread catch up :wink:
 
  • #75
Since most of my programming has been in the "close to hardware" section (some people call it "system programming"), FORTRAN is not an option.

Somebody likes FORTRAN, though (see http://web.mit.edu/humor/Computers/real.programmers).
 
  • #76
Svein said:
Since most of my programming has been in the "close to hardware" section (some people call it "system programming"), FORTRAN is not an option.

Somebody likes FORTRAN, though (see http://web.mit.edu/humor/Computers/real.programmers).

If you really wanted to you could (with the right hardware :DD). https://en.wikipedia.org/wiki/PRIMOS
An interesting feature of PRIMOS was that it, like UNIX, was largely written in a high level language (with callable assembly language library functions available). At first, this language was FORTRAN IV, which was an odd choice from a pure computer science standpoint: no pointers, no if-then-else, no native string type, etc. FORTRAN was, however, the language most known to engineers, and engineers were a big market for Prime in their early years.
 

Similar threads

  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
  • STEM Academic Advising
Replies
5
Views
2K
  • Programming and Computer Science
Replies
7
Views
4K
  • Programming and Computer Science
Replies
10
Views
5K
  • Programming and Computer Science
Replies
14
Views
3K
  • Programming and Computer Science
Replies
13
Views
5K
  • STEM Academic Advising
Replies
3
Views
963
  • STEM Academic Advising
Replies
4
Views
2K
Back
Top