4 ms·
Dumb question: how is Julia better than Fortran to write numerical models (for example, finite element simulations) ? In the lab where I work there are plenty
by wiz21c 3y ago
Dumb question: how is Julia better than Fortran to write numerical models (for example, finite element simulations) ?
In the lab where I work there are plenty of people real good at the physics/maths but not that good at writing code. Since they need performances to run their stuff, they often go to Fortran (because that's what has always been used here). How much Julia would make their life easier ?
(I'm the computer guy in the lab: I optimize their stuff when they need it but I'm not in the mindset of "model first, code quality after", I'm much more a rustacean :-))
- leephillips 3y agoBoth Fortran and Julia have a concise syntax for array operations, and both, with a little care, can produce fast programs. Unless you want to program in C or C++, those are your only options¹ for high-level languages that have already proven themselves in high performance computing. I wouldn’t advise rewriting a substantial Fortran project in Julia; but for new projects, Julia is the better choice. Fortran is excellent in the scientific/numerical high performance niche, but it’s still awkward to move beyond that; it’s still stuck in the Formula Translator role. So the non-numerical parts of the program, that deal with input/output, for example, are awkward; Julia is more pleasant to program these tasks. Julia lets you build your program interactively, by trying things out in the REPL. This alone may be sufficient reason to prefer it over Fortran. Although most scientists won’t become sophisticated as programmers, for those that will, Julia can grow with them. It has extensive support for metaprogramming (for example), including real macros. Its type/dispatch system, and other features, allow you to write far more concise and better organized code than you can in Fortran. Sharing code and composing libraries² is easier in Julia. Really, Julia is just more fun to program in. 1 HPCWire (2017) ‘Julia Joins Petaflop Club’. Available from: https://cacm.acm.org/news/221003-julia-joins-petaflop-club/fulltext https://cacm.acm.org/news/221003-julia-joins-petaflop-club/f... 2 Phillips, Lee (2020) ‘The Unreasonable Effectiveness of the Julia Programming Language’. Ars Technica. Available from: https://arstechnica.com/science/2020/10/the-unreasonable-effectiveness-of-the-julia-programming-language/ https://arstechnica.com/science/2020/10/the-unreasonable-eff...
- wiz21c 3y agoThanks ofr this answer. Looks very balanced to me.
- TheRealKing 3y agoExcept for the fact that your Julia code will always suffer from correctness problems, something that would rarely if ever happen in Fortran. https://yuri.is/not-julia/ https://yuri.is/not-julia/
- leephillips 3y agoNo, it probably won’t, and certainly not “always”. A majority of the issues raised in that article concern errors in packages that have been fixed, most rather a long time ago.
- TheRealKing 3y agoThat "always" holds for the Julia language almost surely as long as interfaces are missing in the language. It is just a matter of time to find newer issues.
- leephillips 3y agoMy Julia programs do not “always suffer from correctness problems”; therefore you are incorrect. More generally, saying that programs written in a language that happens not to include a feature you think is important (in this case, interfaces) will “always suffer from correctness problems” doesn’t seem to be a serious point of view.
- TheRealKing 3y agoAll Julia codes are arbitrarily extensible. Any Julia code can always be readily extended to silently yield incorrect results. That is the whole point of the blog post shared above. Justifying the indefensible is different from wanting or liking it.
- queuebert 3y agoIt's actually very easy to make Fortran bindings for Julia, where you can call your Fortran code from Julia. https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/#Fortran-Wrapper-Example https://docs.julialang.org/en/v1/manual/calling-c-and-fortra... So unless you think the Julia version will compile to faster code than the Fortran code (probably not if you use a fancy paid license Fortran compiler), then definitely don't rewrite.
- e12e 3y agoMight be (significantly) easier to run idiomatic Julia on GPU(s)? (Unsure of current Fortran here).