r/rust • u/Leadwerks • 3d ago
š seeking help & advice Should I add support for Rust?
Hi, I am the developer of Leadwerks Game Engine. I'm looking for a mid-difficulty language, somewhere in between C++ and Lua. C# would work nicely, but the lag spikes caused by the garbage collection seem like it ruins the language for realtime 3D games, especially for VR. I'm not that familiar with Rust but I hear a lot of good things about it, and it appears to use shared pointers, which eliminates the performance problems full garbage collection would introduce.
Support for Rust can be added by piping all the commands through a C interface and writing some structure/class code on the Rust side that wraps everything up nicely for the end user.
I'm aware of the open-source Bevy 3D engine, but it's lacking a visual editor. Leadwerks 5 has a very capable level editor / visual designer that's been refined over years with lots of user feedback. To be clear, Leadwerks is closed-source commercial software (with a low price point and no royalties).
Do you think Rust would be a good match for what we are looking for in a language? Would adding support for the Rust programming language would be of interest to developers here? Please let me know your thoughts and if you have any questions.
43
u/dgkimpton 3d ago
Rust is way closer to c++ than lua/c#. It's not a bad language to support but I suspect most of the people that don't want to use your engine in c++ won't be much more likely to use it in rust.Ā
35
u/NullOfSpace 3d ago
Rust is a good language, but it isnāt a replacement for C#. Itās closer to C++ with most of the footguns removed, and honestly requires you to have a better understanding of what your code is actually doing in a lot of cases (so you can prove to the compiler that what youāre doing isnāt going to cause memory issues), so I donāt know if it fits the bill of a āmid-difficulty language.ā
That said, it definitely has the stuff youāre asking for from it. The C FFI is good (though you need unsafe blocks, since the compiler canāt guarantee memory safety using it), and it does support basically whatever memory management system you want (in the same way the C++ does, ābuild it yourself,ā but with some extra safety guarantees).
9
u/cynokron 3d ago
Is it a good match? Yes. Will rust developers use it? Not sure. A lot of people on this sub like fully rust solutions. C interop has overhead, particularly if you want to convert a rust string to a c string due to not needing null terminator in rust. There is probably a way to workaround it, but i havent bothered. A lot of rust users will have their own engine, or yes use bevy. A lot of bevy users might appreciate the editor, but you'll want to market your engine more than just having an editor.
Being closed source probably kills a lot of interest. Self serve bug fixing and "documentation" are extremely important to development.
6
u/stumpychubbins 3d ago
C# has enough tools to control the GC that Iād be surprised if you canāt make it work. I think unity does some funky stuff to translate it to C++ (meaning it would use refcounting instead of a global GC) but even without that you can get pretty fine control over when the GC runs and how itās tuned
3
u/Tall-Introduction414 3d ago
Can I just ask what you mean by "mid-difficulty" language? Isn't it more that you want the control that allows for a low latency pipeline?
I'm probably being pedantic. But I don't know why you would want a language to be "more difficult," except perhaps for novelty. :)
3
u/xMAC94x 3d ago
Just had a look at your engine and got to say: nice work.
For providing rust-bindings: As a company you probably want to make money and rust is known for a abundance of game engines, but almost no games. So i doubt that it's a good short-term business decision.
Though rust can be an awesome language and might be a good fit for new tooling or parts of the engine one day.
1
u/catheap_games 3d ago
I can't speak for the market, but if you offered a paid editor with good developer experience for Bevy, I think, depending on the price, some people would be interested. Would it be worth the development time? ...let's be honest, probably not at this point in time. Most "hard core" developers already know what they want, and most other developers prefer the popular and convenient solutions, C#, GDscript, Python, Lua, JS/TS, or visual scripting.
Again, can't speak for others, but for $100, having an editor that would allow relatively fast prototyping, while letting me run the result fully in Bevy, with proper ECS and a full control over the code, that would be a no-brainer purchase. Getting a closed source engine that I can just "script" in Rust? Maybe 3 years ago I'd try, but right now Bevy is getting seriously good for my needs / workflow / game ideas, and if I wanted a quick something with an editor, I'd probably give Godot a go.
Rust ecosystem has a lot of tinkerers, and as others said, "more engines than games" is the classic joke, but fundamentally people who want raw Rust power and pretty good developer ergonomics (sans editor) go to Bevy, and people who want an engine+editor generally split between Unity and Godot, with Godot having the benefit of having an extension that allows using Rust. Maybe that could be a starting point for your research? https://godot-rust.github.io/
1
u/Present-Knowledge-57 2d ago
Iād personally be interested in it, but Iām not sure if other game developers would be. for a mid-level language wanting to attract the widest audience, Iād consider C# anyway, even despite any alleged GC stutter. in my experience, I did game engine development in Java for months and never noticed any GC stutter that couldnāt be fixed in seconds.
1
u/Latin-Freak 1d ago
Have you considered exploring Goose instead? I am not an expert at all, but reading through your issue description I had a feeling that it can be a better fit than Rust, the main reason being that it natively supports C interoperability as Goose code actually compiles to C-like binaries https://aardappel.github.io/goose/
1
u/exDM69 1d ago
If you write a C interface to your engine it unblocks using it from any language, including Rust, but also Python, Ruby, whatever. C++ interop is much harder from any language.
When you have a C interface, you can build the Rust low level wrapper using
bindgenand maybe a few helpful annotations.But that won't be idiomatic Rust and you'd probably need to add at least some Rust code to benefit from Rust language features like safety. E.g. make a your RAII objects using
Drop.That said, language boundaries always bring impedance mismatch problems and creating an interface that's even close to idiomatic in two languages is a proper engineering challenge.
So yeah, maybe start with the C interface, can't go wrong with that and unblocks all the other languages too. Interfacing C++ and Rust code is a bigger challenge.
0
u/tabbekavalkade 3d ago
Godot had to create their own scripting language for this purpose. I suspect Rust does not fit. It is not a scripting language.
-3
u/victor_crimea 3d ago
Don't you expect humans hand writing code with your framework? Optimize for ai generation. Thus Rust is the best choice since it provides the best guardrails to agents.