Hacker News new | ask | show | jobs
by TazeTSchnitzel 1930 days ago
It took until C99 for C to have complex numbers and `restrict`. Those are two features FORTRAN has had for a much longer time, right?
3 comments

You're testing my memory now. If I recall correctly, at least complex numbers were in the WATFOR (University of Waterloo) FORTRAN-IV compiler that I used in 1968 on the System/360. (That said, I've always understood it was there from at least FORTRAN II.)

I seem to recall needing 'i' for vector stuff, Maxwell's equations etc. (If I'm wrong it must have been on the VAX FORTRAN-IV several years later.

Correct me if I'm wrong.

And like in everything C, unlike Fortran, there is no way for the compiler to validate if restrict is being used properly.

Use it wrong, break the compiler assumptions and the bug hunting fun starts.

Mostly the compiler won't catch violation of the storage association rules. Toolpack had a useful tool for strict F77 code which was a boon fixing stuff not to break with the Alliant compiler, which was the first one the project I inherited used that took advantage of the optimization opportunity. Possibly Cray's would have done, but hadn't been used for a while at that point.

The fact that people won't believe the rules exist, is a continual source of bug hunting in Fortran unfortunately. At least restrict is visible.

How does Fortran enforce this, actually? Does it just not let you pass the same array to a function via multiple parameters?
Fortran didn't originally have pointers, and pointer based code is relatively rare in fortran, so making requirements about pointer aliasing doesn't have same potential to completely break your code that it does in c. The reason c can't actually restrict the restrict keywoard, is that the standard would break code!
The storage association rules have nothing to do with pointers like that. Code will typically break because arguments are passed with copy-in/copy-out semantics, not by reference.
It does, indeed, but that's not the only way to associate storage. Using INTENT to specify whether an array is updated is useful.
I __think__ Fortran just never gave you this particular footgun. No aliasing of pointers allowed from the getgo. It was never an issue. Somebody let me know if that is wrong.

I read Complex numbers came in FORTRAN IV, so mid 60’s.

I never used anything older than FORTRAN 77, and it certainly had complex numbers, and also ways for the “inventive” programmer to make use of pointer like functionality. You could e.g. pass functions to functions, if you were so inclined.

"I read Complex numbers came in FORTRAN IV, so mid 60’s."

FYI, this link [PDF] https://personalpages.manchester.ac.uk/staff/paul.johnson-2/... contains the peculiar statement "Over the next few years, FORTRAN II would also add support for the DOUBLE PRECISION and COMPLEX data types."

At face value, that statement implies complex numbers came later but before FORTRAN III, which also implies a point release (FORTRAN II was released in 1958). Moreover, I read somewhere that FORTRAN III had it but it wasn't widely released. Likely then that FORTRAN IV was the first widely released version with complex numbers. As it was released in 1961, we should assume then that this was the likely date.

Pretty cool, thanks for the details! This is about what I’d expect from ancient FORTRAN. (I read fortran IV off Wikipedia, maybe there was fine print)
You'll note from one of my other posts that FORTRAN-IV was my intro into programming. However, that was toward the end of the decade not the beginning. By then, many universities were running the WATFOR FORTRAN-IV compiler from U. Waterloo.

At the time it was anything but ancient. We students felt both cocky and privileged in that we knew that we were some of the very few people in the country who had access to a state-of-the-art IBM mainframe.

BTW, the mainframe, a System/360, had just 44kB memory and ran 7 concurrent operations at once. It was a red-letter day when the '360 got upgraded to 77kB memory. The university's rag had the fact as large headlines on its front page.

I like it! Sorry to call older dialects ancient. Being a Fortran programmer is somewhat like being from a red state, I find. I naturally self deprecate (or stick with c++ as appropriate) in front of others.

I used to work on a system that was older than me, but immaculately refactored (to the authors admittedly rare taste) through the years. It had run on all kinds of hardware in the 80s, but was different enough from its predecessor programs that I am not sure what all it ran on - I recall maybe DEC, maybe pdp this and that, maybe a 360?? being mentioned. The guy who led the team that wrote it passed on two years ago now. Man he was a trip! He wasn’t old. He used to smoke, darn it.

Sounds like you had some fun times with the 360! Makes me want to retro-compute a bit. Actually my phone makes me want to retro compute as well, every time I “type” on it. ;)

Cheers!