5 ms·
Although Fortran compilers may produce fast code (they have to - there's no chance to play with SIMD intrinsics or templates unless you want to use C++), I don'
by xioxox 6y ago
Although Fortran compilers may produce fast code (they have to - there's no chance to play with SIMD intrinsics or templates unless you want to use C++), I don't find them very good. I've personally hit several bugs in gfortran. The code I maintain now has some extremely ugly hacks to work around unfixed compiler bugs. I recently tried compiling it with Intel Fortran and got a compiler crash on one input file. Maybe they work well with Fortran 77 level code, but the Fortran 2003 level support seemed rather buggy. I suppose this is the problem with a minority language.
I won't recommend Fortran unless the code has to be written by scientists who know nothing else. It has horrible string support, no data structure or algorithm library (like STL), no templates, few non-numeric libraries (e.g. http, json...) and (as above) buggy compilers. Furthermore, C++ gives you much more control over numerical speed when you need it.
- TheRealKing 6y ago"It has horrible string support", this is untrue. Learn Fortran 2003, 2008, 2018.
- xioxox 6y agoWhat? Where is this good string support in Fortran 2003, 2008 and 2018? I must have missed it in the manual. Now you can allocate a string of a non fixed size - simply amazing technology! Actually, one of my compiler crashes was trying to use this revolutionary feature.
- pantalaimon 6y ago> Now you can allocate a string of a non fixed size - simply amazing technology! That’s more than what C gives you out of the box ;)
- smabie 6y agoMany languages forbid mutable strings. They aren't really a very good idea, imo. Even less of a good idea are extensible strings. More complex data structures are required for efficient extensible strings, and this complexity shouldn't be hidden in a simple interface. Better to have a Buffer type or something that is distinct from the String type so programmers are made aware of the performance/allocation characteristics. Though, this is kind of ridiculous to even talk about, since the CPU and compiler itself are responsible for the greatest sins of hiding something unimaginably complex behind a simple interface. Ah, the joys of the 6502 and the Commodore 64!
- benibela 6y agoDelphi had mutable xor aliased strings. That is really great. Each function can change the string as fast as a mutable string, but once it shared with other functions, they can be certain that it will not be changed randomly
- m463 6y agoOr just bite the bullet and learn how format statements really work. ;)
- codezero 6y agoWe could never use gfortran, and other open source compilers were not really great for us either. We used Intel's fortran compiler, and it stood out as a pure gem. At the time it was free for educational/research purposes, which is why we used it, but if we had to pay (I think the license was like $1k/yr) we would have done it in a heartbeat. Our code was entirely FORTRAN 66 and 77, so that may explain why it worked so well for us.
- pantalaimon 6y agoHave you tried Flang? It’s LLVM's fortan compiler and was written from the ground up to support FORTRAN-2018
- codezero 6y agoNope, I left the field in 2012 so haven’t kept up to date at all, sounds cool though!
- m463 6y agoI wonder if when global warming starts eating coastal cities will the government have to seek out centenarian fortran programmers to analyze the climate models? (like the new jersey unemployment system in cobol) :)
- codezero 6y agoI'll do the same thing they did and ask for a shit ton more money :) Though the beauty of fortran to me is really how easy it is to learn and make working code. That said - it's not elegant at all, probably a feature.
- wycy 6y agoDitto this, I've run into some strange compiler bugs I've had to work around. Intel Fortran 2019 actually fails to compile a code at work that's worked for ~40 years, Intel Fortran 2018 compiles it but produces numerical errors when the code runs. Intel Fortran 2016 actually works perfectly, as do several earlier versions. With gfortran I run into issues primarily when using the "newer" features of Fortran 2003/2018.