This man has never heard of video game A.I. programming :)
I had the same reaction. Almost nothing but FSMs in game AI. Makes me wonder if we need to look beyond FSMs for the next level of intelligence.
Why Developers Never Use State Machines
41–50 of 96 posts
Re: Why Developers Never Use State Machines
#42Re: Why Developers Never Use State Machines
#43Having used state machines a lot for embedded development, I find that they have one huge drawback: the resulting C code is unreadable, which turns maintenance into a nightmare. SM have a key quality: they are a compact and unambiguous way for specifying a behavior. If your system's behavior is set in stone, it's worth specifying it as a SM and implementing it as one. This SM is also great to include in a spec, stand…
So they suck in a bad implementation choice because it looks pretty to them. Not so different than the way most Java development works, honestly.
Re: Why Developers Never Use State Machines
#44Re: Why Developers Never Use State Machines
#45Having used state machines a lot for embedded development, I find that they have one huge drawback: the resulting C code is unreadable, which turns maintenance into a nightmare. SM have a key quality: they are a compact and unambiguous way for specifying a behavior. If your system's behavior is set in stone, it's worth specifying it as a SM and implementing it as one. This SM is also great to include in a spec, stand…
Amen. I think the only reason state machines are popular in microcontroller work (not really "embedded" -- big SoC software looks like desktop software) is that they're a common hardware implementation choice. And most of those uC programmers are EE cast offs who look to hardware for their reference of taste and not "software engineering". So they suck in a bad implementation choice because it looks pretty to them. N…
But, yes, you are probably right. When I was taught embedded systems we did do software work, usually on small memory footprints, and state machines were what was taught.
Re: Why Developers Never Use State Machines
#46I'd highly recommend using state machines for multi-step forms. It feels very natural and keeps you sane, I believe it should be a best practice.
Re: Why Developers Never Use State Machines
#47Pretty much every embedded system used for a consumer electronics device is driven by a state-machine. They are really fairly fundamental to embedded development. I suspect this guy is talking about (and dealing with) mostly web developers and people who don't sit so close to the metal. In my current position it's entirely expected and reasonable to write some code and then half way through go back and rip parts of i…
Re: Why Developers Never Use State Machines
#48Having used state machines a lot for embedded development, I find that they have one huge drawback: the resulting C code is unreadable, which turns maintenance into a nightmare. SM have a key quality: they are a compact and unambiguous way for specifying a behavior. If your system's behavior is set in stone, it's worth specifying it as a SM and implementing it as one. This SM is also great to include in a spec, stand…
Re: Why Developers Never Use State Machines
#49I never understood why one needs a framework or a library for state machines. Can't you just write a switch statement.
I love writing switch statements (even with gotos) for small things like lexical analyzers, but when it comes to maintainability and extensibility, a well-designed framework is the way to go.
The Boost C++ libraries supply two of them. I've used one of them and am eying the other. They claim its template magic can make the result actually faster than a typical switch-driven design.
Re: Why Developers Never Use State Machines
#50This is a stupid statement. Pretty much every code depends on a state (i.e. the content of the heap memory) and is thus a state machine (by its most generic definition). I think he is referring mostly to a finite state machine, though. But even then, you have that quite often somehow in your code (think of global boolean variables).
That said, some programs have state that is more finite than others. :-) Deep down, a "state machine-based design" is a mindset of the designer.