Live data from Hacker News

Why Rust Is the Future of Game Development

thefuntastic.com

171–180 of 247 posts

Re: Why Rust Is the Future of Game Development

#171

Is it though? I feel like most people compare Rust to C++98 and if you do that, certainly Rust looks really good. The benefits of Rust compared to, say, C++17 are not as pronounced.

It's still quite easy to shoot oneself in the foot with modern C++: #include #include #include int main() { std::string_view v = std::string("xyz"); std::cout

I'm try to not sound rude, but I don't think I can. Every C++ developer with even some significant amount of experience will identify this as bad code with one eye closed. Of course this looks wrong to someone that doesn't know the language. People freak out because it crashes your program, but in the end it's just a bug and producing bugs that are not obvious to someone that doesn't use the language much is very easy with every language.

I remember people prophesizing the end of C++ because of the introduction of string_views. When writing a text editor over a couple of weeks (a lot of text manipulation) I used string_views extensively and purposely over-used them (returned them a lot or kept them for a long time), because I wanted to see how dangerous they could be and I never got a bug/crash that was related to them. Of course you have to think about what you are doing, but you should be doing that anyway. What I am trying to say is that while it's never "free" to not write bad code, if you get used to it, you don't have to think as hard about it, as you might think.

There are way more common examples of easy ways to break your code, like storing references/pointers to elements in vectors, which then resize or capturing objects in lambdas that get destroyed before the lambda is executed and stuff like that. Even out-of-bounds access to arrays/vectors is a lot more common than that, I think personally.

Re: Why Rust Is the Future of Game Development

#172
post #80

When discussing games, where players demand excellent performance but are tolerant of initial startup times (i.e. launching the game from Steam or the Start Menu) being long, then I question why Java isn't the future. By all accounts Java has the most sophisticated runtime out there, it has all the safety features of Rust without fucking around with the borrow checker which seems like a huge piece of complexity just…

There is nothing wrong with Java except the issues surrounding protecting your code from reverse engineering.

Re: Why Rust Is the Future of Game Development

#173

Earlier quoted context omitted.

Isn't it a use-after free? (I haven't had time to compile and run it) You have a temporary std::string, pointed to by a string_view, which means that it's freed, and the view is dangling, and then used when printing things out.

So thats what I initially thought but then I ran it and it works so IDK anything anymore.

It's undefined behavior, so it'll literally print anything. On my system with my compiler version it'll print xyz without any optimization, but if I use -O3 optimization it prints nothing. But it could just as easily segfault or print garbage from memory.

Edit: If I move the first line into a function and return that string_view, then with optimizations it still prints nothing, but without optimizations it prints random varying garbage each time I run it, different each time.

Re: Why Rust Is the Future of Game Development

#174

> Way back around 2010, Mozilla was frustrated by the state of development in Firefox, a massive software project written mostly in C++. Despite best practices > Even so, manual memory manipulation is easy to get wrong, Even predating C++11, you should not have been doing manual memory management. I don’t think Mozilla was following best practices. IIRC, there were pointers everywhere. Even before C++11 best practice…

So what in the language prevented them from doing it that way? What in the community ensured they didn't do it that way? Firefox is open source, and yet it still happened. "Best practices" is such a red herring. Best practices = don't write bugs, too; yet there are bugs. You can't evaluate a language in theory and ignore what happens in practice any more than you can with any other thing in life. It's the UX, does it…

> "Best practices = don't write bugs" That's absolutely not what it means. Best practices usually means "don't use these features anymore" and "use these features whenever you can". And that is very reasonable and DOES get rid of a lot of the problems (not all) that are usually associated with C++, but still people don't do it. I blame it many C++-people actually preferring "C with classes" (various code bases openly prefers this as their coding style - you won't get those people on the Rust train either) and many people just don't know or don't trust it, because some of the newer features are sadly not very easy to understand properly.

Re: Why Rust Is the Future of Game Development

#175
post #171

Earlier quoted context omitted.

It's still quite easy to shoot oneself in the foot with modern C++: #include #include #include int main() { std::string_view v = std::string("xyz"); std::cout

I'm try to not sound rude, but I don't think I can. Every C++ developer with even some significant amount of experience will identify this as bad code with one eye closed. Of course this looks wrong to someone that doesn't know the language. People freak out because it crashes your program, but in the end it's just a bug and producing bugs that are not obvious to someone that doesn't use the language much is very eas…

> People freak out because it crashes your program

