5 ms·
I've used Fortran for scientific computing work, mainly because it's ultra-fast and my advisor still used it. If we are going to invest a high-performance compu
by glial 5y ago
I've used Fortran for scientific computing work, mainly because it's ultra-fast and my advisor still used it. If we are going to invest a high-performance computing ecosystem and community, why would Fortran make more sense than e.g. Rust?
(I have never used Rust for anything but HN seems to love it)
- leephillips 5y agoThe languages that have proven to be effective for high-performance computing are Fortran, Julia, C, and C++; but only the first two are convenient media for the scientific programmer. Recent activity in scientific computation is moving to Julia, but the vast amount of existing Fortran code makes this effort around tooling worthwhile.
- Bostonian 5y ago"Recent activity in scientific computation is moving to Julia" I'm not saying you are wrong, but I wonder what metric you are using.
- leephillips 5y agoThat’s a fair question. I can’t claim to have anything that would merit being called a “metric”. The number of papers and projects using Julia increases every year, but that in itself doesn’t quite support my claim. What I mean is that there are regularly new large-scale computational projects adopting Julia, and they are the types of projects that, in most cases, I’m pretty sure would have used Fortran seven years ago.
- pjmlp 5y agoI guess this project list is a possible metric. https://juliacomputing.com/case-studies/ https://juliacomputing.com/case-studies/
- TheRealKing 5y agoThe fact that Fortran applications are not collected in a single page by a for-profit company that does not exist in the case of Fortran, does not in anyway prove that new applications moving away from Fortran.
- bondant 5y agoOne reason would be that Fortran has proven itself in the HPC area. Another one would be that it is a much simpler and easy to learn language than Rust (so can quickly train students, PhDs and so on to improve your simulation code, even when they have no programming background). In most of the HPC codes I've worked with there are no complicated memory management, most of the things are arrays usually declared and allocated at launch time and that's it, no more memory management after that. So I'm not sure what rust would bring on the table, but maybe I'm just missing it.
- milancurcic 5y agoAuthor here, so I'm biased toward Fortran, though I've been enjoying learning Rust as well. I think there are a few reasons. First, Rust's multidimensional arrays are either limited and/or difficult to use. Fast, flexible, and ergonomic multidimensional arrays and arithmetic are essential for HPC. They are possible with Rust, but my two favorite Rust books not mentioning them suggests to me that they're not the focus of the language. This may or may not change in the future. Second, Rust may be too complex to learn for scientists who aren't paid to write software but to do research. Fortran is opposite--multidimensional whole-array arithmetic looks like you would write it as math on a whiteboard. While scientists can sure learn to program Rust effectively, I think most scientists don't think like Rust, but they do think like Fortran. For somebody not familiar with Fortran but familiar with Python, I'd say Fortran very much feels like NumPy. Third, such ecosystem would be built in Rust from scratch. In Fortran, most of the value is already there, but needs to be made more accessible with better and more modern tooling. For example, Fortran's fpm (https://github.com/fortran-lang/fpm https://github.com/fortran-lang/fpm) is largely modeled after Rust's Cargo because we recognize the importance of good user experience when it comes to building and packaging software. With the recent Fortran-lang efforts, we study many programming language ecosystems and communities (e.g. Python, Julia, Rust, etc.) to find what could work best for modern Fortran tooling.
- zozbot234 5y ago> Third, such ecosystem would be built in Rust from scratch. Rust can actually interoperate quite seamlessly with external libraries, and make its own libraries available to other languages. You're quite right that the support for even simple numerics in Rust isn't quite stable just yet, so it's not ready for productive use. But it can get there, to a far greater extent than C/C++.
- jandrewrogers 5y agoFortran makes sense to the extent there is a lot of battle-tested and highly optimized numerics code written in it. It was mostly replaced by C and (legacy) C++ for new code when I last worked in HPC many years ago. Fortran is not an ergonomic language for most types of software by modern standards and performance parity was achieved a long time ago. I used all three languages. Rust doesn't solve many problems for HPC, and HPC still often involves weird hardware targets compiling from some dialect of C or C++. A bit like embedded but without the market scale to justify tool investment. Fortran and Julia are more likely targets for a second language for the obvious reasons. Another issue is that some HPC silicon has unusual low-level concurrency and memory semantics with no analogues in ordinary CPU architectures. At least in some cases, I suspect it would be require non-trivial modification of Rust's safety checking to allow it to work correctly on that silicon.
- zozbot234 5y ago> Another issue is that some HPC silicon has unusual low-level concurrency and memory semantics with no analogues in ordinary CPU architectures As long as it's properly reflected in the LLVM IR, I don't think this would be an issue.
- jandrewrogers 5y agoThat does not address the issue I was raising. In some systems, sophisticated memory ownership and concurrency control are implemented in the hardware. These abstractions are very low-level and are intended to transparently support fine-grained and extremely high concurrency with almost no overhead. The memory ownership model is oblivious to the programming language's concept of such a thing. As long as the compiler is emitting the appropriate memory control instructions, there can never be a conflict no matter how many concurrent mutable references there are and this conflict resolution is nearly free. This scales to thousands of cores and millions of concurrent threads. The issue with porting Rust to this silicon, without thinking about it too deeply, seems to be two-fold: First, code organized to satisfy the borrow-checker etc is an anti-optimization on these CPUs because they are specifically designed to encourage you to ignore memory ownership and mutability at the code level. This enables absurdly concurrent code execution on mutable shared memory that would be difficult-to-impossible to write safely on an ordinary CPU in any language. Second, you would probably want the Rust compiler to ignore many issues of ownership and concurrency, instead emitting appropriate memory control instructions and delegating it to the hardware, since the hardware does it much better. This seems non-trivial, particularly since the hardware model does not map perfectly to Rust's model in the details (which vary by CPU design). This also creates the case of code that safely compiles on this silicon won't compile on e.g. x86 because the safety is provided by the hardware rather than at compile-time. Ironically, a large part of the reason these CPUs have never been commercially successful is that people don't know how to write idiomatic massively concurrent mutable code. The assumption that thread concurrency is expensive and dangerous is so pervasive that everyone writes code that tacitly assumes this even when it isn't true for the given hardware, with significant loss of performance. Idiomatic algorithms and data structures in C++ on these platforms look very different than what you would use on e.g. x86 or ARM.
- nestorD 5y agoThere was actually a very good 'Rust vs Fortran' subject in the Rust forum [0]. My personnal belief is that Fortran codebases will be replaced as new programmers don't want to learn the language due to its reputation. At the moment they are rewritten in C++ (fast but so many footguns) and Python (easy but terrible performance): I am betting on Julia replacing Python in the medium term (faster, not harder to learn and designed for this particular use-case). Rust is hard to learn so I think most scientists will not invest in it but I do hope to be wrong and that it will replace C++ in the HPC world... [0]: https://users.rust-lang.org/t/rust-vs-fortran/64642 https://users.rust-lang.org/t/rust-vs-fortran/64642
- uoaei 5y agoRust may be a good option for safety and speed, but putting effort into Julia to speed it up because of its ergonomics seems like a pretty good idea.
- eigenspace 5y agoJulia for sure. Rust is not a good fit for scientific HPC.