TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

FSL: A programming language to make complex finite state machines easy to create

96 pointsby nlteabout 4 years ago

22 comments

rdez6173about 4 years ago
I'm not sure why this is being shared if the site is wholly incomplete. Outside of the TODO links and bogus videos, two of the listed libraries point to invalid or archived repos in GitHub.
评论 #26581059 未加载
评论 #26580719 未加载
jhvkjhkabout 4 years ago
Is my ad provider broken, or there’s something wrong about the video link?<p>“Using the live editor” is a Chicken fighting ninja, “What are state machines?” is a black woman singing(the cover is a laughing Jesus, why?), “Why FSL?” is Video unavailable, “Publishing a machine” is The history of Japan.
评论 #26579740 未加载
评论 #26581073 未加载
评论 #26579707 未加载
zokierabout 4 years ago
How does this compare to Ragel?<p><a href="http:&#x2F;&#x2F;www.colm.net&#x2F;open-source&#x2F;ragel&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.colm.net&#x2F;open-source&#x2F;ragel&#x2F;</a>
评论 #26579750 未加载
评论 #26579515 未加载
评论 #26579555 未加载
评论 #26581088 未加载
ModernMechabout 4 years ago
While most of the site seems broken, at least the online editor is working. There&#x27;s an example of a traffic light that gives some insight as to the design of the language: <a href="https:&#x2F;&#x2F;stonecypher.github.io&#x2F;jssm-viz-demo&#x2F;graph_explorer.html" rel="nofollow">https:&#x2F;&#x2F;stonecypher.github.io&#x2F;jssm-viz-demo&#x2F;graph_explorer.h...</a><p>One thing I&#x27;ve learned personally writing live editors is that while recompile on every key seems neat, in practice it is very jarring to have things jump around every keystroke. The problem with this is that mid-typing you may express an invalid program, so your rendered output jumps wildly from something coherent to something completely wrong, only to resolve itself when you&#x27;re done typing. This is why I think it&#x27;s best practice to explicitly recompile on ctrl+enter, even if you have the ability to do it every keystroke.
评论 #26587589 未加载
dragontamerabout 4 years ago
I&#x27;ve been dreaming of (ab)using C&#x27;s &quot;goto&quot; statement to make easy to read finite state machines.<p>An actual, proper language, for making FSMs probably makes more sense. Lol. But still, the conceptual similarity between a thread-of-execution and FSMs must remain in the back of most programmer&#x27;s minds. All turing machines are FSMs, and your code determines the state. (When executing &quot;foo&quot; function, you&#x27;re in the &quot;foo&quot; state. And the &quot;foo&quot; function easily tells you either to return to the previous state, or which states to move forward in).
nojokesabout 4 years ago
I found this <a href="https:&#x2F;&#x2F;stonecypher.github.io&#x2F;fsl&#x2F;draft%20tutorial.html" rel="nofollow">https:&#x2F;&#x2F;stonecypher.github.io&#x2F;fsl&#x2F;draft%20tutorial.html</a> tutorial
remramabout 4 years ago
Since I&#x27;m here, any tool recommendations for visualizing state machines, and state charts in particular? XState&#x27;s [1] is ok but only works on the web and offers to export, and I found its layout algorithm a bit sub-par. Writing graphviz code by hand, or using google draw&#x2F;draw.io&#x2F;... gets painful very quickly.<p>[1]: <a href="https:&#x2F;&#x2F;xstate.js.org&#x2F;viz&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xstate.js.org&#x2F;viz&#x2F;</a>
评论 #26585631 未加载
评论 #26587149 未加载
Datenstromabout 4 years ago
When I worked on robotics I often found myself reaching for behavior trees for anything complex over a FSM. See section 2 of &quot;Behavior Trees in Robotics and AI&quot;[1] for an example of how much simpler they are. I think they are popular in game dev too but I&#x27;ve never worked in that field.<p>[1]: <a href="https:&#x2F;&#x2F;arxiv.org&#x2F;pdf&#x2F;1709.00084.pdf" rel="nofollow">https:&#x2F;&#x2F;arxiv.org&#x2F;pdf&#x2F;1709.00084.pdf</a>
评论 #26581080 未加载
datavirtueabout 4 years ago
Very cool. I looked through jssm but get the sense that fsl or jssm might be adapted so that it can be used to declaratively generate an FSM for any language?<p>I wish my colleagues knew what an FSM was and how to create one. Getting tired of seeing 400 nested IF statements sprinkled across 10 classes.<p>Something that makes it easy to create an FSM declaratively for any language might help raise awareness and spur adoption.
评论 #26587552 未加载
thinkloopabout 4 years ago
It&#x27;s trick site and it still made the front page?
Folconabout 4 years ago
Their live editor is here[0], for anyone interested in seeing a working example.<p>I&#x27;m not affiliated with the project, just found the link among all the other stuff there.<p>- [0]: <a href="https:&#x2F;&#x2F;stonecypher.github.io&#x2F;jssm-viz-demo&#x2F;graph_explorer.html" rel="nofollow">https:&#x2F;&#x2F;stonecypher.github.io&#x2F;jssm-viz-demo&#x2F;graph_explorer.h...</a>
Chris2048about 4 years ago
Seems like the site wasn&#x27;t ready yet (see author comments), maybe HN should have criteria for whether certain links should be posted? Or perhaps a convention where-by website author can indicate they do not want to be posted on social aggregators.<p>Aside: I actually think HN might be better if no karma was given for link submissions.
bearjawsabout 4 years ago
Anyone with experience using finite state machines in production apps want to share their experience? I love the concept, but not sure how to implement a POC so my teams can see the value. We have a few areas that have a ton of dense business logic, and I think something like xState could be beneficial.
评论 #26581626 未加载
评论 #26581196 未加载
评论 #26585619 未加载
mattsouthabout 4 years ago
This library seems quite a lot quicker at runtime (20x) than <a href="https:&#x2F;&#x2F;thisrobot.life&#x2F;" rel="nofollow">https:&#x2F;&#x2F;thisrobot.life&#x2F;</a>, at least for the red-&gt;green-&gt;yellow-&gt;red example in my very quick superficial test that follows the README.
foucabout 4 years ago
Any Regular Expression can be represented as a Finite State Machine. Knowing this, I usually look at things like this because I&#x27;m hoping that someday someone will come up with a new concise &amp; readable way of writing both regular expressions and finite state machines.
评论 #26580411 未加载
评论 #26580391 未加载
评论 #26581519 未加载
评论 #26580186 未加载
Tabular-Icebergabout 4 years ago
What&#x27;s the significance of the history of Japan to this project?
评论 #26583616 未加载
评论 #26579820 未加载
argvargcabout 4 years ago
Why are the examples and learning resources crossed-out?
评论 #26579629 未加载
derefrabout 4 years ago
I feel like we don’t need a novel language for this. There’s already a pretty-well-known language that’s almost a DSL for “making complex finite-state machines easy to create”: Erlang.<p>I know that sounds wacky, so let me pitch you on that idea :)<p>In ‘primitive’ Erlang (i.e. Erlang without OTP), each FSM state is just a function, that can contain its own event loop (`receive` statement) to accept input, and then can transition to a new state based on that input by tail-calling another function.<p>Such an Erlang module is a direct, 1:1 encoding of the FSM you’d draw on paper — and very readable as such — but is also plain-old executable Erlang code! In fact, this is basically the <i>most</i> idiomatic Erlang code you can write, syntactically. It’s when the language is at its best and most compact&#x2F;expressive. (It’s also when all of Erlang’s weird syntax choices suddenly make perfect sense.)<p>You can easily author+maintain an FSM with a large&#x2F;complex tree of states and sub-states, by just putting each state function with its various sub-state functions into its own module, and then having each module only expose the valid entry states for each sub-state set.<p>Because each independent FSM exists in its own actor (virtual thread of execution), you don’t need any more than this. You don’t need to worry about the data representation of the FSM — the FSM’s data representation is the actor’s process record + stack. And you don’t need to worry about how to “pump” the FSMs; they’re pumped by the runtime scheduler. (However, if you care about pinning down your concurrency model — e.g. if you’re trying to model a DSP — there are Erlang libraries for specific abstractions like CSP channels that you can use to do so.)<p>It’s very easy to write a static analysis pass to verify that a primitive Erlang module like this constitutes an FSM “and no more” — i.e. that it could be transpiled into any other formalism that instantiates an FSM (e.g. a regex; a DSP; etc.) Erlang even breaks down its compiler into helpful separate reusable components (all available to any Erlang program) to help you do this. And these components make it just as easy to do the actual transpilation, turning this Erlang code into whatever other kind of encoded formalism you like.<p>But, unlike most such formalism DSLs, it’s very easy to also <i>break out of</i> the FSM abstraction, and trade it for a more powerful one, if an FSM no longer works for your use-case. You’re working with regular Erlang code. So, if you just do a regular stack-frame-pushing call instead of a tail-call, now your FSM is a pushdown automaton. Or, if you pass a state variable on the stack along with each tail-call, now you’ve got a Turing machine.<p>Honestly, ignoring all the stuff about concurrency, Erlang source code &#x2F; BEAM bytecode is an almost perfect abstract machine for reifying various computational formalisms in an externally-verifiable way. If I was working on a computational proof for some CS conjecture, I’d heavily consider 1. writing the problem statement in (primitive, non-OTP) Erlang, and then 2. writing a small transpiler that would convert Erlang to lemmas in Z3 or Coq. (I’ve already done this once or twice, actually.)<p>And, if I were implementing something like Cloudflare’s Edge Workers “but for FSMs” (e.g. some user-submitted pattern-matching automata for structured data, to filter user subscriptions to that structured data) then it’d be an extremely easy decision to standardize on (a restricted, static-analyzed at submit-time sub-ISA of) BEAM bytecode as the user-submitted program format. I would then just implement my worker server as a regular Erlang server that would load+run those checked BEAM modules.
评论 #26583599 未加载
评论 #26581967 未加载
评论 #26583447 未加载
评论 #26587687 未加载
0xFFCabout 4 years ago
Very interesting project. Sorry for my ignorance though, where in the industry something like this might be useful?
评论 #26585676 未加载
ryanmarshabout 4 years ago
This looks very nice. Currently I’m learning how to use @davidkpiano’s XState.<p>How would you say this compares?
评论 #26585635 未加载
ben7799about 4 years ago
I feel like this could be more useful as a DSL library for various other popular languages.
Chris2048about 4 years ago
A programming language pronounced the same as a relatively prominent VCS? That would certainly confuse things..