6 ms·
Rust-GPU: Making Rust a first-class language and ecosystem for GPU code
- lwansbrough 6y agoPrevious discussion: https://news.ycombinator.com/item?id=24858172 https://news.ycombinator.com/item?id=24858172
- chrismorgan 6y agoYeah, this should be marked as a dupe of that, given it was only two days ago and gained substantial traction.
- rco8786 6y agoMan Rust seems like it’s really on fire at the lower levels right now, like it’s gonna replace C.
- timClicks 6y agoRust's range is very impressive. It's almost equally at home doing systems work, embedded and CLI utilities
- zamalek 6y agoIt's not unreasonable to expect it to replace C, but as a major Rust fan myself, I don't see it specifically taking aim at C. C++ is the monster under the bed.
- pezo1919 6y agoCan you please elaborate on that? Both why not C and why C++ sounds really interesting.
- swsieber 6y agoAn outsider's perspective is that c and c++ are pretty similar except c++ is a little more ... powerful? More something for being a bigger language. Rust is a bigger language. There are other languages aiming to be small and a better c. Zig comes to mind.
- tikej 6y agoRust is bigger than C++?! I mean i can hardly imagine any language being BIGGER (as in more language features) than C++ (except C++ 2030 standard ;)
- swsieber 6y agoNo, not bigger. Maybe same order of magnitude though.
- AlphaSite 6y agoYou’ve obviously never looked at swift.
- pjmlp 6y agoOnly because it has a npm style library. The biggest chunck of ISO C++ is describing the standard library. Just wait Rust to get 40 years of language improvements, while you try to link 5 different epochs on the same executable.
- echelon 6y agoC++ has a ton of baggage and is a very difficult language to use. There are too many language features and they all have years of warts. Imagine PHP, but not memory safe. Mistakes cause segfaults, memory leaks, and can enable attackers write memory they shouldn't be able to access. To top it off, a lot of libraries are still written in "PHP4 style" and you've got to make use of them. C++ is really hard. Both C and C++ require consideration of memory semantics, and they are both "hard" in this sense. You have to allocate and free memory deliberately and be conscious about what memory you're passing around. C is much simpler in design than C++. It doesn't have as many features, so it's harder to trip over. It doesn't necessarily make it easier to program, though. Rust targets the same domains that C and C++ do: systems programing (operating systems and drivers), real time programming (robotics and control software), graphics and games, etc. These are places where explicit memory management is important. Rust does so while being much easier to write. The language leverages new programming language theory and design to protect memory from being written incorrectly. The memory semantics are baked into the language design and checked at compile time. Bad code (in terms of memory and async) simply doesn't compile. Rust does this while being just as fast as C and C++. In addition, Rust has a ton of modern features that make it feel like Ruby. Functional idioms, zero-cost abstractions, a modern trait-based type system, generics, macros, and a beautiful package manager and package ecosystem that is better than Ruby and npm. Rust is going to beat both of these languages.
- edsac_xyzw 6y agoHardly it will fully replace C++ due to the pervasiveness of the language on many domains and also due to the C++ ecosystem that encompasses system programming; embedded systems; games and so on. For instance, the C++ ecosystem still outmatches rust regarding high performance libraries for several scientific computing domains; GUI graphical user interface libraries, such as Qt, MFC, wxWidget; Game engines and so on. In addition, Rust lacks openMP feature which allows parallelizing for-loops, which are widespread on scientific computing, for taking advantage of multi-core CPUs and from SIMD.
- zamalek 6y agoC++ is vastly more complex, meaning that it should tend to have more footguns, and it definitely does. Simplicity is a feature, and one that C++ aggressively avoids.
- deleted 6y ago[deleted]
- pjmlp 6y agoIt has 60 years to catch up with C and 40 years to catch up with C++. Don't mistake winning a few battles with winning the war. So far C++ hasn't had much foothold on kernels and embedded, despite several victories. Also note that NVIDIA is on ISO C++ and they have changed CUDA architecture to fit C++11 memory model.
- kzrdude 6y agoRust has been going for 10 years (5 years since 1.0); everything needs time for sure, but Rust has been building up to this point.
- pjmlp 6y agoTrue, and it has been a remarkable progress, but it is yet far from being a SDK language on game engines and consoles.
- the-dude 6y agoFirst, I think you might be a decade off on both accounts. Second, the connectivity was not the same at the time, ideas travel much faster now.
- pjmlp 6y agoEasy to validate, C was born in 1972, so 48 years. C++ was born in 1985, so 35 years. I stand corrected on the matter. As for ideas, traveling is not enough when at the reception end there isn't any willingness to accept them.
- PrinceKropotkin 6y agoI don't see C going away. That said, there does seem to be a cultural change afoot.
- Const-me 6y agoUnlikely to happen, except couple of small niches. Rust is too hard to learn, compiles too slow, hard to interop with C, and less safe than VM-based languages. P.S. According to hackernews filter bubble, Lisp should have killed Java decades ago.
- StavrosK 6y agoC is only easy to learn if by "learn" you mean "getting something to compile". Learning it enough to write programs without malloc vulnerabilities is basically impossible.
- Const-me 6y agoThat's not a huge deal for 2 reasons. 1. Not all software is exposed to internets, or requires many 9-s in reliability like avionics. A videogame that crashes their hardware-virtualized compartment on 1 out of 100k consoles is not OK, but might be good enough in practice if the unlucky users are refunded. 2. We have higher-level languages which solve these vulnerabilities for acceptable performance cost, and even easier to learn than C.
- Nullabillity 6y agoMost video games do connect to the internet these days.
- pjmlp 6y ago
- bionhoward 6y agoSomebody please, please make an equivalent to Tullio.jl for Rust ... by far the easiest way to write custom kernels
- cute_boi 6y agowow looks so cool :D
- fluffy87 6y agoDoes it support pointers? It seems this is only for shaders, but if that’s the case one has been able to use shaders with Rust via GLSL since forever.
- tucnak 6y agoI don't think Rust is very suitable for GPU programming, "first–class" or whatever. And it has not much to do with Rust itself. We have seen time and time again people write deeply inefficient overkill kernels in C for some basic stuff really. I should expect this would happen to Rust, too. In order to tackle this right, it seems, we really should treat GPUs and similar coprocessors for what they are—deeply data–parallel computation accelerators. You must design your pipelines with that in mind; this stuff is also very sensitive to data locality, as you might expect. Now, take a look at this Haskell-inspired language [1], which I think is much more viable in the long–term as far as data parallelism and composition goes. Admittedly it's not in itself designed for graphics, but that's okay. From their website: "Futhark is a small programming language designed to be compiled to efficient parallel code. It is a statically typed, data-parallel, and purely functional array language in the ML family, and comes with a heavily optimising ahead-of-time compiler that presently generates either GPU code via CUDA and OpenCL, or multi-threaded CPU code." I can see that very much unlike Futhark, Rust-GPU is deeply graphics focused, but I argue that a very similar language can be made to accomodate if not all then most shader-specific things. In which case, Futhark would be a very good place to start. [1]: https://futhark-lang.org/ https://futhark-lang.org/
- nestorD 6y agoHaving a macro to convert a Rust-like DSL (with a focus on iterators to replace Futhark's higher order functions) to GPU via a Futhark-like compiler is doable and something I would love to see done. It could be the rayon of GPU computing on Rust.
- svntid 6y agocode look and feel is messy. files with 1K+ loc spaghetti bolognese an absolute turn off. good luck I guess