Hacker News new | past | comments | ask | show | jobs | submit login

Linking COBOL and Fortran against C is actually one of the easier things to do. So with these multi-million line systems, often new features are written in C++, minor minor minor bugfixes in the original language, and general maintenance is a toss-up if it's a re-write in C++ or just fix it in the old language. Depends on how fast they need it.

I did some Pre66 Fortran work for a bank, and that was basically the idea. They were in the process of converting internal assumptions of the program from a very particular older mainframe type to a mix of Z/OS and Solaris, and the Fortran/COBOL into something they could continue working with.

Some of the code was very specifically marked as "not for C++", because modern Fortran (2003 at the time) was better for some specific number-based things. But that code becomes a library rather than part of the original monolithic structure. And modern Fortran is actually quite a nice low-level language to play with.

It was actually easier than expected - when the original program was written, and for about the next twenty years following, the entire program and changes were very well specified in multi-thousand page specifications. The newer code was harder to keep track of, rather than the oldest, because at the oldest those documents were 99% accurate, even if you never trusted them to be because of the intervening time.




> Some of the code was very specifically marked as "not for C++", because modern Fortran (2003 at the time) was better for some specific number-based things.

Was that a you-can't-do-that-in-c++ thing or slightly-faster-in-fortan thing? I'm always skeptical about the latter guiding major maintainability decisions on often-specious performance benefit claims.


To expand a bit on other answers: There is a qualitative difference Fortran has by offering

1) built-in multidimensional arrays including Matlab-like array operations. That means every library supports the same format, it's standardized and convenient as opposed to the many formats in C++ Land.

2) performant defaults. When performance is more important than safety, Fortran programs are easier to write and maintain. Arguments are by default pass-by-reference, non-aliased (a major assumption Fortran compilers can usually make to optimize) and their intent as in/out/in out can simply be marked as such.

Fortran:

real(8), intent(in) :: foo

C:

restrict const * const double foo # if I remember correctly


I’m not sure what you mean by “When performance is more important than safety, Fortran programs are easier to write and maintain.” The fact that arrays are not based on pointers makes Fortran a much safer language than C. It’s very hard to shoot yourself in the foot with Fortran. It’s fast and safe


Fortran offers a better developer experience overall for Numerical applications yes. But it is still very foot shootable as I remember - point a pointer at allocatable and the fun can start. Or make everything inout for convenience and/or performance. But yes, compared to C the defaults are also safer, just don't expect Rust.


It’s very easy to shoot yourself in any body part - just disable array bounds checking, drop modules (which means no function call interface checks) and you’re practically back to C-land in terms of memory safety. Of course, the sensible thing to do is to check interfaces and bounds (at least in debug/test mode).


Slightly-faster-in-Fortran. But it wasn't just a slight gain. The system I'm referring to is a multi-national system that processes somewhere in the order of 50-100 million transactions a second (depending on the time of day, and the day itself).

A slight performance gain of 1% by using Fortran has a noticeable effect on long-term economic gains. (It was usually in the range of 5-8% performance improvement, but at the worst was 1%).

Thankfully, the reason I can tell you this, is because they tested it in the real world, splitting all transaction across a large-scale A/B test.

The real-world economic gains from the faster performance more than paid for the occasional development costs of a Fortran-familiar developer, hence why those systems persist in Fortran. They also scheduled re-assessment of this once every five years, knowing it might change one day.


In the areas where you'd want to use modern Fortran (numerics, not TCP servers), it is easily also more maintainable than C++.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: