Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I probably wouldn't use coroutines as state machines, because most state machine DSLs are very easy to read. I'm curious though, if I could ditch state machines altogether if the coroutine equivalent was more readable. Most state machine libs also allow things like on-enter/on-exit state callbacks, which would look awkward using only coroutines.


What are you using state machines for now? just wondering. I have been looking into JS state machines (mostly xstate) in order to model UIs better.


I recently programmed an application for a test bench of electric motors, where I could basically translate the flow chart I was given by the engineers to a state machine. Out of the state machine I handled all concerns like UI, hardware controlling and persistence via events.


I agree. I also would prefer not to use state machines if I wanted coroutines (i.e. algorithmic code with traditional control structures interspersed with coroutine yields). Ideally you need both.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: