9 ms·
Fortran 2023
- hardmaru 3y agoFor a summary of changes to the language, see John Reid's slides here: https://fortran.bcs.org/2022/AGM22_Reid.pdf https://fortran.bcs.org/2022/AGM22_Reid.pdf More info, The Home of Fortran Standards: https://wg5-fortran.org/ https://wg5-fortran.org/
- theodorethomas 3y agohttps://wg5-fortran.org/N2201-N2250/N2212.pdf https://wg5-fortran.org/N2201-N2250/N2212.pdf is John Reid's complete document.
- fithisux 3y agoas a funny note John Reid was the singer of Nightcrawlers in the 90s.
- krylon 3y agoThat is funny. Interesting career trajectory.
- fithisux 3y agoWhich FOSS compilers support it?
- rsecora 3y agoflang [1], it's part of the LLVM project. [1] https://github.com/llvm/llvm-project/tree/main/flang https://github.com/llvm/llvm-project/tree/main/flang
- certik 3y agoGFortran, Flang and LFortran are all open-source compilers that support modern Fortran.
- pklausler 3y agoIf "it" is F'23, then none. GNU Fortran has had the "new" degree-unit trig functions for a while, but no compiler, FOSS or otherwise, has the newly invented features of this revision. Fortran doesn't prototype features with real implementations (or test suites) before standardizing them, which had led to more than one problem over the years as ambiguities, contradictions, and omissions in the standard aren't discovered until years later when compiler developers eventually try to make sense of them, leading to lots of incomplete and incompatible implementations. I've written demonstrations for many examples and published them at https://github.com/klausler/fortran-wringer-tests/tree/main https://github.com/klausler/fortran-wringer-tests/tree/main .
- thechao 3y agoDang ternary operator. I wish ternary was "open": X ? A : B : ... Z; Where the value of each expression counted down from A..Z, ie, of there's 8 limbs, then A is 7, B is 6, ..., Z is 0.
- smegsicle 3y agoyou want a one-line switch expression??
- thechao 3y agoYes; not often, but, yes.
- gamache 3y agoSounds similar to computed GO TO, as in: GO TO (LABEL1, LABEL2, LABEL3, LABEL4) I https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn9l/index.html https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn9l/inde...
- nittanymount 3y agohmm, wonder which fields people are using fortran now ? did a search, ha - numerical weather prediction, - finite element analysis, - computational fluid dynamics, - geophysics, - computational physics, - crystallography and computational chemistry.
- ravenstine 3y agoI wonder exactly why that is, though. I imagine it has more to do with historical use of Fortran in those fields than anything that Fortran specifically has to offer. There's no real reason to switch to another language, I suppose, except that you're limiting yourself to a much smaller pool of talent. Maybe learning Fortran "proves" one is passionate enough about one of these fields? Or requiring Fortran keeps out hordes of undisciplined JavaScript developers. EDIT: Wow, I didn't expect so many informative and reasonable replies. Kinda makes me want to check out Fortran. Thanks y'all!
- smacke 3y agoFortran can be faster than C because it has a more restrictive memory model (compiler can make more optimizations when it knows nothing else is aliasing some memory)
- klez 3y agoIs there no way to apply such optimizations to C code as long as the developer adopts certain standards in writing code?
- jerf 3y agoIn principle yes, in practice, no. This is one of those places where our developer intuition fails us, and I fully include mine. It feels like it ought to be feasible, even now, but in practice it turns out that there are just so many ways to screw up that optimization without realizing it, with responsibility for it scattered between compilation units (which is to say it isn't even necessarily clearly one things fault, these can arise in interactions), and once it creeps in just a little bit it tends to spread so quickly, that in practice it is not practical to try to exclude the problems. You can't help but write some tiny crack it sneaks into. This is part of why I'm in favor of things like Rust moving borrow checking into the langauge. In principle you can statically analyze all of that in C++ with a good static analyzer, in practice, it's a constant process of sticking fingers in broken dikes[1] and fighting the ocean. Sometimes you just need a stronger wall, not more fingers. [1]: https://writingexplained.org/idiom-dictionary/finger-in-the-dike-mean https://writingexplained.org/idiom-dictionary/finger-in-the-...
- fortran77 3y agoHooray! But I’ll stick to fortran77
- xeonax 3y agotrue to the username!
- findalex 3y agoCommon blocks for the win.
- UncleSlacky 3y agoI can write Fortran 77 in any language!
- fuzztester 3y agoYou be one good Blub programmer. pg can write Lisp in any language! Heck, pg can write any language in Lisp! pg can even write On Lisp!
- pklausler 3y agoF’23 doesn’t have much in it that’s new over F’18, which itself was also a pretty minor update to F’08. One thing to watch out for: in a departure from former commitments to compatibility, F’23 changes some semantics of working conforming code, specifically allocatable characters being used for internal writes, iomsg=, &c.
- imachine1980_ 3y ago> allocatable characters being used for internal writes can you explain this ?
- pklausler 3y agoIf you allocate a character object, then write to it with an internal write statement, F’23 now requires that the variable be reallocated to the actual length of the formatted record, instead of retaining its former length and being padded out with blanks (or truncated). The LLVM Fortran compiler (Flang) has warnings for various usages whose semantics would change if F'23 semantics were adopted by default, which I'm not sure I want to do.
- EE84M3i 3y agoI've never used fortran so I'm not sure what a character object or an internal write is, but in C would this be something like allocating a character array and sprintf-ing to it?
- pklausler 3y agoThat's a good analogy, with the change being that sprintf is now somehow required to reallocate your buffer on every call if the length ever changes.
- bee_rider 3y agoIt must be hard to update a language that was already perfect in 1990.
- v8xi 3y agoI learned Fortran for a summer research job in college about 15 years ago. It was my first programming language and I used it to do some population modeling. I found an old Fortran book from when my dad went to school back in the early 70s and learned it from that which was a cool experience - I just had to skip over all the parts about entering your code into punch cards :D
- hnlmorg 3y ago> I just had to skip over all the parts about entering your code into punch cards Haha I bet that was a fun and weird experience.
- m463 3y agoA shame to skip the IBM 029 experience. (separate issue from drum cards with a skip)
- deleted 3y ago[deleted]
- jonjacky 3y ago> I just had to skip over all the parts about entering your code into punch cards A few years ago I worked with a scientist who used a huge Fortran program with a long history. He described the lines in a text file that configured the program: "On the first card you put ... on the next card you put ..." They still call them cards! He was born after actual punch cards went out of use.
- dcchambers 3y agoAbsolutely wild to me that you need to buy access to a digital PDF of a spec for a programming language in 2023.
- krylon 3y agoIt's kind of the default for ISO standards, not just for programming languages. Ada is - to my knowledge - the exception, the standard document and the rationale are available free of charge. However, the draft documents are usually available for free, and the difference between the final draft and the official standard is usually miniscule (typos, punctuation errors, and so forth). You can probably find it on the working group's web site.
- trws 3y agoYup, this. The final version the committee actually works on is free for C, C++ and Fortran. After that ISO has it. I’m honestly not sure I would trust the final as much as the final draft. You can also build the c++ spec from the latex for yourself, the repo is public.
- jt2190 3y agohttps://wg5-fortran.org/f2023.html https://wg5-fortran.org/f2023.html
- krylon 3y agoThank you very much!
- peppermint_gum 3y ago> However, the draft documents are usually available for free Unfortunately, not for SQL :(
- creer 3y agoIt's the default but are these orgs really getting significant funding from that kind of end-user hostile behavior? (And some drafts are available and sufficient but not in all fields)
- mike_heffner 3y agoJust in time for Advent of Code.
- marshallward 3y agoUnfortunately I don't think the compilers will add it in time.
- aborsy 3y agoNumpy probably calls Fortran and C libraries under the hood. Is Fortran still considerably faster than Numpy?
- bee_rider 3y agoThe overhead of a function call should be O(1) (I mean it must be, right?), and then most of the functions are probably O(N), where N is the size of the vector, at least. So, as long as most of the work is in the C or Fortran library, it should be about the same.
- adgjlsfhk1 3y agothe problem is that O(1) here can be hundreds of nanoseconds which has a pretty notable impact for arrays shorter than a few thousand
- chihuahua 3y agoBut constant factors matter. We don't expect there to be a difference in the big-O complexity between languages. If you have two O(N) implementations, but one is 10x faster than the other (or 1.5x or whatever), that's still a significant difference.
- ok123456 3y agoIt depends on how much conversion is needed to feed it into the FFI. Duck typing in python means there are a lot of implicit conversions that will take place.
- bee_rider 3y agoTrue. But if the code is reasonably well written, and you are just doing Numpy operations on Numpy vectors and matrices, it should basically be equivalent to doing those operations in Fortran (because most of the actual compute should be performed by code written in Fortran and C). They asked if Fortran was faster than Numpy, not if it was faster than Python.
- synergy20 3y ago
- complex_pi 3y agoBesides the technical part, Fortran's community has evolved a lot as well since 5-10 years. See the community paper here: https://arxiv.org/abs/2203.15110 https://arxiv.org/abs/2203.15110 "The state of Fortran" (not an author myself)
- dang 3y agoRecent and related: Fortran - https://news.ycombinator.com/item?id=37291504 https://news.ycombinator.com/item?id=37291504 - Aug 2023 (223 comments)
- avidphantasm 3y agoStupid ISO charging money for standards.
- pkphilip 3y agoOk. but can I create full stack webapps using Frontend?
- tpoacher 3y agoIs anyone aware of a nice resource that teaches the language while also showing its evolution at each step? (as opposed to just teaching the latest version only / an older version only)
- sheepshear 3y agoThe Metcalf books, collectively.