alt.hn

5/21/2025 at 3:46:45 PM

Show HN: Evolved.lua – An Evolved Entity Component System for Lua

https://github.com/BlackMATov/evolved.lua

by blackmat

5/21/2025 at 4:52:42 PM

> Components are stored in contiguous arrays in a SoA (Structure of Arrays) manner, which allows for fast iteration and processing

Does this actually matter in Lua? Aren’t all array elements going to be pointers to heap allocated objects anyways?

The point of SoA is your likely to be accessed values are adjacent in memory, but if you’re chasing a pointer to get that value then you’re not getting anything out of it.

by cmovq

5/21/2025 at 9:40:10 PM

Yes, organizing components as SoA can provide a significant performance boost in Lua, especially with LuaJIT. Both iteration and element access become faster, and it also reduces memory allocations and GC pressure when creating entities. And yes, Lua tables can be contiguous in memory if you use them carefully.

by blackmat

5/22/2025 at 5:42:52 AM

Do you have any published benchmarks?

by dicytea

5/22/2025 at 8:21:00 AM

Comparative benchmarks are a big task on their own, and usually the author's library wins in them. I have internal benchmarks in the repository, but they are not designed for comparison or for evaluation by outsiders. Maybe I'll get to that someday.

As for the SoA approach, here you can find a small and exaggerated example: https://luajit.org/ext_ffi.html

by blackmat

5/21/2025 at 5:08:50 PM

Lua uses tagged unions so that primitives are stored inline within a table. Some time ago I benchmarked this and the perf gains from SOA were significant. Besides, even if you had to chase pointers, SOA still means you can reduce the number of allocations.

by PhilipRoman

5/21/2025 at 4:46:54 PM

Cool to see a new ECS project! I've been learning and using JECS (https://github.com/Ukendio/jecs) for a project of mine, and some of the core ideas (like Chunks) felt familiar. This project definitely seems to have a more in-depth documentation though and a lot more features especially by having its own scheduler stuff. Would love to try it out on a new project someday

by euvin

5/21/2025 at 9:49:57 PM

Hmm! I haven't heard of JECS before. I need to check it out :-) Thanks for the kind words!

by blackmat

5/22/2025 at 4:57:55 AM

Will give this a try. I was using claude code to make a small game in love2d, and really hoped for a nice lua ecs lib to help manage the game objects (its my first time playing around with game dev).

by sali0

5/22/2025 at 12:20:29 PM

It always makes me happy to see people publishing Lua libraries in $YEAR. I am also working on Lua stuff. Thank you for posting!

by binary132

5/23/2025 at 7:44:55 AM

Yeah! Long live Lua! :-)

by blackmat

5/21/2025 at 7:21:32 PM

One alternatives I like is https://bakpakin.github.io/tiny-ecs/doc/

by je42

5/21/2025 at 9:53:44 PM

Yeah, tiny-ecs is good, but it doesn't quite fit my needs. With these thoughts in mind, I started this project.

by blackmat

5/21/2025 at 5:45:35 PM

What makes it an "envolved" ecs?

by dogprez

5/21/2025 at 10:06:51 PM

Honestly, it's just a fancy way of saying I learned a few things from earlier attempts and made some tweaks. I just think "evolved" sounds cool!

by blackmat

5/21/2025 at 6:32:41 PM

Any examples of projects using this?

by poly2it

5/21/2025 at 9:58:03 PM

Not yet, but I wrote this library to use in a project of mine. When I finish it, I will add a link to the README. As for a small demo project, I have one in mind, but I haven't started it yet.

by blackmat

5/21/2025 at 6:41:48 PM

[flagged]

by elpocko

5/21/2025 at 8:22:30 PM

[dead]

by sieabahlpark

5/21/2025 at 5:11:52 PM

[flagged]

by luabloughs