Live data from Hacker News

Flecs – A fast entity component system for C and C++

flecs.dev

51–60 of 90 posts

Re: Flecs – A fast entity component system for C and C++

#51

To any budding game developers, my advice would be to not rush into ECS and try to accomplish your goals with structs and loops first and understand the fundamentals of how a video game 'works' under the hood. Your game will get done if you work on it, not necessarily if you pick ECS!

You can do both. Here is tutorial for Rogue-like game with ECS in Rust: https://bfnightly.bracketproductions.com/rustbook/chapter_2....

Here's a rogue-like game written in straight C, with hard-coded arrays, structs, and defines.

https://github.com/tmewett/BrogueCE

component systems are useful when you have no design doc, or a design doc written by new-hire monkeys. Or when management has no idea what the goals are.

Re: Flecs – A fast entity component system for C and C++

#52

To any budding game developers, my advice would be to not rush into ECS and try to accomplish your goals with structs and loops first and understand the fundamentals of how a video game 'works' under the hood. Your game will get done if you work on it, not necessarily if you pick ECS!

I've spent a few months working with ECS/DOTS with the Unity Game Engine, their implementation of this style of architecture end up being very complex in comparison to the old fashion GameObject workflow that made Unity popular in the first place. Everything is MUCH more difficult to implement, I won't go into details but from my experience the time spent to achieve a similar result is about 5x-10x what it should be.…

> GameObject workflow that made Unity popular in the first place.

It's a bit much of a over-simplication that just the GameObject architecture Unity uses is what made it popular. For example, if there wasn't a UI editor for Unity and only code, you still think it would be as popular? I'm 99% sure it wouldn't be.

I tried getting into DOTS as well, as ECS is an interesting architecture overall, but Unity kind of dropped the ball on it and made it way more complicated than it has to be, from every side of having to use it.

On the other hand, you have Bevy, which is built with ECS as a core part of the engine, and it makes using ECS a breeze. After getting to know Bevy and ECS outside of DOTS better, I'm not sure I could back to how I wrote my games before. ECS just makes it a lot easier to structure bigger projects than the basic introduction game like flappy bird. The modularity is on a different level and it gives you a much better view of the overall architecture than anything else I've tried before.

Simply put, I'm not sure I'd write the same amount of games if it wasn't ECS, because it makes it fun to make games again, for me.

Re: Flecs – A fast entity component system for C and C++

#53

To any budding game developers, my advice would be to not rush into ECS and try to accomplish your goals with structs and loops first and understand the fundamentals of how a video game 'works' under the hood. Your game will get done if you work on it, not necessarily if you pick ECS!

In imperative langs, maybe.

But I _would_ recommend ECS to Haskell devs interested in making games because apecs is just that good.

Re: Flecs – A fast entity component system for C and C++

#54

To any budding game developers, my advice would be to not rush into ECS and try to accomplish your goals with structs and loops first and understand the fundamentals of how a video game 'works' under the hood. Your game will get done if you work on it, not necessarily if you pick ECS!

I've spent a few months working with ECS/DOTS with the Unity Game Engine, their implementation of this style of architecture end up being very complex in comparison to the old fashion GameObject workflow that made Unity popular in the first place. Everything is MUCH more difficult to implement, I won't go into details but from my experience the time spent to achieve a similar result is about 5x-10x what it should be.…

As a game dev that’s been using Unity ECS in production for over 2 years, it’s a very underwhelming implementation. Sure it’s fast if you design a game with Unitys intentions, but Unity has never made a game and what they made isn’t what game devs need.

Re: Flecs – A fast entity component system for C and C++

#55

To any budding game developers, my advice would be to not rush into ECS and try to accomplish your goals with structs and loops first and understand the fundamentals of how a video game 'works' under the hood. Your game will get done if you work on it, not necessarily if you pick ECS!

I've spent a few months working with ECS/DOTS with the Unity Game Engine, their implementation of this style of architecture end up being very complex in comparison to the old fashion GameObject workflow that made Unity popular in the first place. Everything is MUCH more difficult to implement, I won't go into details but from my experience the time spent to achieve a similar result is about 5x-10x what it should be.…

Whether ECS is complex or not depends a lot on which one you use. I've heard the same thing from a lot of gamedevs that use DOTS, but people in general seem to be pretty happy using Entitas (also a C# ECS that can be used with Unity), Bevy (which is based entirely on ECS) or for that matter Flecs.

Re: Flecs – A fast entity component system for C and C++

#56
post #34

Earlier quoted context omitted.

Yeah fully agree, ECS is the microservices of gamedev these days. I've worked on AAA games that used it, and shipped games as a solo dev without it. If you don't know why you need it, then chances are you don't need it. Just keep it in mind as one possible architecture pattern for when your code base starts to experience growing pains is my advice.

I don’t have any intention of writing a game, but my lay understanding of ECS is that it sort of treats your world as an in-memory columnar database for better cache locality: if you’re updating the positions of a collection of entities, you only need to loop over a collection of contiguous `position` structs—you can get a lot more of these in a cache line than you would if the entire entity was a struct containing a…

Pretty close, but there's a bit more to it. This post goes over one way an ECS can store data: https://ajmmertens.medium.com/building-an-ecs-2-archetypes-a...

Re: Flecs – A fast entity component system for C and C++

#57
post #43

I have a sort of off-topic question. The marketing for this claims not using STL containers as a selling point. Does anyone know what makes STL containers unsuitable for this use case? Clearly they're not a one size fits all but I'm intrigued to know why you market an unknown container based API over a tried and tested one?

The biggest reason for me was to reduce compile times, which got cut into approximately half when I replaced STL containers with simpler custom ones. This starts adding up in large projects, where lots of files end up including the ECS.

Re: Flecs – A fast entity component system for C and C++

#58
post #2

Any idea what a game loop would look like for an ECS engine that only renders a new frame when some animation is running or when the user is manipulating the camera, but not otherwise? Let's not argue "why". Most obvious would be saving battery.

Definitely possible. I know of a project that used an event-based architecture to decide when to run ECS systems.

Re: Flecs – A fast entity component system for C and C++

#59

Could this be used to implement an efficient backend server for an Unreal Engine game?

It could be yep. One of the things that makes it a good fit for this use case is that Flecs has a query language that supports things like graph traversal and joins. Combined with either the builtin REST API or some custom protocol you could use it as a realtime in-memory database (which is what I use it for).

Re: Flecs – A fast entity component system for C and C++

#60
post #34

To any budding game developers, my advice would be to not rush into ECS and try to accomplish your goals with structs and loops first and understand the fundamentals of how a video game 'works' under the hood. Your game will get done if you work on it, not necessarily if you pick ECS!

Yeah fully agree, ECS is the microservices of gamedev these days. I've worked on AAA games that used it, and shipped games as a solo dev without it. If you don't know why you need it, then chances are you don't need it. Just keep it in mind as one possible architecture pattern for when your code base starts to experience growing pains is my advice.

I'm definitely not going to argue that you need ECS to do much of anything, but ECS has come long way in the past 4 years from a tool that lets you have lots of entities in a game, to a more generic system for entity management.

Things like entity relationships (https://ajmmertens.medium.com/building-games-in-ecs-with-ent...) introduced features that were already common in existing entity management systems, such as entity hierarchies.

An ECS can also come with a bunch of tools for inspecting entities, monitoring performance or changing components in realtime (https://www.flecs.dev/explorer/). Definitely not something you need to complete a game, but very handy.

Post reply on HN