8 ms·
Why do specifically Rust programmers think that people in every domain are just misguided and waiting for someone to teach them the right development practices?
by t8sr 4y ago
Why 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!
- pcwalton 4y ago> It's turn based, so I don't need AAA game multi-threaded performance. Then you could just use a GC'd language. For example, you could use C# in Unity.
- cwzwarich 4y ago> 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. Out of curiosity, what are your favorite examples?
- spoiler 4y agoI would be curious to know more about this case too, fwiw! Personally, I've only struggled a bit with the borrow checker in a couples of cases: trying to have self/circular references when trying to model OOP, and when fiddling/interacting with some low level async code. Both were unnecessary in my case, and each situation was caused by a lack of understanding.
- Veliladon 4y agoYou can put recurring references in a type, you just need to Box it up first. So you'd have something like: enum List<T> { Cons(T, Box<List<T>>), Nil, } Since the list is now boxed up the borrow checker has a fixed sized object to put on the stack at compile time.
- spoiler 4y agoHi! Thanks for taking the time to explain the concept! I'm familiar with these (and others) now, but I was curious to know what others issues the commenter alludes to
- pornel 4y agoPrevious post mentioned self/circular references. You can't do that with a `Box`. You can with `Rc<RefCell<List` or `*mut List`, but those options either have a runtime cost, or aren't borrow-checked. Lack of self-referential types that are both safe and zero-cost is a legit limitation of Rust.
- pjmlp 4y agoIn which cases they are already mostly using Erlang, Java, .NET languages, or Go on their server stacks. Rust is a great C and C++ replacement for low level stuff, I am still not convinced it is worthy versus those languages for distributed computing in terms of the productivity automatic memory management brings to the table.
- eyelidlessness 4y agoI don’t have a dog in this fight, but I’m also surprised to see proverbial fight spring up here so abruptly and a proverbial dog so rapidly entered into the fray. I didn’t see anything in GP suggesting anyone else is misguided, I saw them state clearly why they appreciate the technical choices of a project and hope others will too. To the extent they made any mention of preferences to the contrary, I read it as conciliatory. As an outsider to both game dev and the general Rust ecosystem, but with a more than passing interest in the ECS data model (entirely apart from games!) and the prospect of using it safely with parallelism (entirely apart from memory safety concerns!), I found GP’s comment insightful and interesting. I find yours unnecessarily defensive. I get that “in Rust” is a HN lightning rod, but maybe sometimes it’s okay for people to just appreciate someone’s personal project for the reasons they appreciate it, without it being an instant conflict?
- deleted 4y ago[deleted]
- pornel 4y agoSorry, that was a poor phrasing. I mean gamedev has distinct approaches/methodologies/culture/priorities from the rest of the software industry. If you move from gamedev to other application development, you'll find a lot of things taken for granted in one are not that common in the other (an example great GDC talk: https://www.youtube.com/watch?v=t9HRzE7_2Xc https://www.youtube.com/watch?v=t9HRzE7_2Xc) Other types of software projects also have their own complexity, budgets, changing requirements, and deadlines (admittedly not as major as a game release), but these things are managed differently. Without telling all of gamedev that they're doing it all wrong, I'd like to say that perhaps there's another methodology that would also work. Especially that some games nowadays aren't just one-offs with a big-bang launch, but are maintained for years after initial release, which makes them look more like other software projects.
- vvanders 4y agoEx-gamedev here, I have no idea what you're on about. Gamedev isn't some place of rainbows and unicorns that makes it a unique snowflake. I spent more than my fair share of time chasing down heap corruption, invalid iterators and all sorts of other fun issues. If anything working on a console where the compile, cook, upload, play cycle can be long having something that removes a whole class of errors would have been great back then. I don't think anyone is saying Rust is a silver bullet but it certainly has aspects that are beneficial in certain contexts.
- stephc_int13 4y agoWell… Many Rust enthusiasts treat it either as a silver bullet or everything else as unholy (unsafe). Besides, syntax and complexity wise I think Rust is even worse than C++. As a gamedev I am not interested in Rust. Zig, Jai and Odin seems much cooler/interesting.
- nu11ptr 4y agoHave you written any Rust code by chance? I personally think Rust is easier than C++, possibly because it is a lot smaller language than C++ (at present). It isn't magic, but it kinda feels like it. To be able to do low level coding knowing you can't blow your foot off is pretty cool.
- nurettin 4y agoI've been using C++ on and off since the 90s (borland C++ 5 times) Tried rust at initial release. Read a csv file line by line, split each line read (because I couldn't find any streams), converted to numbers and calculated some stats. Never again. What rust feels like: you are riding a bike, but it has six safety wheels instead of any normal wheels.
- jeffdn 4y agoI think it’s fair to say that Rust has changed massively since initial release. There are certainly safety aspects, but doing what you describe should be trivial and trigger none or almost none of them. The compiler’s error messages are fantastically helpful these days. Might be worth a tinker some rainy day, but understand being completely turned off of something as well.
- tialaramex 4y agoThis toy project already gives a nice example of something Rust delivered that the author found to be a huge pain in C++: "C++ has one big flaw in Unreal. You can easily crash the editor, either by triggering an assert or accessing a nullptr." but "if you ever unwrap an Option::None or do out of bounds access, unreal-rust will simply catch the panic, exit play mode and log the error to the console. It will never crash the editor."
- t8sr 4y agoHah, I'd forgotten about that (I haven't touched Unreal in a couple of years). You're right, that would be a huge win.
- nestorD 4y agoPeople should probably stop saying that rust is about memory safety, its design has impact on a lot of others things (that I arguably, care much more about). > many interacting systems resulting in unpredictable behavior[0], buggy level geometry[1], or poorly scripted missions not accounting for all player behavior[2]. [0]: Rust borrowing system (you know exactly who is allowed to touch each ressource at a given point in time) is great at pushing you away from architecture with too much mutable interaction. That is a side effect of the system rather than its design purpose but, for my point of view, it is one of the main draw to write large projects in rust rather than C++. [1]: probably not something Rust will help you with. [2]: Rust type system (and overall coding conventions) is really good at building things such that it will only compile if you check for all cases or, at the very least, leave some explicitly unchecked cases.
- t8sr 4y agoSorry, I think "system" is an overloaded term. I'm not talking about "thread X changed my state", I'm talking about a scenario where the physics system wants to move the player collider, but you want to control its motion with hand-tuned code, so you set it to cinematic, which now causes everything in the scene to go flying when it touches it, because it has effectively infinite inertia. Or maybe you have a system that regenerates your health and an area where healing effects turn into damage and your health regen is now draining the health bar. These types of interactions exist at a layer where Rust can't help you. Even outside of gamedev, I would claim that most software bugs we run into every day are in this category: too high-level for the borrow checker. (Button not connected to anything. Scrollbar hidden, but the page is too long. Microservices that upgrade independently without API stability.) > [2]: Rust type system (and overall coding conventions) is really good at building things such that it will only compile if you check for all cases or, at the very least, leave some explicitly unchecked cases. I invite you to try to teach Rust's type system to level designers.
- deleted 4y ago[deleted]