A DSL for XState[0] by the co-creator of astro.build[1], cool! But the repo[2] has been archived and there is an active FSM library from the same developer called robot[3].
I'm on my phone right now, so can't try Robot but I'm wondering what the type safety story looks like. For instance, in the example in "Getting started" the variable `users` is defined irrespective of the state, even though it is only available in the `loaded` state.
whilenot-dev 17 days ago [-]
And the following part
Instead of conforming to an XML specification created decades ago, Robot takes the best ideas from both academia and real-world usage of finite state machines. This makes state machines easy to read and understand, as there is only one way to do most common tasks.
...is hinting at some disagreements with XState's approach. Would be nice to have a visualization tool, like the kind XState has, for any FSM library (like robot) though.
steve_adams_86 16 days ago [-]
The visualization tool goes a long way in helping non-developers understand what logic is actually doing, from a relatively wide perspective. It’s valuable for sure
codethief 16 days ago [-]
Where do you see the disagreement with XState's approach?
whilenot-dev 16 days ago [-]
XState famously always conformed to the SCXML spec[0]. It isn't mentioned anymore in the current version anywhere(?), but you can still see it in the v4 docs[1].
robot seems interesting, but I wonder why they didn't stick with the elegance of the Lucy language.
MatthewPhillips 17 days ago [-]
Writing a language, even a DSL is a lot of work. It's not enough to just make a good language, there's also a whole world of tooling support that people expect nowadays.
Also ultimately it was hard to sell the idea of living in a different file format from the rest of your code. This is always a tough sell for DSLs. Even languages as good as CSS and SQL struggle with this for a lot of devs.
whilenot-dev 17 days ago [-]
A JavaScript-only implementation of robot suffers a similar fate as a DSL without proper tooling, as states and actions are just some custom strings that need to be repeated, no? An implmenetation with good types would provide useful autocompletion, and I can see there was a similar conclusion and types have been implemented with generics. Haven't used it yet to confirm the behavior (at a first glance it seems like a few more strings would need to be inferred), but it would be helpful to mention this somewhere for us TypeScript folks.
aziis98 17 days ago [-]
What I don't like about these state machine DSLs is that they are not really composable at the "machine level". It is a known fact that FSM are equivalent to regular expressions [1]
Alternatively, a regular language can be defined as a language recognised by a finite automaton. The equivalence of regular expressions and finite automata is known as Kleene's theorem
I think a cool state machine language would use this fact as a starting point for it's syntax. Another very useful feature would be "functions" to isolate specific repetitive parts of FSM
xstate and other libraries like it implement Harel's statecharts, which are an extension of FMSs with different semantics and composability (a.k.a. "hierarchy", where machines can embed other machines), so the relationship with regular expressions may not be that useful.
"Classic state diagrams require the creation of distinct nodes for every valid combination of parameters. For all but the simplest of systems, this can lead to a very large number of nodes and transitions between nodes (state and transition explosion), which reduces the readability of the state diagram." [1]
"What's missing in the traditional state machines is the mechanism for factoring out the common behavior in order to share it across many states. UML state machines address exactly this shortcoming of the conventional FSMs. They provide a number of features for eliminating the repetitions so that the complexity of a UML state machine no longer explodes..." [2]
FOMA is a finite state transducer library that creates composable FSTs. FSTs are generlaizations from one-sided FSAs in that while they accept input they also write and output (they are further elegant because they are not only composable but also reversable: switching input and output tames with "up" and "down" is trivial, so the same formalism can be used to analyze and generate).
FOMA [1] is an open source clone of the Xerox XFST tools [2,3] developed at Xerox Research Laboratory Europe in Grenoble under the late Prof. Lauri Karttunen.
While the FOMA/XFST family of tools are most suitable for linguistic applications and for teaching formal language theory, I have been impressed
by the fact that they are the only formalism that permits elegant naming and re-use of sub-automata.
At a glance, this seems to implement both FSM and Statecharts, and Statecharts are composable AFAIK.
almostgotcaught 17 days ago [-]
How would you use this fact to make fsms composable when regexes aren't composable...?
aziis98 17 days ago [-]
Most common regex implementations are not composable at the language level but there are more modern alternatives like Pomsky [1] that introduce bindings and actually make regexes composable expressions.
By the way regular expressions are "composable" by definition as they are defined recursively as (in their simplest form)
- ε is the regex that matches the empty string
- given regexes A and B we can construct the new regex AB that matches first the regex A followed by B
- given regexes A and B we can construct A|B that matches A or B
- given a regex A the regex A* matches any number of repeated occurrences of A
Then for some reason languages like javascript don't provide a way of constructing
> - given regexes A and B we can construct the new regex AB that matches first the regex A followed by B
> - given regexes A and B we can construct A|B that matches A or B
Concatenation and alternation is not what one typically imagines when they utter the word composition (unless you expect me to understand "composition over inheritance" to mean actually "just use two classes instead of one").
mportela 16 days ago [-]
Hmm, concatenation and alternation are exactly what I thought of when reading the work "composition" (I probably had functional programming in mind).
I'm curious. What came to your mind for "composition"?
almostgotcaught 16 days ago [-]
I already said it: what does the phrase "composition over inheritance" mean?
> probably had functional programming in mind
Then you should have no trouble recognizing that there is no analog to `f . g . h` for regexes.
16 days ago [-]
v9v 16 days ago [-]
I quite like the concise state machine definitions used in Rodney Brooks' "A Robust Layered Control System for a Mobile Robot"[0]. The first element is the state name, and whatever is returned is the next state.
One thing that saddens me is how Ragel petered out, I guess they got bit too ambitious with the Colm rewrite. But it was a state machine language that saw a blip of usage at one point
jesuslop 16 days ago [-]
There is also vintageish SCXML underwritten by the w3c, with the panoply of xml friends (an xsd schema hence validator, xpath queries and xslt transforms). Also being part of the uml chart family it should be xmi-borne, if you wondered.
mbitard 17 days ago [-]
This is an abandonned project :(
masklinn 17 days ago [-]
Oh yeah, it's more than just dead, the repo is actually archived.
TypingOutBugs 17 days ago [-]
> This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
Hasn't been updated in 4 years, and is now archived, so I assume this project is dead. Looks good though!
[0]: https://xstate.js.org/
[1]: https://astro.build/
[2]: https://github.com/lucydsl/liblucy
[3]: https://github.com/matthewp/robot
[0]: https://thisrobot.life
[0]: https://www.w3.org/TR/scxml/
[1]: https://stately.ai/docs/xstate-v4/xstate/advanced/scxml
Also ultimately it was hard to sell the idea of living in a different file format from the rest of your code. This is always a tough sell for DSLs. Even languages as good as CSS and SQL struggle with this for a lot of devs.
[1]: https://en.wikipedia.org/wiki/Regular_language
"Classic state diagrams require the creation of distinct nodes for every valid combination of parameters. For all but the simplest of systems, this can lead to a very large number of nodes and transitions between nodes (state and transition explosion), which reduces the readability of the state diagram." [1]
"What's missing in the traditional state machines is the mechanism for factoring out the common behavior in order to share it across many states. UML state machines address exactly this shortcoming of the conventional FSMs. They provide a number of features for eliminating the repetitions so that the complexity of a UML state machine no longer explodes..." [2]
--
1: https://en.wikipedia.org/wiki/State_diagram#Harel_statechart
2: https://en.wikipedia.org/wiki/UML_state_machine#UML_extensio...
FOMA [1] is an open source clone of the Xerox XFST tools [2,3] developed at Xerox Research Laboratory Europe in Grenoble under the late Prof. Lauri Karttunen.
While the FOMA/XFST family of tools are most suitable for linguistic applications and for teaching formal language theory, I have been impressed by the fact that they are the only formalism that permits elegant naming and re-use of sub-automata.
[1] https://fomafst.github.io/
[2] https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&d...
[3] https://dsacl3-2018.github.io/xfst-demo/
By the way regular expressions are "composable" by definition as they are defined recursively as (in their simplest form)
- ε is the regex that matches the empty string
- given regexes A and B we can construct the new regex AB that matches first the regex A followed by B
- given regexes A and B we can construct A|B that matches A or B
- given a regex A the regex A* matches any number of repeated occurrences of A
Then for some reason languages like javascript don't provide a way of constructing
but that is another problem.[1]: https://pomsky-lang.org/
Concatenation and alternation is not what one typically imagines when they utter the word composition (unless you expect me to understand "composition over inheritance" to mean actually "just use two classes instead of one").
I'm curious. What came to your mind for "composition"?
> probably had functional programming in mind
Then you should have no trouble recognizing that there is no analog to `f . g . h` for regexes.
Hasn't been updated in 4 years, and is now archived, so I assume this project is dead. Looks good though!