People freak out because it _doesn't_ crash your program (until it's running in production of course). On my system without optimizations it prints "xyz" just fine, with optimizations it prints nothing, even though I'm accessing to the middle of memory. I think on most systems this will not actually crash unless you have explicit out of bounds memory tracking inserted into code by the compiler every access slowing down your code.

The point is in Rust this wouldn't even compile.

I'd be curious if you ran your text editor through a memory sanitizer like valgrind and how many issues it points out.

Re: Why Rust Is the Future of Game Development

#176
post #4

Let me tell you that most C++ game dev never heard of Rust, so imagine how long it's going to take for Rust to be something usable in that domain? Right now in the real world of AAA games it is nowhere, it's not even a consideration so calling it "Rust Is the Future of Game Development" right ... For those who don't work in games, the tech there move very slowly, it's not your typical SV "let's use the latest fun and…

If you openly admit in a public internet forum that you use C++, you WILL be reminded that Rust exists and it vastly superior to your choice of tool. I find your statement very questionable and don't personally know any game developer (though I know a good number) that hasn't heard of Rust. So I would like to know if you actually know this from experience or are just guessing.

Re: Why Rust Is the Future of Game Development

#177

Personally, I'm betting on Haskell - for indie dev in particular where I want to manage huge amounts of complexity as an individual. This is partially because I've been programming Haskell professionally for 5+ years so I'm over the learning curve and well into the realm of efficiency gains. The GHC RTS is akin to the Lua layer and handles all the high-level logic. For storage and compute-intensive things, we can dro…

I could see this with Idris, but Haskell's lazyness is just too unpredictable for anything you wouldn't use a scripting language for. People have been trying to get gamedev done in Haskell for like a decade with virtually nothing to show for. The LambdaCube 3D guys have been working on it for ~8 years and last I've seen they couldn't even get quake 3 graphics to render smoothly.I haven't seen any noticeable development in recent times, so I don't expect that to change in the next few years.

The only thing I could realistically see happening anytime soon would be people using it as a scripting language for Godot, but I'm not convinced that working with the Godot abstractions won't rob you off most of the gains you make by using Haskell.

Re: Why Rust Is the Future of Game Development

#178
post #131
post #114

Earlier quoted context omitted.

Unfortunately, Rust has limitation on what it can prove to be safe using the ownership and lifetimes approach. One of the simplest things which can't safely be done in Rust is a doubly-linked list. I'm certain that Rust will help some parts of game development a lot, but I'm also certain that game developers sometimes use tricks safety of which cannot be proven by Rust's type system.

>Unfortunately, Rust has limitation on what it can prove to be safe using the ownership and lifetimes approach. One of the simplest things which can't safely be done in Rust is a doubly-linked list. It can be done "safely" in Rust, as in without actual bugs; it can't be done in "safe Rust", that is, Rust without `unsafe{}` blocks. But it's reasonable to assume that any Rust game would make liberal use of `unsafe{}` b…

> potentially faster compile times than C++ when Rust is more mature

First cargo needs to also handle binary dependencies, and C++20 has modules now.

Re: Why Rust Is the Future of Game Development

#179

Earlier quoted context omitted.

Not directly relevant, but the use of the phrase “democratization” to describe a process that has nothing whatsoever to do with democracy (“anarchization”?) has become a pet peeve of mine.

It's really about the empowerment of the masses; giving 'non-programmers' the power to create software.

Right, so like I said - nothing to do with democracy.

Re: Why Rust Is the Future of Game Development

#180

This article doesn't actually talk about "Why Rust Is the Future of Game Development." You could have taken out the game development piece, and it still doesn't talk about "Why Rust Is the Future of Development," more than talking about Rust features themselves. I should be able to complete the sentence, "Rust is the future of game development because...," but I can't in any meaningful way. Here are the highlights of…

>It may come as a surprise, but you basically have to bake networking into the engine I'm not sure what you mean? Are you saying bevy's architecture isn't fitting? Not to mention that you evidently don't _have to_ do this, seeing as how in Unity you're basically forced to work with raw sockets.

I'm not making comments about bevy. I'm talking about game engines in general.

> Not to mention that you evidently don't _have to_ do this, seeing as how in Unity you're basically forced to work with raw sockets.

I don't know how old you are, but by the time 1999 rolled around, id Software had produced essentially the same multiplayer client-side prediction model that has been in major use to this day. It hasn't fundamentally changed.

The fact that Unity cannot reproduce 20+ year old tech is a joke, not an example. In fact, UNET was such a joke it basically tried to ignore this fundamentally unchangeable architecture and they ended up canning it in the end.[1]

[1]: https://blogs.unity3d.com/2019/06/13/navigating-unitys-multi...

Post reply on HN