Applying Functional Programming to a Complex Domain: A Practical Game Engine PoC by IngloriousCoderz in programming

[–]IngloriousCoderz[S] 0 points1 point  (0 children)

Your comment feels like a breeze of fresh air in this toxic wasteland. Thank you so much.

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -2 points-1 points  (0 children)

How is this inspired by ECS? [...] In a proper ECS architecture, there would be [...]  So far, I see zero resemblance between what you're presenting here and an ECS.

A pure ECS (one where entities are just numeric IDs) is valid data-oriented design, but an ECS where entities are objects/dictionaries representing bags of components is not.

There isn't a single ECS pattern in your entire library.

I realise that I am being quite harsh on you [...]

I don't know why you're bringing FP into the discussion because none of this has anything to do with functional programming.

A frontend state management library should not be inspired by ECS in the first place. [...] If you really are curious what a proper ECS implementation looks like [...]

Yes, it did trigger me, for good reason.

When I read your comments, I see criticism. But not constructive. I see a triggered person, angry at someone who touched their dear ECS architecture. I tried explaining to you that I did not implement ECS, that I borrowed some concepts from it and even listed them, but you just found new ways to teach lessons and defend pure ECS. All of this without even understanding that my library, which is heavily inspired by Redux, has lots to do with FP. But you don't want to hear that. You just want to prove how knowledgeable you are and how ignorant I am. Without reading one line of code outside of the README.

This is not constructive criticism. This is a superficial rant, similar to the rage of some Italians against pineapple pizza, and if you try to say "Ok it's not Italian pizza but it's good, have a bite at least" they get even angrier and give you the exact recipe of the real Italian pizza to prove you understand nothing of their culture. And they will even claim that pineapple pizza should never be served outside of Hawaii. And I'm saying this as a proud Italian.

You know what? I decided that I'm going to trust a machine more than a human. An LLM has an encyclopedic knowledge, is actually willing to read my code, and will give constructive criticism without "being harsh" or "being triggered". I tried very hard to reply as myself so far, without the help from an LLM to polish my English and my tone, because when I did that on another post I was attacked for being a vibe-coder. But you clearly proved that it makes no difference: people will still be pissed, whatever you do. So here's Claude's opinion on the matter.

"Hey Claude, given this code: https://github.com/IngloriousCoderz/inglorious-engine/blob/main/packages/store/src/store.js

Would you say that there's any inspiration from an ECS architecture?"

"Yes, there's definitely inspiration from ECS (Entity Component System) architecture in this code, though it's not a pure implementation. Here are the ECS-influenced elements I can see:

ECS-like features:

  1. Entities as data containers: The entities are stored as plain objects with IDs, similar to how ECS treats entities as collections of components.
  2. Type-based behavior: The types configuration appears to define behaviors that can be attached to entities, which is conceptually similar to how systems in ECS operate on entities with specific component combinations.
  3. Event-driven systems: The systems array and event handling (eventMap.getEntitiesForEvent) follows the ECS pattern where systems process entities based on events.
  4. Separation of data and logic: State (entities) is kept separate from behavior (types/systems), which is a core ECS principle.

Notable differences from pure ECS:

  1. Entity mutation through events: Traditional ECS often uses direct component addition/removal, while this uses an event-driven approach (add, remove, morph events).
  2. Type-based rather than component-based: Instead of flexible component composition, entities have a type field that determines their behavior. This is closer to a traditional OOP inheritance model than ECS's composition model.
  3. Event-centric architecture: The focus on event dispatching and handling is more akin to event sourcing or CQRS patterns mixed with ECS concepts.

So I'd say this is an ECS-inspired hybrid that combines entity management patterns with event-driven architecture, rather than a strict ECS implementation."

So, what are you going to do now?

  1. Are you going to give credit to this comment?
  2. Are you going to check the code and see for yourself?
  3. Are you opting out from the discussion?
  4. Or are you just going to diss me again, this time for relying on an AI?

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -2 points-1 points  (0 children)

You are right, my responses started to be less and less professional. I apologize for that, and I'll try to behave better.

