6 ms·
This is great, because Unreal is a C++ project that's not so easy to just Rewrite In Rust. It's also nice it uses bevy's ECS. It's made to fit Rust's type syst
by pornel 4y ago
This is great, because Unreal is a C++ project that's not so easy to just Rewrite In Rust.
It's also nice it uses bevy's ECS. It's made to fit Rust's type system and borrow checking model, and is highly parallel. It's really awesome how easy it is to distribute work across cores with it, without risk of heisenbugs thanks to Rust's data-race-safety guarantees.
I know game development sees traditional software best practices as not applicable to them, but then games struggle with showstopping bugs and single-core performance bottlenecks. I hope someone will bet that Rust, despite being stricter and seemingly slower to iterate with, can be a net benefit from lower defect rates. Rust users outside of game dev praise the "if it compiles, it's usually correct", and that junior devs can be told not to write unsafe code, so they can't cause UB and memory corruption.
- waboremo 4y agoWhy would you think that? All of the game developers I've met don't really view themselves as separate from traditional software best practices, just that there's a lot more involved in making a game than people are ever really aware of. They're also among some of the most talented programmers, the stuff they have to come up with is insanity sometimes, so it's certainly not about them not caring about best practices. Games aren't struggling because they're written in Unreal's flavor of C++ (or whatever other currently existing engines and their respective languages), there are insane deadlines always being pushed. There is never enough time and never enough money. Neither of these problems are solved with Rust, at least not to a substantial degree.
- Ygg2 4y ago> there are insane deadlines always being pushed. Higher compilations times aren't all bad https://xkcd.com/303/ https://xkcd.com/303/
- t8sr 4y agoWhy do specifically Rust programmers think that people in every domain are just misguided and waiting for someone to teach them the right development practices? The sheer hubris… The kind of bugs that games mostly struggle with these days have nothing to do with the stuff Rust is targeting, like memory safety. They are “business logic” problems with many interacting systems resulting in unpredictable behavior, buggy level geometry, or poorly scripted missions not accounting for all player behavior. How exactly does Rust help with any of that?
- nynx 4y agoI mean, dude, I’ve seen the C++ written by organizations with supposedly highly-competent programmers. I think maybe we should let programmers get a little help from language designers.
- steveklabnik 4y agoMemory safety does matter for games. Especially in places like networked games, or anti cheat software. Even in single player games, a game crashing and losing your progress sucks. Rust’s non-borrow checker features help with other kinds of things. Rust isn’t only an ownership system.
- MiguelX413 4y agoAs mentioned, the type system helps reduce invalid states among many other things too!
- moldavi 4y agoFor a single player turn-based game, I'm not so sure the tradeoff is as obvious as everyone says, after coding one in C++ and another in Rust. It's turn based, so I don't need AAA game multi-threaded performance. It's single-player, so cheating doesn't really hurt anyone. I use sanitizers to catch memory problems, but there have only been a few of those over the years. Maybe ECS just isn't that vulnerable to memory-safety problems? The borrow checker prevents iterator invalidation problems, but most of my functions are read-only so there's not really a chance for those anyway, or many other single-threaded race conditions for that matter. After this long using Rust, I'm noticing more and more that the borrow checker is imposing a lot of artificial complexity, when I compare it to my C++ version. We're often told that Rust is hard because the underlying problem is hard, but I've encountered many cases where that's not true, it really is just the borrow checker. And unfortunately, most of them are problems that Polonius won't fix. Rust has a lot of great features (enums and cargo!) but I think one should think carefully about their domain and architecture before choosing a language, lest they pay too much cost for too little benefit. Just my two cents!
- 4y ago
- capableweb 4y ago> Rust users outside of game dev praise the "if it compiles, it's usually correct", Why do people keep echoing this sentiment? I don't find this to be particularly true, in my sense of "correct". Yes, it does what the code says it'll do, but rarely the problem I actually get stuck at are language/syntax/semantic errors, it's usually domain/logic errors. Same can be said for PHP, JavaScript and a bunch of languages, as every program that is possible to run without error, is correct, at least in the eyes of the interpreter. But again, the difficult errors are not syntax/language errors.
- FpUser 4y ago>"but rarely the problem I actually get stuck at are language/syntax/semantic errors, it's usually domain/logic errors." Exactly my case. I've forgotten last time I've had memory alloc / free/ overrun /free after use etc. related bug in my C++ projects. I am using modern C++ which in combination with STL containers makes me forget about all this C++ is scary FUD. I am however not being "turn everything into template" maniac and in general trying for code not to be fancy but rather readable.
- patrick451 4y agoYeah, it's such as silly sentiment, which honestly makes me wonder about the skill of the programmers repeating it. Exactly none of the bugs I've fixed in the last month had anything to do with memory corruption or data races or other undefined behavior.
- Yoric 4y agoIt feels like something was misquoted at some point. The main benefit of Rust towards safety is not memory safety or data race safety or undefined behavior. The main benefit of Rust towards safety is a strong type system with affine typing. When used properly, this eliminates huge classes of bugs. Most of the bugs that I need to fight when I'm writing in Python or JS, for instance, are simply impossible in Rust. Of course, when I'm writing C++ (which I don't do a lot these days), I really miss all the features that you mentioned.
- virtualritz 4y ago