News for hackers. Stuff that matters.
Re:Why physicists still use Fortran by bsder on Sunday December 18, 2016 @04:58PM (#13207921)
> I tried to talk the Go and Rust people into putting in multidimensional arrays

What facility is Rust lacking that prevents you from coding this as an extension/package rather than needing core coding support?

Native long integer (128-bit) support could be coded as a compiler extension for a long time before it got pulled in.

Re:Why physicists still use Fortran by Animats on Sunday December 18, 2016 @05:34PM (#13208131)
What facility is Rust lacking that prevents you from coding this as an extension/package rather than needing core coding support?

That sort of thinking is what drives number-crunching people away from a language. You end up with ten different representations for matrices, and can't pass matrices from one package to another.

Re:Why physicists still use Fortran by bsder on Sunday December 18, 2016 @10:39PM (#13209374)
If the numerics people can't agree on something, throwing the decision over to the core Rust folks is unlikely to result in something better.

So, the question still stands: What in Rust prevents an ambitious number cruncher with good design taste from adding the appropriate pieces to the language?

Re:Why physicists still use Fortran by greglindahl on Sunday December 18, 2016 @11:59PM (#13209571)
Fortran has 1st class many-dimensional arrays; can you really do that efficiently (as in "works great with a loop nest optimizer/LNO" and "has pretty syntax" and "there's one way to do it") as a Rust extension? C++ says "NOOOOOOO!!!" I don't know Rust well enough to answer the question.
Re:Why physicists still use Fortran by Manishearth on Monday December 19, 2016 @01:37AM (#13209842)
You can do `arr[(1,2,3)]` in Rust (not pretty, but ok). Assuming you've marked the indexers as inline, LLVM should be able to optimize it pretty well. If it doesn't, optimizations can be added.

Rust can't enforce "one way to do it" since this would be done as a library. Currently there's only one library offering this (ndarray), so in a sense there's only one way to do it :)

Re:Why physicists still use Fortran by greglindahl on Monday December 19, 2016 @01:48AM (#13209878)
What does arr[(1,2,3)] have to do with what I asked for? The code that I write for my personal scientific stuff (numerical hydrodynamics) needs loop jamming/fusion and splitting, SIMD without having to use any special notation, and other stuff which is typically provided by compiler LNO. I happen to have interchanged loops in my code, but if I goofed that up, it'd be nice for the compiler to do it for me.

No array slices needed. Plain Fortran 77 notation provides what I need.

Re:Why physicists still use Fortran by Manishearth on Monday December 19, 2016 @02:09AM (#13209947)
> What does arr[(1,2,3)] have to do with what I asked for

"has pretty syntax", was just showing what the syntax would look like in Rust.

LLVM autovectorizes, and does many loop optimizations. I suspect LNO exists, but if it doesn't there's nothing preventing it from being added afaict.

Was mostly explaining what the status of this in Rust is. It's not awesome, but not horrible either.

Re:Why physicists still use Fortran by greglindahl on Monday December 19, 2016 @02:35AM (#13210051)
Thanks for trying to be helpful. The place where C and C++ goes wrong is multi-dimensional arrays. Some googling tells me that narray gives Rust syntax like foo[[1,2,3]] for a 3 dimensional array. I have no guess if this optimizes well or not.
Re:Why physicists still use Fortran by Manishearth on Monday December 19, 2016 @02:43AM (#13210077)
It will compile down to `foo[1][2][3]` and get optimized the same way. Rust additionally does hint a lot more about aliasability to LLVM (everything is restrict by default, basically), so there probably is more scope for optimization here.
Re:Why physicists still use Fortran by steveklabnik on Sunday December 18, 2016 @11:45PM (#13209546)
I'm not an expert in that domain, but to my mind, the two big things are

* lack of type-level integers

* lack of explicit SIMD on stable Rust

Re:Why physicists still use Fortran by Manishearth on Monday December 19, 2016 @01:08AM (#13209761)
This is already true in the Fortran world. When I was a student I was working with some condensed matter physics software and there was all kinds of madness with flipping conventions in there.

And Rust doesn't have ten different ways to do n-dimensional arrays. There's one major library out there (ndarray). I just learned about a second (https://github.com/Luthaf/mudi) which seems to use the same conventions.

There are multiple ways to do matrices, but these are in graphics-oriented libraries.

Re:Why physicists still use Fortran by PeterisP on Sunday December 18, 2016 @07:59PM (#13208727)
Well, it can work if one package gets dominant - e.g. the Python ecosystem works quite well with having all this outside of core language in the numpy package.
Re:Why physicists still use Fortran by tnecniv on Sunday December 18, 2016 @09:54PM (#13209202)
But that happening is just as likely as the fragmentation that exists in C++. Getting OpenCV to play nice with Eigen can be a hassle.
Re:Why physicists still use Fortran by sidlls on Sunday December 18, 2016 @08:36PM (#13208869)
Nothing prevents a person from doing that, but that isn't what folks doing scientific computing are interested in, generally speaking. Some are, sure, but in aggregate as a matter of what the "day to day" is, it's just not of much interest.

I mean, maybe I was an outlier, but when I was in academia I wanted to have my models compute as accurately and quickly as possible, and I generally didn't have much time for or interest in the computer coding beyond the necessary implementation details required to conduct my research.

Telling me "implement an extension", then, would have made me roll my eyes and go back to fortran.

Re:Why physicists still use Fortran by jerf on Sunday December 18, 2016 @09:44PM (#13209153)
I don't think the idea is necessarily that you personally implement an extension, but that "someone" needs to implement it and the bar for "someone" to do so is lower if it can be done via extensions or libraries rather than having to be done in the core. That someone should share their work, of course, and that someone may find they have a feature or two they have to get into core, but even that's easier than sticking a whole whackload of changes into core.
Re:Why physicists still use Fortran by Manishearth on Monday December 19, 2016 @01:03AM (#13209748)
You don't have to implement an extension. It already exists.

https://bluss.github.io/rust-ndarray/master/ndarray/index.ht...

Re:Why physicists still use Fortran by computerphage on Sunday December 18, 2016 @05:09PM (#13207982)
It would be nice to have access to an overloadable index operator that works on multiple dimensions at once (like C#'s [1, 2, 5] syntax). It's sometimes not easy to write something to be efficient if it has to go one-by-one like [1][2][5].
Re:Why physicists still use Fortran by gpm on Sunday December 18, 2016 @06:26PM (#13208353)
The ndarray library indexes via tuples, i.e. [(1,2,5)], which should be just as efficient as a built in syntax (if perhaps a bit uglier).
Re:Why physicists still use Fortran by spullara on Sunday December 18, 2016 @05:16PM (#13208028)
Doesn't Rust have macros that let you modify the syntax? Maybe you could do this.