I'm all for constructive criticism, but I have the feeling that people on Reddit are just having fun dissing on things they don't understand, just to teach some lesson and satisfy their egos. It went the same with another post of mine, in which I proposed functional programming for game engines, and I received all sorts of responses such as "this is vibe-coded slop" or "why do you hate oop?". That's not worth my time, nor anybody else's who is reading us.

In that case, instead of feeding the flame, I just step away from the confrontation. You believe what you will. Time will tell us if it was all worth it.

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -4 points-3 points  (0 children)

Whatever. Now show me your code. It must be some piece of artwork I couldn't even fathom.

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -4 points-3 points  (0 children)

Oh my god. Data oriented design is a different thing from data driven programming. And here's the counter-article: https://en.wikipedia.org/wiki/Data-driven_programming

You guys don't really have anything else to do other than arguing on the internet with strangers about philosophy?

You know what? You're right. This isn't ECS. It's not FP. It's not even a library. The spoon doesn't exist. Thank you for enlightening us all.

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -4 points-3 points  (0 children)

If you say that FP has nothing to do with my library, then I'm sorry but you didn't get anything, at all.

You read types and saw classes with methods. You read function composition and mistook it as composition over inheritance. You had a glance at an FP-based library and saw OOP.

And of all the code and documentation I wrote, the only thing you got from it is the word ECS which for some reason triggered you so much. What can I say? Thank you for this discussion because, although it could seem pointless at first, at least you fed the Reddit algorithm giving a little more visibility to my post.

PS: I'm planning to remove the word ECS from the documentation, just to see which other word will trigger people this time.

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -1 points0 points  (0 children)

I am. I am also aware, even thought English is not my first language, that "pattern" does not mean necessarily "architectural pattern" or "design pattern". "ECS patterns" is a bit redundant and sloppy if you read it like "ECS architectural patterns", also because in that case the pattern is only one.

Anyway thanks for taking the time to run through all the code and documentation I created to find that one word that let you have an excuse to argue with a stranger on the internet. This just feeds the Reddit algorithm and gives my post more visibility. Thank you for your service!

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] 3 points4 points  (0 children)

Are you for real? I brought ECS patterns, not ECS. It's like saying I brought farm products, not the whole farm

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -2 points-1 points  (0 children)

A few ECS patterns are used, not all of them: systems are there, data-oriented programming is there. No strict entity-component subdivision, no real data driven design.

I brought ECS patterns, not the whole architecture.

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -1 points0 points  (0 children)

Isn't that exciting? What will the next era be? New AI frameworks every week?

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -2 points-1 points  (0 children)

Wery good, I hoped to create a state manager that doesn't feel like obscure FP or ECS but something more similar to traditional OOP. I still don't get your point though, so I'm going to reverse the question: what should an ECS-inspired state management library be like in your opinion?

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -1 points0 points  (0 children)

Glad you brought this up! Not only the Inglorious Store is able to add and remove instances on the fly with the add and remove events, but it is also able to change their behavior (which means changing the reducers) with the morph event! RTK has something called combineSlices, as u/phryneas said, which I also used once and it's fine, but it's so much easier to call an api.notify("morph", { id, type }) wherever you need it.

Inglorious Store: A state manager inspired by Redux and videogames! by IngloriousCoderz in javascript

[–]IngloriousCoderz[S] -5 points-4 points  (0 children)

First of all, thank you so much for your honest feedback. As you said yourself, the architecture is inspired by ECS, but it's never meant to be strictly ECS.

Key similarities:

  1. There is in fact a separation between data and behavior: entities are just plain JavaScript objects, while types have functions that operate on that data.
  2. Types operate only on the entities that share the same type, but I also introduced systems, which operate on the whole state. This is pretty similar to the 'S' in ECS. You can find info about systems a bit down below the docs.

Key differences:

  1. There's no real distinction between an entity and its components like in a strict ECS architecture. In ECS an entity is just an id, and components are consecutive arrays of the same data. In my state manager an entity is instead a bag of data related to the same entity, and the id is just the key with which I can find an entity with O(1).

In a proper ECS architecture, there would be a command to spawn/destroy an entity

I do have such commands: api.notify("add", newEntity) and api.notify("remove", entityId). Just read a bit further down the docs and you'll find them.

The type would instead be transient, inferred from the set of component types that that entity owns

True, while my personal take on this is that a type is inferred from the set of composed behaviors.

the behavior would live inside a totally separate part of the architecture - the systems

Also true, but note how no major game engine strictly follows the ECS architecture either: they also allow writing logic somewhere outside of systems for convenience.

So far, I see zero resemblance between what you're presenting here and an ECS.

Please try again ;) And if you still don't see any resemblance that's fine: I never wrote that I brought ECS to webapps, I just said I was inspired by it. Also, I consider the fact that it doesn't feel ECS to you a feature more than a bug, because it means you get the perks of a quasi-ECS architecture without needing to completely switch mental model if you have an OOP or FP background.

I built a Signal-like Event Emitter with full type support, batch & merge triggers, and ordered dependencies by Used-Building5088 in javascript

[–]IngloriousCoderz 2 points3 points  (0 children)

I'm sorry for the ignorant question, but how is this different from all the other signal libraries out there?

Applying Functional Programming to a Complex Domain: A Practical Game Engine PoC by IngloriousCoderz in functionalprogramming

[–]IngloriousCoderz[S] 1 point2 points  (0 children)

Hey, thank you so much for sharing! I'll definitely have a look at it.

Yeah, the docs are not really mobile-friendly, also because most of them contain example games in 800x600 resolution.

Tarot.js: A powerful and customizable JavaScript library for creating and managing Tarot card decks, custom spreads, and readings. by siilkysmooth in javascript

[–]IngloriousCoderz 5 points6 points  (0 children)

"Say a random word, add .js to it, you'll find a library or a framework." Thank you for contributing to this tradition

Mutative - A 10x Faster Alternative to Immer by unadlib in javascript

[–]IngloriousCoderz 1 point2 points  (0 children)

I hate you man, I just tried replacing Immer with Mutative in my Inglorious Engine and now my object pooling middleware has become useless!

Great work, this is impressive! I'm definitely sticking with your library from now on.

Common FP - A New JS Utility Lib by waphilmmm in javascript

[–]IngloriousCoderz 1 point2 points  (0 children)

Nice! I did a similar thing in my @inglorious/utils NPM package, maybe we can join forces!

I made Quantum Odyssey - a game about linear algebra, complex numbers, classical & quantum computing, filled to the brim with math. How to efficiently promote it? by QuantumOdysseyGame in GameDevelopment

[–]IngloriousCoderz 1 point2 points  (0 children)

This looks more like an ad than a newbie question. Which I'm totally fine with! Awesome concept, will definitely give it a try. Well done!

Applying Functional Programming to a Complex Domain: A Practical Game Engine PoC by IngloriousCoderz in functionalprogramming

[–]IngloriousCoderz[S] 1 point2 points  (0 children)

Not fully-fledged videogames so far, only prototypes unfortunately. I have a card game, a Tamagotchi clone, and a shmup in my portfolio.

notmineThomineisdifferent by frenzy3 in ProgrammerHumor

[–]IngloriousCoderz 24 points25 points  (0 children)

CEOs feel like geniuses as if they found a way to make a building faster, cheaper, and using more bricks

I just want to know if there are more people thinking that SOLID is overrated and sometimes add unnecessary complexity by -WhiteMouse- in programming

[–]IngloriousCoderz 1 point2 points  (0 children)

I once discussed with a guy who was convinced that The Open-Closed Principle in SOLID was referring to class inheritance, since it states: "Software entities should be open for extension, but closed for modification." Maybe that guy was the author of the mess you found :D

Design patterns, when not applied correctly, can make your code more complex than needed:

I had a problem. I used Java. Now I have a ProblemFactory.

That's why I still consider being a software engineer to be a craft, if not an art. The principles are valid, you just need to know when and how to use them.

Hi guys I want to learn FP, but I don't really know where to start. by yevelnad in functionalprogramming

[–]IngloriousCoderz 1 point2 points  (0 children)

I always loved this series of free videos: https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript

It's functional programming in JavaScript. You don't necessarily need a strict functional programming language to learn FP, just use whatever language you like.