Leipzig Gophers

🔗Hybrid Meetup #43 wrap-up

Finite state machines

Hybrid Meetup #43 took place 2024-05-28 at Gridfuse, Hauptpost Leipzig. We had a great presentation about a lightweight (~200 LOC), open source state machine library written in Go: ekstatic — presentation slides (PDF)

The use case in the context of RAIDA is the modelling of workflows, composed of a number of steps (and the loose coupling of business logic with state transistions). The library is flexible, but the limits of the Go type system require to resort to any (which will defer some type checks to runtime).

For convenience, the predeclared type any is an alias for the empty interface. [Go 1.18]

The library is open source at Metamogul/ekstatic, and contains some examples as well. Thanks again, Jan for the insights, and Gridfuse for hosting another Leipzig Gophers event.



A finite state machine consists of states and state transitions; implementationwise, a state may be any type, but at the same time we would benefit from marking a type as a state, hence unifying different actions. A variant type could be a solution, but Go does not support variant types (albeit interfaces and type switches allow for some unification).

In essence, we would like chainable computation, or workflow composition, which is reminding of monads.

Sidenote: For Leibniz, monads were the essential substance (1714), which has no parts and is therefore indivisible. They also were windowless, or immutable.

The Monads have no windows, through which anything could come in or go out.

A few years earlier, in 1703, Leibniz recognized something else essential: the binary number system.

But reckoning by twos, that is, by 0 and 1, as compensation for its length, is the most fundamental way of reckoning for science, and offers up new discoveries, which are then found to be useful, even for the practice of numbers and especially for geometry. The reason for this is that, as numbers are reduced to the simplest principles, like 0 and 1, a wonderful order is apparent throughout.