No love for FORTRAN?

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

No love for FORTRAN?

Post by cbmeeks »

OK, I've tried and tried to learn Forth. I know it's a popular language around here. And, despite being a developer by trade, I just can't wrap my head around it.

I understand how Reverse Polish Notation works. But I just don't think that way. Sigh...

Anyway, I was reading some old BYTE ads (circa 1978) and I noticed just about every computer ad claimed compatibility with FORTRAN IV.

So, anyone here ever work in FORTRAN? Either professionally or otherwise?
Cat; the other white meat.
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Re: No love for FORTRAN?

Post by 8BIT »

My only use of FORTRAN was a college FORTRAN class on a TI mainframe. As I recall, it is a number crunching program that worked in fixed decimal. It was a great tool for business database and column-type reports, but not really designed for anything graphic intensive. I never used it outside of that class.

Daryl
Please visit my website -> https://sbc.rictor.org/
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Re: No love for FORTRAN?

Post by cbmeeks »

That's cool.

According to Wikipedia, it's still used for really computational tasks like weather prediction, traffic analysis, etc. But I guess Forth is the "new kid" in town, being a young language of 48 years. :-)

Fortran, being 61 years old.
Cat; the other white meat.
Martin_H
Posts: 837
Joined: 08 Jan 2014

Re: No love for FORTRAN?

Post by Martin_H »

My last use of FORTRAN was in 1985 for a numerical computing class, and there have been several revisions to the language since that time. I recall it being a straight forward language, but lacking the expressive power compared of Pascal and C, or the elegance of Lisp. However, that simplicity is what made it so fast, and why it flourished in numerical computing.
Tor
Posts: 597
Joined: 10 Apr 2011
Location: Norway/Japan

Re: No love for FORTRAN?

Post by Tor »

My first FORTRAN program was something I wrote in 1982 to read CP/M 8" SS/SD floppies, on the minicomputer I used. I still have that code (and some more code) on my computer, copied from old CCT backups. The compiler on the mini had just a few extensions that made it great for processing data buffers and strings.

Since then I wrote a bit of FORTRAN, and maintained even more. I much preferred Fortran-77 over earlier versions though. The code could be made very structured and nice when using proper coding standards. What surprised me most was when we forwarded new coding standards to the mathematician who wrote some highly advanced (and huge!) code for data processing, with a humble suggestion of using it for newly developed code. What we got back was the whole thing, now nicely formatted and structured. Readable to this day, and at one point I wrote a translator to convert it to Pascal.. it actually worked. Something I did just in order to test it on the new-fangled PCs that started to show up.
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: No love for FORTRAN?

Post by drogon »

I've worked in FORTRAN, but I'd not say extensively. More to support some other stuff and I did have a summer job porting a FORTRAN project to (apple ucsd) Pascal once upon a time

