Rust for UE ?

I start learn rust lang.
Seems very good for games.
How about add rust support to UE?
I think it be big step to UE game stability.

3 Likes

No any try?

Don’t want to re-learn another language. I tried it a bit and seems pretty different. Not bad but i feel like C++ is more suited for game development anyway. Plus there are other more important things like improving the C++ workflow and improving Live++ and so on.

1 Like

Maybe Unreal Basic will make the engine complete, one day. The right way to make super basic games.

Stability doesnt come from a language.

1 Like

Then instead of 50,000 lines of C++ to make a small game we would only need 4 million lines of basic!

Nope. That claim will not hold.

lol I see you don’t know Futurama.
that is just a reference to an episode of Futurama :wink:

I understand! Still doesn’t make it true.

I took a look.

It’s the same as binding any DLL, in Rust you wrap everything into a extern ‘C’ {…} and then compile your Rust application as *.so or *.a library.
Then you load the library into Unreal and call functions from it. Boring stuff, making extern C functions is the most boring thing to do even if you use automatic header generation tools.

Every time you need something more you have to add more extern functions :confused:

No need to poll, no need to ask. If you think it is good, why dont you make it yourself, and then present it here? :wink:

Rust is actually interesting as a binding because no need for memory management AND no garbage collector needed either.

But yeah, if you want to use it you have to write extern C api yourself and do BP → C++ → C → Rust…
Then Rust → C → C++ → BP.

That is very annoying code to deal with once you go above the HelloWorld level.
Btw I know that some AAA studio migrated to Rust doing that, just don’t remember which one. Maybe was “Ready at Dawn”, not sure.

1 Like

I went over a small test just to see if Unreal would allow this or if it would complain…
Turns out it’s possible to make it work indeed:

Rust application compiled as --lib:

extern “C” interface:

called Rust functions from within Unreal project’s module:

works fine:

[HR][/HR]

Now all you need is an ARMY of programmers to port Unreal’s code to Rust language :wink:
Good luck lol

2 Likes

In theory yes.
In practice I would need funding to do that, because that would become a full-time job for me.


Also, what exactly do you mean with “simpler”?
My first programming language I ever used was BlitzBasic, and I still love the way it was structured.
Do you mean THAT simple or you mean “simple like C# and Java”?! ( those aren’t simple, they just hide complexity)

I have no idea…
I can’t drop my job to do it, so what I am saying is it’s probably not going to happen anytime soon.
I wouldn’t encourage anyone to wait for it. Can be done, but I won’t even talk about ‘whens’ and ‘ifs’… right now I only tinker with these things on weekends.

I’m not familiar with Rust’s FFI stuff, how much work would it be to transfer more than primitive data types across the boundary? Would it just require doing the mapping into structs on Rust side and annotating them with #[repr(C)]? What about C++ side?

I’m not familiar either, but I think Rust has a “Box” (it’s literally called box) mechanism which you can use to collect C data such as complex structs and then manipulate them within an unsafe block.
I think it can also share pointer addresses with C code, but I’m not sure how that works either.

Their docs have this example, calling C function from Rust side:



extern "C" {
​​​​​​ fn abs(input: i32) -> i32;
}

fn main() {
    unsafe {
        println!("Absolute value of -3 according to C: {}", abs(-3));
    }
}


Box is just used for managing the ownership of heap allocated data, I don’t think it’s required here (not sure how trait objects would work here, if at all).

Btw, I’ve found something very useful I didn’t know existed:

https://rust-lang.github.io/rust-bindgen/

I would reconsider UE4/5 over Unity if it had Rust. Especially since Unity may never support Rust. While I could live with C#, it’s not as ideal for games as Rust because of its GC.

The thing with Rust is that it is intended to replace C/C++ in the entire industry altogether, not just in game development. And it is getting very close to that goal.

It’s voted 4 times(if I recall) in a row as the Github favorite.

It is almost as accessible as C# but as fast as C/C++.

It’s even as a “system language” a safe language. No seg faults, no dangling pointers, no nulls, no headers, and it got safe threads. Data Oriented design over the OOP non-sense.

It’s eventually going to be fully embraced by Microsoft. According to them, C/C++ is not a valid choice anymore. 70% of their security flaws could have been avoided with Rust. Security may not be an issue with games, at least offline games, but when Microsoft makes the final move to fully embrace it. Rust obviously will come to Visual Studio and the entire MS ecosystem, including DirectX. A COM Rust binding generator is already in the works by MS.

As somebody who comes from C -> C# -> F#. I got zero regrets so far with Rust. I’m still amazed that a “system language” could be designed in such an accessible way, almost as if it was something like managed code C#/F#.

As somebody who follows not too closely, bot close enough the evolution of AI these days. And witnessed the super human genius of AI. It wouldn’t come as a surprise to me if somebody like MS could come up with a AI based translator that can convert full C/C++ code to idiomatic Rust. No need to waste time on mere bindings for UE. Convert the entire engine.

For all we know UE5 could be already on a road map for such a full conversion to Rust. Like I said, Rust is meant to replace C/C++ not just to compete with it as yet another language. And so far the signs show that it does a very good job at it. Not to mention that such a converter would be a huge use outside of MS as well. There is certainly need for that.

1 Like