Hacker News new | past | comments | ask | show | jobs | submit login

What is the Rusty way of handling memory management for a game engine client deployed on WebAssembly? When a program is running a game loop, there are certain entities which will stick around across frames, and there are certain entities which definitely will not. Is there a way to enforce that most of the implementation of the game reside in pure functions, while making memory management nearly bulletproof?



Nothing about this is specific to WebAssembly; you’d write the same Rust code as you would for any other target.


In that case, what's the Rusty way to handle a game loop, in which one wants to encourage the use of pure functions? I must confess: I'm thinking of using Rust and a few other languages as a compiler target for a unified Web Client + Server game engine. Is there a particular way in which Rust could support this better than other languages compiling to WebAssembly?


Rust is not super worried about purity. That said, Rust is also more pure-ish than not; the large control over mutability and sharing helps. Controlling allocations is also generally easy, as there's no special things that are doing allocation behind your back. Arenas/memory pools are well supported too.

> better than other languages compiling to WebAssembly?

The best supported languages for this are C, C++, and Rust. So that's really the comparison here, IMO.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: