4 ms·
> 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 extensi
by bsder 10y ago
> 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.
- computerphage 10y agoIt 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].
- spullara 10y agoDoesn't Rust have macros that let you modify the syntax? Maybe you could do this.
- spullara 10y agoDoesn't Rust have macros that let you modify the syntax? Maybe you could do this.
- gpm 10y agoThe 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).
- Animats 10y agoWhat 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.
- PeterisP 10y agoWell, 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.
- tnecniv 10y agoBut that happening is just as likely as the fragmentation that exists in C++. Getting OpenCV to play nice with Eigen can be a hassle.
- bsder 10y agoIf 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?
- steveklabnik 10y agoI'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
- greglindahl 10y agoFortran 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.
- Manishearth 10y agoYou 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 :)
- sidlls 10y agoNothing 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.
- jerf 10y agoI 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.
- Manishearth 10y agoYou don't have to implement an extension. It already exists. https://bluss.github.io/rust-ndarray/master/ndarray/index.html https://bluss.github.io/rust-ndarray/master/ndarray/index.ht...