A few months ago I started trying to combine the flexibility and conciseness of both ECS (Entity-Component-System) paradigm and prototype-oriented programming (of which Lua is famous). After several iterations, the framework, which is named Fila, began to take shape and even gradually surpass my initial expectations. So after spending quite a few time writing the demo, I think it's time to share it to all of you.
To be short, Fila is not a framework built based on some foundation of software development such as OOP. It's designed to be the foundation, just like OOP, ECS and prototype-oriented programming. As a result, you don't need to know any of them to be able to understand Fila. What needed is a completely (or partially, maybe) renewed perspective of how the data and logic could be organized. This is where Fila looks really different from other programming paradigms:
If you are familiar with OOP - In Fila there is no class, every object (named fila) can be a class, or properly speaking, a template for its child instances. (Lua developers should be quite familiar about it - this is what metatable does!)
if you are familiar with ECS - in Fila there is no system, every fila can be a system, or properly speaking, can match and inject desired logic (rules) to its child instances.
When I was writing the demo of Fila, I was amazed by how elegant and intuitional it was to model the real world we are living (thus the game world). The only problem is that for PICO-8, taking up 2471 tokens for a mere framework is simply too much...So if performance is not your major concern (maybe also secondary XD), feel free to delete all the lines of code started from '-- Event Bus' and only use normal groups to inject your logic, which will save you total amount of 1049 tokens (you will understand what I am saying once you read the demo code in the 0 tab of the cart. And trust me! It's really fun to read).
All feedbacks and contributions are welcomed. Furthermore, since English is not my mother tongue, if you find any grammatical mistakes or typos in the repo, feel free to make a pull request.
A knot is an abstraction over component. In ECS paradigm, aside from extending the data an entity carries, components can be used as 'keywords' to select entities we care about (for example, to select all the entities that have 'velocity' and 'mass' components).
Fila Framework extends this matching and selecting mechanism with the power of prototype-oriented programming. A fila can be derived from another fila and inherits all its knots (components). Parent fila can select its children (see fast group and reactive group section in the demo).
Therefore, unlike ECS in which we have seperated concepts for data (Entity) and logic (System), Fila unifies both of them.
Besides setting and accessing knots, there are many other important functions for fila. For example, functions for creating and fetching groups, functions for adding and removing listeners, functions for resetting, lifting and detaching, and so on. So it would be risky to allow people define knots on the fila table directly, since they may accidentally overwrite these functions.
[Please log in to post a comment]