3 ms·
I would hazard a guess that there are decent state machine libraries for most languages that you can use I think this is already part of the problem of complex
by userbinator 9y ago
I would hazard a guess that there are decent state machine libraries for most languages that you can use
I think this is already part of the problem of complexity --- when I think "state machine", what comes to mind is a loop and a switch with some gotos in the cases. Definitely not a library. If you think "I need to use a state machine" and your next thought is "I need to find a library for that", then IMHO you're definitely doing it wrong.
- JoachimS 9y agoAgreed. When I worked on last years Advent of Code problems (amazingly good problems btw) I ended up writing many solutions as small FSMs. Typically you read a token, moved to a new position and then acted based on the current state and the token, position. You don't need a library since the code is just a few switch statements. https://adventofcode.com/2017 https://adventofcode.com/2017
- AstralStorm 9y agoAnd then everything ends up in Error state with no history. At least function stack has stack traces...
- zaarn 9y agoFSM's usually don't have error states, you tend to crash them first. Though that is preventable, mostly because the code you run is inbetween transitions and that will return very nice stack traces. Otherwise, you don't need a trace of a state machine, the state you're in and the current transition should tell you exactly where it's breaking. If it doesn't, chances are you're breaking state machine definitions by storing wildly complex state outside the machine.