State Machines in Programming

Discussions center on the benefits, underuse, implementation, and libraries for state machines in software development, including comparisons to switch statements and requests for tutorials.

📉 Falling 0.2x Programming Languages
2,235
Comments
20
Years Active
5
Top Authors
#459
Topic ID

Activity Over Time

2007
3
2008
1
2009
23
2010
21
2011
110
2012
86
2013
35
2014
54
2015
32
2016
107
2017
117
2018
253
2019
129
2020
195
2021
247
2022
181
2023
344
2024
176
2025
117
2026
4

Keywords

SM IMHO CLI FSM UI UA01HN GOTO ed.ac statecharts.pdf solipsys.co state machines state state machine machines machine transitions states transition finite design

Sample Comments

baq Mar 27, 2023 View on HN

“I don’t need a state machine library” - everyone when starting a new project

gumby Aug 27, 2022 View on HN

State machines are tragically underused IMHO. They are powerful and easy to reason about. I often see a rat's nest of fragile code that could much more easily have been built as a state machine.

worik Oct 25, 2024 View on HN

State machines are the easy part.

westoque Jan 23, 2023 View on HN

Same here. I am a big proponent of state machines. I have found that state machines bring sanity to an otherwise complex situation. For example, most inexperienced developers will check presence of certain fields to imply where someone is in the process whereas it would be better written using a state machine.

anon-3988 Oct 11, 2023 View on HN

There's obviously no better way to write state machines...

ender7 Sep 1, 2011 View on HN

Can anyone recommend a good introduction to using state machines in code? Especially something in javascript/python? I know what an SM is and how it works, I just want to know how to use an SM library to actually do all these cool things.

yewenjie May 22, 2021 View on HN

Is there quick primer on what and why of state machines?

paulgb May 13, 2019 View on HN

State machines. They can be a helpful abstraction for UI or business logic, and they also make regular expressions make a lot more sense.

imode Apr 4, 2017 View on HN

if you squint, it all looks like state machines!

perfunctory Sep 1, 2011 View on HN

I never understood why one needs a framework or a library for state machines. Can't you just write a switch statement.