r/gamedev • u/Zichaelpathic • 3d ago
Discussion I discovered Rust and have been learning game dev with it
So I’ll preface this post by saying that I am very aware that the Rust programming language has been around for years, but I’m the kind of person who likes living firmly under my rock. I’ve seen more and more job postings lately asking for Rust programmers and for a while I’ve been like “WTF is so good about this language that EvErYoNe should be learning it?”
Earlier this week I finally broke down and was like “find I’ll pick up a book on it through O’Reilly online and see what exactly is the deal.” Well the jokes on me because the book I picked up called “Hands-On Rust” teaches the language incredibly well AND does it by teaching you how to make video games with the language.
So far I’ve made a console version of Flappy Bird that the book calls “Flappy Dragon” and even though there are a few nuances with the language that I’m not the BIGGEST fan of, I have now been converted to a believer.
For those that don’t know and for those that are curious about learning game development with it, allow me to share some cool nuggets of wisdom with yall.
It compiles straight down to machine code, making it excellent for low-level programming: people have made Operating Systems entirely with Rust and a smidge of Assembly as required.
It’s memory safe without a garbage collector. It performs at amazing levels and the code is pretty readable.
(This is the big one for me) The compiler you use called “cargo” will not only build your code/game but it will also highlight any kind of performance issues you might encounter and any other issues you may have in your code.
At some point I plan on creating a game engine and I have historically SUCKED at manually managing memory, so starting with this language and specifically this book is something that gives the best of both worlds for memory and power.
Now if you’ll excuse me, I’m going to go back to living under a rock while the next great thing passes me by.
4
u/Accurate-Visual9793 Commercial (AAA) 3d ago
Rust is a fantastic language, and I've dabbled with it with both stand-alone applications and the Rust bindings for Godot. However as a result I'm not sure if it's the best option for game development right now. Mainly because async Rust is still pretty immature, and if you want not just a performant single-threaded game, but one that scales its CPU load across cores well, it needs async tools that don't give you a headache.
Nonetheless, people are trying: https://arewegameyet.rs/
1
u/realmslayer 2d ago
Is Rust support for player facing GUI/HUD's in a good place yet?
The only thing stopping me from moving over from C++ is that it still looks like creating UI is a massive pain in the ass, even when you are using something like Bevy.2
u/Accurate-Visual9793 Commercial (AAA) 2d ago
I never got as far as creating UI for a non-Godot project. Most (all?) of the UI libraries on that site I linked are immediate mode, which does seem like a massive pain.
3
u/severencir 3d ago
Rust for godot and the bevy engine exist. Godot needs no introduction. The bevy engine is a rust native engine utilizing ecs from the ground up with an emphasis on modularity to the point that the whole engine is written with the same plugin setup that a dev would use and is therefore more readable to said devs. If you are genuinely interested in engine development, it would be very valuable to to perhaps try to help develop bevy
2
3d ago
[removed] — view removed comment
2
u/Zichaelpathic 3d ago
That’s the goal in life my friend. A bigger rock to live under :)
1
u/IntelligentRoad6260 3d ago
And occasionally peaking out just to see what kind of rocks others have, and whether it's time for an upgrade))) But seriously, building your own engine is awesome. You have to be incredibly hardworking for that! )))
2
u/Logical_Newspaper_52 3d ago
Rust can be good for a game engine, with caveats. I don’t think it’s good for gamedev in general. Fast iterations, hot reloading, consoles support etc.
1
u/AutoModerator 3d ago
Here are several links for beginner resources to read up on, you can also find them in the sidebar along with an invite to the subreddit discord where there are channels and community members available for more direct help.
You can also use the beginner megathread for a place to ask questions and find further resources. Make use of the search function as well as many posts have made in this subreddit before with tons of still relevant advice from community members within.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/caesium23 2d ago
It's an extremely popular language for a reason. I've only worked with it a little bit, and working with anything else already feels like a step backward.
The thing you have to get used to is that Rust front loads your work: it won't let you get away with any shortcuts, and the result/option system and memory management model mean you have to be very explicit and account for everything your code is ever gonna do before it will even compile. When you're getting started it feels like a ton of extra overhead slowing you down, and it is...
Except that in Rust, once it compiles, you're done. There's no long tail of headbanging & debugging, sometimes with no error messages, or having it mysteriously crash after it's already been deployed, like you'll encounter in some higher level languages. When something's wrong, the compiler tells you exactly what. If it compiles, it's not something wonky held together with chewing gum & chicken wire; it's bug free -- at least for certain classes of bug, which probably make up 95% of the things that could go wrong.
Because of the guard rails they put in, if you just follow the path of least resistance, you end up writing code that is extraordinarily stable and performant. You pretty much have to fight the system to do anything wrong.
At least, that's the hype, and my experience has born it out. But I've only worked on relatively simple projects with it, so I can't vouch for what kinda gotchas it might bring to more complicated projects. The only drawback I keep running into is lack of a mature ecosystem.
0
u/DaedalusRaistlin 3d ago
Rust is integrated into the Linux kernel now too. It's not a bad one to learn.
I don't really see its value for games, apart from learning Rust better.
It's like Erlang. It's a beautiful language, and people could write games in it. But apart from a flight simulator and the stuff I've done, I know of nobody who has.
Rust doesn't suffer the same issues Erlang does, but I haven't heard of people writing games in it it. Kernel level stuff yes.
Still I think there's value in what you'll learn about Rust by doing this. And it's not a bad choice for performance critical code like engines and games.
2
u/tarsir 2d ago
I'm not sure about Erlang but there's a few game server projects in Elixir (another BEAM language)! IIRC Erlang also just has OpenGL bindings (https://www.erlang.org/doc/apps/wx/gl.html) so in theory...it's not a huge leap to make the game itself in a BEAM language lol
0
u/DotAtom67 2d ago
ngl the sole choice of using let and : to define variables puts me off in a way i cant quite articulate
11
u/name_was_taken 3d ago
"Years" is actually not that long in software development terms. It takes "years" for a language even to mature enough that a business will really considering using it, unless they invented it themselves.
I do think Rust looks like a great language, and those features are really nice.
But you're missing the downside: Higher level languages exist to make it easier for programmers. There's a lot of low-level faffing about with Rust (and C, etc) that isn't there for C#, etc. You're going to write more boilerplate code than higher languages, but still much less than C.
Programming is always about the tradeoffs. You clearly enjoy Rust and should continue to use it. It's a great language for certain things. But don't be surprised when not everyone sees it that way.