Hacker News new | ask | show | jobs
by martinjlogan 5653 days ago
Hello all, the simplest answer for why we did not include the gen_fsm is that it is not used very often. In 11 years of Erlang programming I have only used it a handful of times. You can easily replicate it's behaviour with the gen_server in any case. Furthermore explaining it's use clearly turned out to be complicated. Rather than confuse readers, and add pages to an already lengthy book, we decided to skip it. If you clearly understand gen_server, superviser, application, and gen_event you will be able to pick up gen_fsm when you need to. If we do a second edition perhaps we can include the FSM as an appendix.

The gen_fsm implementation is elegant and I do recommend taking a look at it but you probably won't find yourself using it all too often. At the end of the day we wanted to write a book that prepared people for real world Erlang situations and the gen_fsm does not weigh heavily in those scenarios.

1 comments

Excellent book! I'm enjoying my copy and find it a great complement to the other two.

riak_kv uses gen_fsm, so people looking for a real world use case could check out their usage: https://github.com/basho/riak_kv/blob/master/src/riak_kv_get... https://github.com/basho/riak_kv/blob/master/src/riak_kv_put...

I'm a relatively new to Erlang, but being familiar with gen_server made it pretty easy to understand the gen_fsm docs and figure out what was going on. I don't see the exclusion as a big deal.