This is an automated archive made by the Lemmit Bot.

The original was posted on /r/programminglanguages by /u/DamZ1000 on 2024-10-20 04:37:47+00:00.


So I’m taking a break from my other languages to let some ideas digest, and thought in the mean time I might distract myself with this other idea I’ve been having.

Originally it was just a state machine language, you write up a series of states and an inital state, the each state can call to another state which would then yield and hand execution over to that other state.

Each state consists of a name, an environment for local variables, and a code block to execute on repeat.

So after building that, I realise as a sort of bug, that I don’t have to have the first state yield, instead it can ‘fork’ and have both states running at the ‘same time’, I thought this was rather neat and am now leaning more in that direction to see what else it could do.

So, what do you folks think of this? Do you have any simple-but-still-complex problems I could try implementing in this multi-state state machine? (I guess it’s still technically just a regular old state machine just with 2N possible states.)

Something about it does feel similar to the actor model. Should I maybe start pushing it in that direction too?

This is currently a solution in search of a problem, but I think it could have value. It operates similar to an operating system, in that the operating system doesn’t call a shell as a function, and a shell doesn’t call your program as a function, instead it opens up a new slot and allows that program to play out until it finalises or is killed. I think you could do something similar with this, but all within the one language/program.

Although, that OS analogy doesn’t entirely work, as it’s works mostly in a tree-based structure, whereas this MSSM can be cyclical or anything really.

The one problem I found for where this might be a solution is with robot control, I’m currently building a robot game, we’re robots can walk, around pick up materials, drop them, and fight other robots. So the use of this language to program them, should be kinda useful, in that you could write collections of states that each perform some task, then just fork into them from the existing code and end up with the robot doing multiple things at the same time without too much difficulty from the programmer. This could introduce some interesting bugs, like one state says walk to A, another says walk to B, and the robot just ends up spinning around in circles, but I think that could be fun for a game where you’re trying to program them correctly.