What is Becsy?

Becsy is an Entity Component System (ECS) framework for TypeScript and JavaScript that makes it nearly effortless to write performant, multi-threaded code. It's inspired by ECSY and bitecs, and guided by ideas from Flecs.

WARNING

Becsy is currently in 0.x status. What's there is reasonably well tested but many features are still missing and you can expect frequent API changes. Most importantly, multi-threading is not yet implemented.

Priorities

Becsy positions itself within the wider ecosystem of ECS frameworks with the following set of priorities:

  1. Multi-threaded: all apps developed with Becsy can be effectively run on multiple threads with minimal or no modifications from their single-threaded version. I believe that multi-threading is the only way to scale performance and that ECS is the ideal architecture for making multi-threading effortless and practical in JavaScript.
  2. Ergonomic: the API is powerful, expressive, and safe, rather than minimal or low-level. I believe that developers choose TypeScript / JavaScript because it's a high level language, where they can express ideas quickly and succinctly. If they need to prioritize performance they'll pick a language and ECS implementation better suited to that objective.
  3. Performant: the point above notwithstanding, Becsy does its best not to unnecessarily leave potential performance on the table. I believe that a good ECS should be usable for more than just toy apps.

The priorities above are ordered from most to least important. This means that I'll sacrifice ergonomics if required to support multi-threading, and accept decreased performance in favor of a better API.

Features

From ECSY we take:
✅ a friendly object-oriented API for both JS and TS clients
✅ multiple queries per system
✅ reactive queries (rather than event callbacks)
✅ explicit mutation tracking
✅ references to native JS objects in components
✅ comprehensive docs

From bitecs we take:
✅ extensive use of ArrayBuffer for performance
✅ a sparse array architecture
✅ Node and browser compatibility with no dependencies

Then we add:
✅ a native TypeScript implementation
✅ selectable component storage strategies
✅ bidirectional entity references with strong referential integrity
✅ declarative system ordering based on data dependencies
✅ coroutines for more natural multi-stage workflows
✅ built-in support for representing state machines (per Sander Mertens)
✅ weak references to native JS objects, for better integration with other frameworks

Still to come:
⬜ multithreaded system execution
⬜ an optional but nicely integrated networked data replication system

Support

I'm actively supporting this package but it's not my primary job, so responses may take 24-48 hours and fixes up to 1-2 weeks (but usually much faster). Please open issues against the repo, and join us on Discord for help and fun discussions!

Showcase

Here are some public creations that use Becsy:

Acknowledgements

Many thanks to Becsy's early users, who helped shape the feature set and API, and found tons of bugs! Thanks to ECSY for the inspiration and their fine documentation, which served as the starting point for this site. And thanks to Kate Liu for the logo design!