Hacker News new | ask | show | jobs
by ArkyBeagle 3571 days ago
The path to concurrency is paved with a mix of finite state machines and event-driven programs. IMO, neither FP nor OO have all that much to say about that.

FSM/event driven is pretty easy even in rickety old languages like 'C'. C++ is a bit nicer because there is dispatch demuxing built in. I suppose the same is true of Java.

I guess webby stuff doesn't lead to the appeal of FSM but for everything else, it's generally a better path. FPGA guys use a lot of FSM and they simply don't have the same defect rates as software guys.

I've used toolsets like ObjecTime/Rose where "everything is a state machine" and It Just Works. I'm not sure why this approach is still obscure - the various works in Verification ( with a capital V ) seem to point to FSM as a means of reducing complexity.

1 comments

I've lived the ObjectTime/Rose path. Made good money converting projects out of those tools. So yes, everyone should use them.

C++14 and coroutines have replaced state machines in my world. They read like normal code, are easy to customize to your needs.

Had to convert a large PLC system from Beckoff structured text to C++. Coroutines allowed me to model it close enough that a little python translator made it work.

Setup actors with queues that timeout on interval and pump the (taskLets) Coroutines.

Create functions that provide blocking on what ever you like. Events, msgs or time.

Better IMO, compared to code shattered into bubbles in a tool or callbacks everywhere.