Should I pick up Rust?

I have been working with Java and Python for about 10 years.
However, my degree is actually in finance - everything I know about developing stuff using programming languages and tool chains is self-taught.

Actually, I don't really know that much about software engineering. I can build web services with Flask and Spring but it's really just USING stuff that's already done for me.

Anyway, now that you know where I am coming from, I'll tell you my plan: I bought some C and C++ books. Basically I want to learn more about the nitty-gritty stuff that happens in the runtime.

I want to build my own 2d game engine and some games using it. I know the premise of writing a game engine from scratch is a fools errand!
I know my games are highly unlikely to be interesting to anyone but me!
The things I want to do here are purely for fun - and for learning a non-managed (native?) language and get some feeling of control back :slight_smile:

So, should I sell my C and C++ books and focus on Rust? My main concern is that I don't have a lot of time and energy after work to two major languages that have been evolving for decades - plus, I somehow feel Rust could be more useful to my career than C or C++

However, I don't want to reach a point where it's like "yeah, to do that stuff efficiently enough for the timings you require, Rust is too high level and you need to go to C"

Actually happened to a friend of mine who, despite my advice, started working on a game using Java and got stuck with garbage collection and memory footprint killing his game.

1 Like

Both C/C++ and Rust will help you understand things at a deeper level from my experience. If it’s just for fun why not learn both? If you start with C/C++ you’ll appreciate Rust more. If you start Rust, you can still pick up C/C++.

I don’t think you’ll run into a situation where the language itself stops your progress. It may be worth noting that since C/C++ is older it has more stuff online to help. I’ve found the Rust community to be welcoming though, so I don’t think it’s a big deal. Only thing that might make C more useful in my opinion is graphics/shader languages tend to be c-like.

I wish I could pick all 3... Actually, Assembly is also super interesting... but as I said, only THAT much free time in life :slight_smile:
...
Obviously the language itself has no "speed" but if it is managed and interpreted, in my opinion, that hugely limits the scope of solutions it should be applied to. Definitely had this discussion before and I've learned not to insist my point :slight_smile:

1 Like

I like to think of it as standing on the shoulders of giants instead of reinventing the wheel.

Along this vein, you might want to check out the Bevy engine for hobby game design.

2 Likes

This is one thing you really don't need to worry about. Rust is as low-level as C, and if there are a few things that C can do better, there are at least as many things that Rust is already better at, and that ratio only gets better with the passage of time. Rust does not have a garbage collector like Java or Python, and gives you a lot of control over resources. The reverse of that coin, of course, is that control of your resources comes with the responsibility to use them intelligently, which is something you don't often have to think about in a garbage-collected language, so you may have a bit of a learning curve there. Fortunately Rust is still way ahead of C in this respect, and will help you avoid the worst pitfalls of manual memory management.

Okay, there's two things to talk about here. First, you don't need to learn C to learn C++; it may help a bit if you are doing FFI or very low level stuff, but that is also true of Rust. Really, knowing some C is generally useful just to understand what people are talking about when certain topics come up, but you don't need it for general use. It is reasonable to achieve the goal of writing a game engine, with top-notch performance, purely in modern mostly high-level C++ without ever dipping in to "regular" C. C and C++ should really be regarded as independent languages. So my first frame challenge would be: if learning two languages is intimidating, consider learning just C++.

Second, well, this is the Rust forum, so perhaps I am biased. But that said, I think Rust is significantly easier than C++ at a language level. There is a lot of cruft in C++, both coming from C and from earlier versions of C++. It may be true that you can get "up to speed" easier in C++ – I don't know if anyone has actually measured that – but the gap from intermediate to expert feels to me a lot bigger in C++ than in Rust. So even with the dilemma narrowed to "C++ vs. Rust", from a learner's perspective, I think Rust still has the advantage.

Where you will likely run into issues, instead, is the availability of libraries and learning resources. A lot of the game design literature will focus on using C++ or C# because those are more common. Learning Rust alone may limit your range to those resources which are specifically targeted for Rust developers. You won't be able to use the libraries or the design patterns that other people solve problems with.

As a Java and Python developer, you may also find C++ more approachable since similar OOP techniques can apply to it that don't apply in Rust. Judging by questions on sites like this one, adjusting one's mindset from the OOP-like "inheritance everywhere" to something that works with Rust is one of the hardest adjustments programmers make when learning a new language. It can feel like learning to code all over again. (It's worth noting that this is also true of C, if you plan to do anything particularly complex with it; you'll need to take a different approach than you would in a language oriented around inheritance.)

There are good reasons to choose Rust but there are also good reasons why Rust might be extra challenging for you. At the end of the day only you can decide. If you decide to undertake learning Rust, let us know how your journey goes.

I think this is a great place to start learning Rust. If you had specific requirements or a tight deadline, those might make Rust a poor choice for you. But I think you'll learn a lot from Rust and I do think it's more fun than C++.

3 Likes

If you want to actually write a game, I'd suggest C# and Unity. It will have a shorter time from now until you can play a prototype of your idea.

If you just want to write an engine for the sake of having written an engine, Rust is great for this! :smiley: Rust's memory management will require you to be creative with ECS design, and Rust is low-level enough that you can have satisfaction of optimizing every instruction.

5 Likes

Thanks a huge lot for some very thoughtful comments!

I think the biggest issue that remains a worry for me is actually learning Game Programming - the techniques of how to draw frames, hit-boxes, sound... Heck, I am pretty sure I NEVER wrote anything that's not console-only!

These are complex enough that there'll be a learning curve no matter which language you use. Libraries exist to help abstract things away, but all abstractions are leaky and you'll eventually need to learn how they work, anyway.

You might want to browse https://arewegameyet.rs/ to see some libraries that tend to be used in games. You could use them directly, or even open up the source code on GitHub and borrow inspiration. Reading other people's code is a great way to pick up a new language.

4 Likes

That is not a thing.

Rust has the same low-level memory model and can do the same things as C (or C++). If you compare microbenchmarks, some will favor Rust slightly, some will favor C slightly, some will show no discernable difference. Rust has no GC, so that particular problem whereby GC latency starts to become an issue isn't remotely likely to happen.

4 Likes

To further support @H2CO3 's point: I am working on some performance intensive stuff, and I have never once found a need for C/C++. On the contrary, it has been great getting errors at compile time instead of having to use gdb / valgrind, or, worse yet, tracking down non-deterministic race-condition bugs.

1 Like

Huge thanks. Really. This is a turning point in my life and the guidance here, although very initial, is going to affect how I spend a good amount of my free time.

I hope to learn things and give back to the community. One of the attractive things about Rust is that it's really quite new and I can see opportunities even for me to contribute and make a lasting impact.

I really hope Rust becomes the next huge thing!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.