Live data from Hacker News

What are Fortran and Cobol used for today?

stackoverflow.com

1–10 of 72 posts

Re: What are Fortran and Cobol used for today?

#2
I was surprised to see when I installed R for the first time, that a large amount of the libraries it makes use of are written in fortran.

To complete the installation required me to choose from one of several current and compatible fortran compilers even.

So at least for fortran, the answer is scientific computing.

Re: What are Fortran and Cobol used for today?

#4

I was surprised to see when I installed R for the first time, that a large amount of the libraries it makes use of are written in fortran. To complete the installation required me to choose from one of several current and compatible fortran compilers even. So at least for fortran, the answer is scientific computing.

Fortran is far from extinct, because scientists often prefer it to C/C++, and it's often faster.

Part of the reason is that Fortran passes arrays by value, while C passes them by reference. It's very hard for compilers to optimise a pass-by-reference array, because it might have the memory altered by another part of the program. If it's pass by value, then you know it's safe. It's kind of like threads vs messages.

I think C has some recent work done to close the gap, but even if it's already as fast, it will take a while to port 50 years of legacy numerical code.

Re: What are Fortran and Cobol used for today?

#5
I believe we should think of Fortran as a domain-specific language for handling multidimensional arrays, rather than a normal programming language. It might be terrible for other things, but it's great for array computations, and that's what people use it for in big simulations. Since it has a well-defined C FFI nowadays, it's easy to connect it to other languages that can do other things (parsing data files, etc.).

Coming from a more traditional CS background, I always thought that Fortran was archaic until I actually had to learn it for some scientific computing. I found it awkward to use, but at the same time, it had array capabilities that I've never seen in any other language.

Re: What are Fortran and Cobol used for today?

#7
post #4

I was surprised to see when I installed R for the first time, that a large amount of the libraries it makes use of are written in fortran. To complete the installation required me to choose from one of several current and compatible fortran compilers even. So at least for fortran, the answer is scientific computing.

Fortran is far from extinct, because scientists often prefer it to C/C++, and it's often faster. Part of the reason is that Fortran passes arrays by value, while C passes them by reference. It's very hard for compilers to optimise a pass-by-reference array, because it might have the memory altered by another part of the program. If it's pass by value, then you know it's safe. It's kind of like threads vs messages. I…

Some discussion here - http://stackoverflow.com/questions/146159/is-fortran-faster-... - my takeaway is it's possible to write numerical code in C in a way the compiler can optimize it, but Fortran does it by default, and the Fortran culture is about making numerical code as fast as possible.

Re: What are Fortran and Cobol used for today?

#8
post #5

I believe we should think of Fortran as a domain-specific language for handling multidimensional arrays, rather than a normal programming language. It might be terrible for other things, but it's great for array computations, and that's what people use it for in big simulations. Since it has a well-defined C FFI nowadays, it's easy to connect it to other languages that can do other things (parsing data files, etc.).…

Given the right tools[1] you can have as much templating/macro support as in C++ while keeping everything both performant and user friendly. The key here is to wrap Fortran in script languages to make it do exactly what you want.

[1]https://github.com/muellermichel/Hybrid-Fortran (I'm the maintainer.)

Re: What are Fortran and Cobol used for today?

#9

I was surprised to see when I installed R for the first time, that a large amount of the libraries it makes use of are written in fortran. To complete the installation required me to choose from one of several current and compatible fortran compilers even. So at least for fortran, the answer is scientific computing.

A lot of NumPy/SciPy (Python's scientific computation libraries) are written in Fortran too: http://docs.scipy.org/doc/numpy/user/install.html

Re: What are Fortran and Cobol used for today?

#10
post #5

I believe we should think of Fortran as a domain-specific language for handling multidimensional arrays, rather than a normal programming language. It might be terrible for other things, but it's great for array computations, and that's what people use it for in big simulations. Since it has a well-defined C FFI nowadays, it's easy to connect it to other languages that can do other things (parsing data files, etc.).…

I'm not sure by now the language's merits are the number one reason Fortran is used, but rather the amount of proven and super fast libraries for number crunching and array/matrix manipulation such as LAPACK.
Post reply on HN