Is there (was there?) a 6502 FORTRAN system? (a quick google suggests there was at least an Apple version, but I don't recall ever seeing it)

From a language point of view, if you can do BASIC you can mostly do FORTRAN (well, older FORTRANs, anyway) It was (is) liked in the scientific community due to complex number handling and there are some really whacky compilers now (and in the early 90's when I last dabbled) that would recognise certain things like nested loops going over an array and vectorise the code for you for the target processor (e.g. cray)

Today? Other than curiosity, I'd give it a miss, however how many of us use I (and J, K, L, M and N) as loop variables in other languages? That comes from FORTRANs implicit number types - if a variable started with the letters I through N then it was implicitly an INteger ...

-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: No love for FORTRAN?

Post by barrym95838 »

I'm with drogon on all of his points. I learned some FORTRAN 77 on a CDC mainframe back in the mid-80s, but it looks like the language has seen substantial additions since then, judging by a few of the code examples here.
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

Re: No love for FORTRAN?

Post by BitWise »

My final year project at University was 'Implementation of the Graphical Kernel System (GKS) in Fortran 77'. GKS is a standard 2D graphics API. I wrote the library and all the demo programs in F77 including the device drivers for the graphics terminals. I only had two PL/1 functions (to interface with Multics) to enable and disable raw character output.

After graduating I worked on an Oil/Gas field analysis package for UNIX that was largely coded in F77 on top of C libraries for X Windows, dynamic memory and data base access. I mainly worked on C but I did my fair share of the F77 as well.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
Uncle Warthog
Posts: 14
Joined: 24 Oct 2017

Re: No love for FORTRAN?

Post by Uncle Warthog »

drogon wrote:
Is there (was there?) a 6502 FORTRAN system? (a quick google suggests there was at least an Apple version, but I don't recall ever seeing it)
I have Apple Fortran but it isn't a 6502 compiler; It runs under Apple's Pascal environment and compiles to UCSD P-Code.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: No love for FORTRAN?

Post by BigEd »

Looks like there was a Fortran for Acorn's BBC Micro, but again it's not a compiler - some kind of interpreter.
https://stardot.org.uk/forums/viewtopic.php?p=75039

Fortran is not unlike Basic, except no strings, IIRC, and usually compiled. Some of the best optimising compilers were for Fortrans.
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: No love for FORTRAN?

Post by whartung »

Uncle Warthog wrote:
drogon wrote:
Is there (was there?) a 6502 FORTRAN system? (a quick google suggests there was at least an Apple version, but I don't recall ever seeing it)
I have Apple Fortran but it isn't a 6502 compiler; It runs under Apple's Pascal environment and compiles to UCSD P-Code.
Yea, UCSD had a P-Machine Fortran. I've never seen or used it. They also had a BASIC.

My Dad had a copy of Fortran for the TRS-80. I spent a couple of days, even borrowed a book on Fortran, trying to suss it out to no avail.

It was my first programming classic college, and we got to use Fortran V/Fortran 77 (as in 1977). Fortran V was much better, it was much easier for character work (just say no to Hollerith kthx). Fortran 4/IV was known as Fortran 66 (1966).

The microcomputer was not the typical environment in which Fortran was used, so the book wasn't super helpful. Great for the language, but I couldn't even get "Hello World" to work. So, I left it.

In Fortran V:

Code: Select all

       PROGRAM TEST
       WRITE(*,*) 'HELLO WORLD'
       END
Pretty sure that's close, and that "just worked". The problem I was having on the TRS-80 was that I had no idea what the unit numbers were for reading and writing the keyboard. And I didn't even know I was looking for unit numbers. The "*,*" specified the unit number and... something else...a format line? Maybe? Anyway, I think in the end, they were like 2 and 3 on the TRS-80, (maybe it was 4 and 5, but like stdin and stdout, the mappings are "common knowledge"), but I didn't know that. The book I was reading was talking about cards and tape drives. Not really helpful.

I wrote a simple BBS in Fortran back in the day.

And I will say this about Fortran. Before college, I was working on PETs and the TRS-80. In College I got dumped in to a time share CDC Cyber 780 mainframe. Let me tell you how utterly different these two environments are. From PET BASIC to NOS with a line editor (XEDIT) and Fortran.

I don't think I could have picked a better thing to have done than Fortran on the Cyber. They were great examples of the commonality of computing, along with their vast differences. Cryptic job control language vs BASIC. Disk files and persistent storage. Data record processing (which I had little experience with in BASIC, having done only a class grading program for a teacher). 60 bit words vs 8 bit. But also, a multi user system vs standalone. Way different, but much the same as well.

It was great to let someone use the differences and details to focus on the abstractions that they represented. It (to me) was important to have that experience early rather than later. One of my computing epiphanies. (First was INPUT and PRINT and simple expressions in BASIC, second was Arrays, third was this with fortran, and utterly different computer architecture, 4th was dynamic memory and pointers in Pascal -- the light that goes on when you keep a linked list in your head, it's bright one, and, finally, let and lambda in Scheme, and all the AHA that brings).

I took to the mainframe environment like a duck to water. Later, when I saw everyone learning on PCs with DOS and Turbo Pascal instead of the Cyber or PDP, it was just...a sad day.

The only reason for Fortran on micros is to port other code. As others have said, it's just not expressive enough for what most folks want to do. Not easily. No doubt there were Fortran extensions that would let you Peek and Poke in to raw memory. But Fortran was noted for it's floating point math, its first class COMPLEX math, masterful array handling, and all the scary hacky fun times that can be had with static data, and infinite ways to map in to them. Thank you Mr. COMMON Block.

Micros back in the day were not Floating Point powerhouses, so "real work" was done on "real computers" with Fortran.

I did many early Data Structure assignments in Fortran, grateful I didn't have to write any compilers in it.
Tor
Posts: 597
Joined: 10 Apr 2011
Location: Norway/Japan

Re: No love for FORTRAN?

Post by Tor »

drogon wrote:
That comes from FORTRANs implicit number types - if a variable started with the letters I through N then it was implicitly an INteger ...
One of the coding standards we introduced was a mandatory 'implicit off' pragma. That's the most important one we ever introduced. With tons of code there will always be typos, which would go unnoticed with implicit types.

As for strings.. Fortran had (and have) strings, but the compiler I used had some extra extensions which made them even more useful. You could for example use -1 to indicate white space begins/ends, in order to easily strip whitespace from a string. That was particularly useful for command line processing.

A character string " abcdef " addressed as (1:-1) would become
" abcdef", or (-1:-1) just "abcdef"

Edit: Typo
Last edited by Tor on Wed Oct 03, 2018 9:39 am, edited 1 time in total.
User avatar
barrym95838
Posts: 2056
Joined: 30 Jun 2013
Location: Sacramento, CA, USA

Re: No love for FORTRAN?

Post by barrym95838 »

Tor wrote:
... With tons of codes there will always be typos, which would go unnoticed with implicit types ...
A read a story several years ago about a guy who was reviewing a gigantic FORTRAN program in preparation for translating it or upgrading/extending it, and decided to write a script to do some automated analysis of the source. This was working code, but his script found a variable buried deep within it that was initialized but never used. The initialized value was 1.2 and the variable was named something like DO31670I ... doh!
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)
resman
Posts: 154
Joined: 12 Dec 2015
Location: Lake Tahoe
Contact:

Re: No love for FORTRAN?

Post by resman »

Although FORTRAN was never big on the 8 bitters, it was successful on the IBM PC (especially on the 386 and above). My good friend Tom Lahey had a Fortran company and he liked to relate a story about a user who had a program he would run on a Cray, but it was expensive and the queue time was 24 hours. With a PC and Lahey Fortran, he could run his code locally and get his results after 24 hours of runtime. So he reached price and performance parity with a Cray using a PC.
User avatar
Druzyek
Posts: 367
Joined: 12 May 2014
Contact:

Re: No love for FORTRAN?

Post by Druzyek »

I found a very old FORTRAN book at my local library in high school one summer and spent a lot of time playing with it on our PC. FORTRAN 90 and 95 were out by then but I didn't know anything about them since they weren't mentioned in the book. I got used to doing output like WRITE (10, 500) before I found out about WRITE (*,*). Later I started using Force Fortran, which has a color coded editor but the compiler (at least at the time) was not that great. I got a copy of Salford Fortran, which can do fancy graphics, and tried redirecting the output of the Force editor to the Salford command line compiler. Unfortunately, Force would hang since it somehow kept track of the execution of whatever program it thought was its compiler (and any programs that program started) and didn't expect it to keep running, so you couldn't just replace its compiler with renamed Salford files. My solution was to replace the Force compiler with a small program that passed the name of the file to compile to a daemon running in the background then quietly exited to appease the editor while the daemon compiled and ran the program with the Salford compiler. I think this qualifies as my very first hack :D
Post Reply