Hacker News new | ask | show | jobs
by Const-me 3106 days ago
One reason is SIMD. Videogames contain quite a lot of math that benefit from SIMD a lot, be it MMX, SSE, AltiVec/VMX or NEON.

Another one is that borrow checker. Games are heavily multithreaded since X360. Game state + game assets = huge pile of data shared across threads. Borrow checker in Rust makes it harder to write parallel code that operates on that large shared state. For small state and/or plenty of RAM you can afford making copies but games can’t afford that. Sure Rust brings value here by eliminating a class of bugs, but for game clients (servers are different story) the optimal safety/resource tradeoff is at another place than e.g. for a web browser.

Finally, games often use many third-party libraries and frameworks (sometimes called middleware), and due to historic reasons majority of those are C or C++ libraries.

1 comments

Rust has no issues sharing state across thread without jumping too much hoops, as long as you can make the borrow checker believe that only a single thread at a time gets to mutate state and when a piece of memory is accessible from multiple threads it's not mutable.
> and when a piece of memory is accessible from multiple threads it's not mutable.

In game engines, these pieces of memory often need to be mutable by multiple threads. E.g. see this old Intel article for a high-level overview how it might work: https://software.intel.com/en-us/articles/designing-the-fram... Now with DX12 / Vulkan it became even worse, because with them we no longer have _the_ render thread.

Sure, doing that the dangerous C++ way can introduce bugs. But the risks are different.

If you’re working on a web browser (that’s what Rust was created for), the worst thing that may happen, a compromised web site you’re viewing (maybe even by accidentally clicking a link) may infect your PC, steal all your data and turn your PC into a botnet node.

Most games can’t technically fail that bad, due to the following reasons (1) Most games don’t allow users to create content, only the developers do (2) Modern console games work in a hardware-assisted hypervisor (3) Some platforms even verify digital signatures of all the content they load.