News for hackers. Stuff that matters.

laundmo

Re:RAII and the Rust/Linux Drama on Sunday December 08, 2024 @09:37AM (#42357366)
re: std::mem::forget not being used much

On one hand, its just a shortcut to moving a value into the transparent ManuallyDrop struct and forgetting the result. In most cases, ManuallyDrop is the preferred way, as it allows encoding this behaviour (disabling the built-in drop) on a type level.

And if you want arenas or similar structures, they simply don't need to use either. The arena struct itself usually implements Drop to enact whatever it needs for deallocating the data its storing. The things stored in them also don't need ManuallyDrop since they're just written to memory directly using unsafe calls, and the compiler doesn't know this data exists (depending on implementation, some directly use syscalls, others use a Rust datastructure like Vec<u8> for allocating their memory). Nowhere in this is mem::forget or ManuallyDrop required, and the resulting API is usually far nicer than dealing with ManuallyDrop.

Re:Bevy 0.10: data oriented game engine built in Rust on Monday March 06, 2023 @02:34PM (#35046428)
It does in a way use a limited subset. Specifically, the borrow checker is rarely a concern since Bevys ECS storage abstracts that mostly away from the user.
Re:Bevy 0.10: data oriented game engine built in Rust on Monday March 06, 2023 @02:29PM (#35046368)
Edit: i was a dunce and explained data-driven, which it also is, but is not what you asked.

Bevy is data oriented due to its ECS: roughly: which data an entity has attached to it decides which behaviours are run. Want something to have a health bar? Just attach the Health { current: 50, max: 100 } struct and it will have all associated behaviour like being able to take damage. Want to make it invincible again? Just remove the Health struct.

This is different from OOP engines, where you might need to keep an is_invincible boolean around to check against.

Re:Bevy 0.10: data oriented game engine built in Rust on Monday March 06, 2023 @02:25PM (#35046294)
you're right, that warning could be improved as it assumes knowledge of how the Rust community usually does these things.
Re:Bevy 0.10: data oriented game engine built in Rust on Monday March 06, 2023 @02:11PM (#35046080)
bevy definitly runs in browsers, but since the browser support for WebGPU is limited, it currently uses the WebGL fallback.
Re:Bevy 0.10: data oriented game engine built in Rust on Monday March 06, 2023 @02:06PM (#35046011)
There was a user on discord a while back who got bevy running in some capacity on, I think, Xbox and Switch. He had trouble with the PlayStation, though. Since you have to sign NDAs with the companies to do that, I don't know what came of it.
Re:Bevy 0.9: data oriented game engine built in Rust on Saturday November 12, 2022 @08:52PM (#33579156)
would be a fair point if the releases weren't actually significant changes