5 ms·
I've been using Bevy recently so here are some thoughts on this: Firstly, the overall quality is high and seeing this attention being paid to the project's org
by noelwelsh 3y ago
I've been using Bevy recently so here are some thoughts on this:
Firstly, the overall quality is high and seeing this attention being paid to the project's organization is another good sign.
Documentation is not great. The Bevy book runs out of content very quickly. The "Cheat Book" has additional useful information: https://bevy-cheatbook.github.io/ https://bevy-cheatbook.github.io/. With these plus the examples I've been able to figure out everything I need, but it's slow going.
I'm not 100% sold on ECS. It loses a lot of type safety and there doesn't seem to be any way to ensure cleanup of entities and their components.
- ioasuncvinvaer 3y agoHow does it lose type safety? I was under the impression that bevy's Query system is type safe.
- noelwelsh 3y agoECS is basically a very simple relational database. There is no equivalent of foreign keys or other constraints between components. I can't say, for example, "every entity that has a location must also have an associated mesh". If I forget to add a component it's just a silent failure. Everything runs fine, just the expected result doesn't happen.
- suby 3y agoYou can probably write runtime tests for this. Some system which queries for component Location, and then does an assert for each component that the associated entity also has a mesh. Granted, this is annoying and not a particularly great solution, but it would serve to give you a reminder for when you forget. I don't mean to diminish from your overall point either, it's a valid and good one I think.
- noelwelsh 3y agoYeah, runtime checks are not very desirable. I have this vague thought that Rust needs a different kind of type system. Standard type systems[0] basically rely on references between values[1]. I seem to read about numerous Rust systems that don't use references for various reasons. Usually the borrow checker gets in the way or they want a different memory layout[2]. This makes me think that what's needed is a type system that allows constraints to be expressed between values without requiring a reference between them. I don't know what this type system looks like, though. [0]: Rust's type system is a fairly standard type system from an academic POV. The novelty is that it's the first language with traction to use a linear / affine type system, but these are relatively well studied in academia. [1]: The theory is not formulated this way, but the representation they compile into is a bunch of references. [2]: ECS, as I understand it, is not a reaction to Rust's type system but an architecture driven by memory layout, parallelism, and breaking-out-of-OO-hierarchy concerns. However the net result is the same.
- spencerflem 3y agoTotally agreed, like when using an int to reference into an array, there's no way to guarantee that the int won't be out of range, so it needs a check every time Also no ideas here, but its fun to think about anyways
- giovannibonetti 3y agoI wonder if a compile-time array-of-structs (AoS) to struct-of-arrays (SoA) transformation like the one done by Zig [1] could fix that issue. [1] https://zig.news/kristoff/struct-of-arrays-soa-in-zig-easy-in-userland-40m0 https://zig.news/kristoff/struct-of-arrays-soa-in-zig-easy-i...
- pcwalton 3y agoIn theory this is what Bundles are for, though it's easy to not realize that there's a bundle for what you want to do. I should note that this is a problem with most game engines, not something unique to Bevy. For example, Unity is infamous for requiring arcane combinations of components to avoid silent failures.
- alice-i-cecile 3y agoThanks (I am the aforementioned project manager) :) Docs are a high priority for me, especially beginner content, assets, and rendering for me. Rust's in-repo examples are really helpful for ensuring they stay up to date, but aren't a replacement for a guided tour. As for the ECS, I've absolutely felt that: the flexibility of the polymorphism created by "just add another component!" can be both chaotic and freeing. Can you say more about what you're looking for with entity cleanup? I haven't heard that complaint before and want to make sure I understand what you mean.
- adastra22 3y agoThe release notes are great btw. Usually if I’m doing something for the first time I look it up in the bevy cheat book, get something that doesn’t work (because it’s two or three versions out of date), then check the intervening release notes. Usually there’s enough direction to figure it out.
- alice-i-cecile 3y agoThey're so, so much work. Carefully going over the log, and patiently explaining / showcasing and contextualizing them is even more work than writing docs for the same feature, since you don't have the API to help structure things. I'm glad it pays off! Seeing them come together makes my day every time, even when I'm writing half of it.
- adastra22 3y agoOh, I know! I’m a maintainer of another open source project and the release notes are such a chore. For the quality of Bevy’s I could easily see it being a full time job, albeit a mostly thankless one. So thank you for the effort you’ve put in!
- mkesper 3y agoAnd I know so many people who think you could automate them from commit messages. Hell, no!
- 3y ago
- tiledjinn 3y agoECS is an architecture proposed by the same group that has said "if you know you're not going to use that memory again, just allocate over it". For certain domains, this is a superior solution to management than more costly cleanup. Re-initializing an allocator and leaving behind old data in now uninitialized memory is a lot faster than doing anything with that memory. For type safety, entities define mapping of types [components are types]. The whole point of ECS is effectively managing types and ensuring correctly typed data is operated on.
- CooCooCaCha 3y agoPersonally i think the flexibility of ECS is worth the tradeoffs, but that’s just me. I’m not sure what you mean by cleanup entities. Whenever i load a level i put it under a root entity and just despawn the root when im done.
- the__alchemist 3y agoA note on the ECS: This is largely due to poor understanding on my part, but I moved my computational chemistry (egui-based) GUI program (Visualizes various wave function properties) from Bevy to WGPU directly, because the ECS was difficult to grok and debug. It felt like more work to reinvent wheels regarding rendering than manipulate the ECS. I had it working in Bevy, but ported. Not a canonical use case for a game engine! It's been ~2 years, but my main reason was wanting to write plain rust, vice using a DSL.
- brink 3y agoI moved my game away from Bevy to WGPU too because I needed tighter, more efficient control of the data than ECS could provide. Though being able to query data with types is amazing and really demonstrates how powerful Rust's type system is, it's not a solution for everything, and feels more geared towards one-off arcade style video game design.