3 ms·
Even better: Julia (although Fortran is pretty good!)
by goerz 1y ago
Even better: Julia (although Fortran is pretty good!)
- adgjlsfhk1 1y agoI translated the jacobi example to julia, and it does seem to address every one of his gripes with Python.
- cbolton 1y agoI think his main point is about strict typing in Fortran. You can add type annotations in Julia but it's almost an anti-pattern if you don't need them e.g. for dispatch. In any case the type annotations in these examples would be quite unnecessary, unlike in Fortran (where as I understand you can at best enable implicit typing but then must use variable names with specific patterns).
- TimorousBestie 1y agoNumerical linear algebra is the exemplar killer app for multiple dispatch; not exploiting it would be a waste.
- adgjlsfhk1 1y agoI would argue that the strict typing in Fortran is actually a significant hindrance. there's nothing about any of these algorithms that requires double precision (or even contiguous storage), so why should the algorithm randomly restrict it? Annotations of rank (e.g. AbstractMatrix in julia) help document what the code does, but the strict annotations of Fortran are restrictions without value.
- QuadmasterXLII 1y agoI love julia, but the default workflow is Step 1) Write the function using high level abstractions Step 2) Glance over the generated assembly and make sure that it vectorized the way you wanted.
- mofeing 1y ago> Glance over the generated assembly and make sure that it vectorized the way you wanted. Isn't that sth you would also need to do in Fortran? IMO Julia makes this so easy with its `@code_*` macros and is one of the main reasons why I use it.
- wtcactus 1y agoIn my experience, Fortran compiler is heavily optimized. It competes head to head with C. Julia’s on the other hand, many times puts out very unoptimized code. Mind you, last time I looked at Julia was 2-3 years ago, maybe things have changed.
- patagurbon 1y agoIf you write Julia similar to Fortran, with explicit argument types and for loops and avoiding allocations it shouldn’t be too far off. Fortran IIRC has a few semantics which might make it more optimal in a few cases like aliasing But indeed there are almost certainly less performance surprises in Fortran
- TimorousBestie 1y agoThis is the default workflow in every high-level language. Even if I’m writing explicit SIMD intrinsics in C targeting a specific processor, I still have to benchmark and maybe look at the assembly to make sure it did what I intended (or something better).