News for hackers. Stuff that matters.
Re:Are we game yet? – A guide to the Rust game development e... by pansa2 on Wednesday February 10, 2021 @08:13AM (#26088619)
I assume most game development (or, at least, game engine development) is still in C++? How easy would it be to start moving parts of it to Rust?

For example, if I were to write a library (e.g. a physics engine) in Rust, how easy is it for game developers to incorporate it into their C++ games? Would they need to set up a separate Rust toolchain alongside their existing C++ one? It seems it would be much harder to for them to include my library compared to a competing one that’s written in C++ - especially if the competing library is available as a single header file.

Re:Are we game yet? – A guide to the Rust game development e... by girvo on Wednesday February 10, 2021 @08:19AM (#26088670)
The rise of Unity (C#) and Godot (GDScript or C#) would make me think that most game code is starting to move away from raw C++ — but of course the core engine code is still C++ indeed.
Re:Are we game yet? – A guide to the Rust game development e... by Thaxll on Wednesday February 10, 2021 @10:53AM (#26090804)
"would make me think that most game code is starting to move away from raw C++"

Godot is talked about on Hacker News but it's nowhere in the industry, as for C++ it's the default language for games and it will be the case for the foreseeable future.

I feel that there is a real disconnect between hacker news and people working in the industry.

Most people here don't seem to understand how different it is from your regular CRUD app compagny.

Re:Are we game yet? – A guide to the Rust game development e... by pjmlp on Wednesday February 10, 2021 @01:28PM (#26092944)
While the disconnect is true, specially in what concerns FOSS views of the world and how real studios work, middleware like Unity and WaveEngine are indeed being picked up by major studios.

On the Switch alone, a very big chunk are all based on Unity, more than 50% as per Unity official statement.

Also although the engine is still mostly C++, they have been porting the rendering pipeline into HPC#.

Re:Are we game yet? – A guide to the Rust game development e... by zerr on Wednesday February 10, 2021 @11:14AM (#26091088)
Engine development and game development are two different things. For gameplay/scripting, even in 90s there were alternative languages. The way Unreal uses C++ (i.e. as scripting) is not different to how Unity uses C#.
Re:Are we game yet? – A guide to the Rust game development e... by lima on Wednesday February 10, 2021 @11:34AM (#26091326)
At some point, every game development project becomes engine development :-)
Re:Are we game yet? – A guide to the Rust game development e... by pjmlp on Wednesday February 10, 2021 @01:29PM (#26092950)
Yep, it even has a GC for the C++ based entities.
Re:Are we game yet? – A guide to the Rust game development e... by mqp on Wednesday February 10, 2021 @08:59AM (#26089129)
Unity has a c# scripting api, layered on the core c++ foundation. Unreal, on the hand, is C++ top and bottom.
Re:Are we game yet? – A guide to the Rust game development e... by slezyr on Wednesday February 10, 2021 @09:11AM (#26089312)
> Unreal, on the hand, is C++ top and bottom.

They have Blueprints[1] (visual scripting) and had a scripting language. However, they have removed it since then.

1: https://docs.unrealengine.com/en-US/ProgrammingAndScripting/...

Re:Are we game yet? – A guide to the Rust game development e... by lfowles on Wednesday February 10, 2021 @01:27PM (#26092931)
A runtime scripting language is coming back in some form or another thanks to Epic acquiring the SkookumScript team.
Re:Are we game yet? – A guide to the Rust game development e... by the_duke on Wednesday February 10, 2021 @10:25AM (#26090375)
cxx [1] is a relatively recent effort to enable safe interop with C++.

Mozilla has also published information on how they are rewriting components in Rust and integrating them into the Firefox codebase, though they were using C apis - exposing Rust to C and vice versa is relatively straight-forward.

[1] https://github.com/dtolnay/cxx

Re:Are we game yet? – A guide to the Rust game development e... by hn8788 on Wednesday February 10, 2021 @09:06AM (#26089248)
Godot is written in C++, but it has a stable C ABI, so it's pretty straightforward to include functionality written in Rust.
Re:Are we game yet? – A guide to the Rust game development e... by slezyr on Wednesday February 10, 2021 @09:12AM (#26089339)
They have [semi?]official bindings for Rust https://github.com/godot-rust/godot-rust
Re:Are we game yet? – A guide to the Rust game development e... by worble on Wednesday February 10, 2021 @09:31AM (#26089584)
I don't think there's anything official about it? Anyone can create bindings from their language of choice to GDNative.

Unless the maintainer is directly involved in godot or something (I couldn't see any evidence of this from quickly checking their profile), it looks like a community effort to me.

Re:Are we game yet? – A guide to the Rust game development e... by datalus on Wednesday February 10, 2021 @08:38AM (#26088817)
Rust has good C interoperability. So from C++ it’d look like a C library. You can either write your own glue code or use something like cbindgen to autogen the header file.
Re:Are we game yet? – A guide to the Rust game development e... by gmueckl on Wednesday February 10, 2021 @09:09AM (#26089296)
Many interesting SDKs come with C++ APIs that aren't necessarily translatable to C. Choosing Rust for engine development has the potential of severely hamstringing the team. It is the same tough uphill battle for all languages that aren't C++. Even more so now that the smoke is slowly rising from the battlefield of licensed engines and only a few contenders remain standing. And all of them have a massive C++ codebase and litttle incentive to toss that out.

If there will be a transition to any other language in that space, it'll take a decade or two.

Re:Are we game yet? – A guide to the Rust game development e... by virtualritz on Wednesday February 10, 2021 @10:27AM (#26090408)
There is an effort to automate generating mid-level C bindings for C++ code automagically, to enable easier wrapping in high level Rust APIs, by an unofficial Academy [of Motion Pictures] Software Foundation group. It is called C++-- [1].

At this time we only target the VFX C++ ecosystem but I'd be surprised if people wouldn't use (and extend) this to cover a broader set of C++ libs.

Maybe you can give an example of a C++ API that you deem not "translatable to C"?

[1] https://github.com/vfx-rs/cppmm

Re:Are we game yet? – A guide to the Rust game development e... by gmueckl on Thursday February 11, 2021 @03:43AM (#26099512)
For example, OpenVDB uses templates with user provided arguments at the very heart of its tree structure. Similar things happen in PCL and CGAL. They are template-heavy libraries by design.

OpenCV on the other hand seems to instantiate all possible variants of cv::Mat for their Python bindings. They don't such a big space of valid and useful template parameters and IIRC the specifics are abstracted away from the algorithms working on them.

Re:Are we game yet? – A guide to the Rust game development e... by radarsat1 on Wednesday February 10, 2021 @02:20PM (#26093480)
That's kind of hilarious given the role that C++ to C compiler had in the early development of the language [1]. But sounds useful, thanks for the link.

[1] https://en.wikipedia.org/wiki/Cfront

Re:Are we game yet? – A guide to the Rust game development e... by virtualritz on Thursday February 11, 2021 @06:53PM (#26109172)
There is also this, [1], which wasn't on my radar until today:

"Corrosion, formerly known as cmake-cargo, is a tool for integrating Rust into an existing CMake project. Corrosion is capable of importing executables, static libraries, and dynamic libraries from a crate."

[1] https://github.com/AndrewGaspar/corrosion

Re:Are we game yet? – A guide to the Rust game development e... by datalus on Tuesday February 16, 2021 @09:56AM (#26154385)
True, Google is at least trying to make it easier to bind to C++ [0]. It's still pretty experimental, though.

0: https://github.com/google/autocxx

Re:Are we game yet? – A guide to the Rust game development e... by pizza234 on Wednesday February 10, 2021 @02:37PM (#26093646)
Interestingly, somebody pointed out in a previous discussion that a potentially significant interoperability hurdle (which is the case for the Qt libraries) is that, if a library makes use of multiple inheritance levels, it translates poorly into any language not supporting inheritance.
Re:Are we game yet? – A guide to the Rust game development e... by fulafel on Wednesday February 10, 2021 @11:02AM (#26090931)
The vast majority of games are indeed developed in other languages than C++. The native languages of the most widely used game platforms are C# for anything done with Unity, Java/Kotlin for Android, and Swift/Objective-C for iOS.

The C ABI is the lingua franca still, you can call it from all of the above. And you can expose a C ABI for your Rust library.

Re:Are we game yet? – A guide to the Rust game development e... by nullcat on Wednesday February 10, 2021 @08:30AM (#26088750)
There's something called a foreign function interface that allows rust to access compiled c++ or c primitives.
Re:Are we game yet? – A guide to the Rust game development e... by gameswithgo on Wednesday February 10, 2021 @08:41AM (#26088848)
simple matter of programming