Smart Trains 1

ST 5 Statechart as a Universal Language for Asynchronous Software

Asynchronous software design has always been tricky since it goes against our natural sequential thought process using basic constructs like if-then-else, do-while, wait-for-signal, etc. Different languages have their own attempts to tame this tricky problem.

It was the goal of UML to come up with a unified methodology to model asynchronous systems. Though nowadays UML isn’t a hot topic anymore (if we know what it stands for), it is still very much alive. With support across popular languages including C++ and Javascript, statecharts and hierarchical state machines finally make the ideal of UML accessible to general software developers.

As an example, the complete behaviors of this model train are universally modeled by statecharts using QP (Miro Samek) on the C++ embedded platform and xstate (David Khourshid) on the Node.js server and web application. It’s magical to be able to use the same idioms (nested states, guarded transitions, entry/exit actions, sending/raising/deferring/recalling events, timers, etc.) across apparently very different domains (embedded vs frontend)!

OLYMPUS DIGITAL CAMERA