Live data from Hacker News

Why Developers Never Use State Machines (2011)

skorks.com

21–30 of 164 posts

Re: Why Developers Never Use State Machines (2011)

#21
post #9
post #5

If you've ever do any game programming you'll be drowning in state machines.

network protocol as well, hell, any non-toy network application ends up containing a state machine either implicitly or explicitly

VHDL/Verilog as well, but that's completely obvious.

I've been using state machines for Javascript UI elements.. really simplifies things.

Re: Why Developers Never Use State Machines (2011)

#22
post #12

Traditional programming languages and imperative thinking don't lend themselves to writing state machines, so its not really that surprising that they're under utilized. Its kind of frustrating constantly reading posts where people shit on functional programm(ers|ing) for being too ivory tower-y or whatever, when its kind of hard not to be when a lot of the older FP guys have spent the last like 20-30 years going "yo…

What? No, that isn’t true at all. State machines come before the FP/IP divide even existed. State machines are also intrinsically stateful, that should be obvious.

> State machines are also intrinsically stateful, that should be obvious.

So are lots of data types, but those are still useful in FP.

Re: Why Developers Never Use State Machines (2011)

#23
Of course developers whose last experience with state machines was in a college course won’t use them. Just read some of the comments below the article on storks.com. Labview developers use state machines extensively, because the implementation is graphical, beautiful, and prevents loose ends.

Re: Why Developers Never Use State Machines (2011)

#24

Earlier quoted context omitted.

What? No, that isn’t true at all. State machines come before the FP/IP divide even existed. State machines are also intrinsically stateful, that should be obvious.

> State machines are also intrinsically stateful, that should be obvious. So are lots of data types, but those are still useful in FP.

Yes, that should be obvious also. State machines have no strong relationship with FP. I'm not sure where this claim even comes from!

Re: Why Developers Never Use State Machines (2011)

#25
post #12

Traditional programming languages and imperative thinking don't lend themselves to writing state machines, so its not really that surprising that they're under utilized. Its kind of frustrating constantly reading posts where people shit on functional programm(ers|ing) for being too ivory tower-y or whatever, when its kind of hard not to be when a lot of the older FP guys have spent the last like 20-30 years going "yo…

What? No, that isn’t true at all. State machines come before the FP/IP divide even existed. State machines are also intrinsically stateful, that should be obvious.

The argument is not that state machines are the child of FP, just that a common idiom in FP, Pattern Matching over ADTs, makes them easy to implement.

Re: Why Developers Never Use State Machines (2011)

#26
post #23

Of course developers whose last experience with state machines was in a college course won’t use them. Just read some of the comments below the article on storks.com. Labview developers use state machines extensively, because the implementation is graphical, beautiful, and prevents loose ends.

Looks like you got bit by autocorrect: s/storks/skorks/

Re: Why Developers Never Use State Machines (2011)

#27
One of my go-to interview questions is "Can you tell me about a time when you've used an explicitly-modeled state machine in your programming?" Our work, heavy in embedded devices, network protocols, and parsing, is so full of state machines that I wouldn't want to hire someone who wasn't comfortable using them.

Re: Why Developers Never Use State Machines (2011)

#28
I really don't like state machines because if you need to add a new event, each of the states need to be updated to handle that event. If you add a new state, you have to figure out how to handle each of the transitions from other states. So as your states grow, the maintenance on the developer's side grows faster than linear.

Additionally, I find that I cannot understand how the program works without actually drawing out the state machine diagram if I come across it the first time, so there is a bit of a learning curve. It's also a nightmare to test because of all of the states that need to be tested.

So in summary, not a fan. Like recursion... if it feels natural then use it, but I don't go and try and turn stuff that isn't a SM into one or turn something that can be done as loops into recursive function for fun.

Re: Why Developers Never Use State Machines (2011)

#29
post #27

One of my go-to interview questions is "Can you tell me about a time when you've used an explicitly-modeled state machine in your programming?" Our work, heavy in embedded devices, network protocols, and parsing, is so full of state machines that I wouldn't want to hire someone who wasn't comfortable using them.

Compilers and games are two areas I've used them a few times in.

Re: Why Developers Never Use State Machines (2011)

#30
post #25

Earlier quoted context omitted.

What? No, that isn’t true at all. State machines come before the FP/IP divide even existed. State machines are also intrinsically stateful, that should be obvious.

The argument is not that state machines are the child of FP, just that a common idiom in FP, Pattern Matching over ADTs, makes them easy to implement.

This might be, but state machines are so common in imperative code, you could say they are common idiom there also. Pattern matching over ADTs only drives transitions; different representation of transitions can lead to different constructs being more convenient (e.g. if your transitions are just based on a finite set of values, you can use just dictionaries).
Post reply on HN