To me, C++ and simplicity are antagonists.
For many firmware developers, that's true, but I would say it's mostly because we're not accustomed to the C++ style. This is an industry-wide phenomenon. I agree that, at some points understanding a complex C++ code can be very hard. It is very rare to have difficulties understanding C code. I can not judge as my main background is C. on the other hand, We cannot overlook the success of many C++ firmware projects like Mbed-OS, which is implemented entirely in C++. The debate about C vs. C++ will never end, I know. I still consider myself a C firmware developer rather than C++. But after attending several talks from Cpp Now event, I'm considering the C++.
Found that that SML library, saw tons of "template class ...", closed it. Unlikely to open it again.
Indeed, it can be daunting, I cannot argue with that. However, I don't believe there is another way to create a similar library without using such intertwined template classes. I mean, if the library developers know what they're doing, performance is validated, and, most importantly, debugging is supported, then having complexity in its implementation isn't necessarily a bad thing. After all, we already place trust in many libraries and dependencies.
IMO, a C code which declares states explicitly and uses a simple switch/case or if/else, makes FSM easy to write and maintain.
If the code becomes big - well, factor out big parts, and keep the FSM core small.
Example: a single-pass JSON parser that uses no heap, implemented as an FSM with clearly defined states:
https://github.com/cesanta/mongoose/blob/9f498d2eea27737bea2f8bce47107d328e881ad0/src/json.c#L129
The whole function is less than 100 LoC, so it was not even broken down into a smaller functions - no need to.
Every state has a clear transition points. For example, a ":" character transits the state to expect a JSON value:
https://github.com/cesanta/mongoose/blob/9f498d2eea27737bea2f8bce47107d328e881ad0/src/json.c#L240-L242
Nice example. Of course, SML is not a one-size-fits-all solution.
That's it. The only thing that I'd like to have here, is to visualise the FSM - and probably it can be done with a tool that parses the FSM code and spits out a graph.
The cool thing about the SML library is that you have a clear transition table in one place, which you can later dump using code to convert it into a graph (mentioned the dumping code in the article).
The SML approach described in the "SML Library: Simplified Overview" chapter of your article does not resonate as "simple" to me at all.
Thanks for the feedback.