A Statechart library (Meditative)

I do feel this is a bit premature to post (I intended on cleaning up the internals and documenting it before posting).
But it is functional (I may have a few quick fixes which I still need to commit from another computer) and is working for the applications I created it for.

Only posting this here now because I’ve had it private, but recently made it public because I reached out to someone in the Elixir slack regarding a job they posted (haven’t heard anything back yet).

Below is unrelated to the library, but just a general overview of my experience. It seems that most job postings for elixir aren’t looking for someone who has little experience in Elixir (and I know I still have areas to improve on, and am taking the steps to work on those in regard to general software design and architecture/clean code).

Feel free to skip reading everything below and just do whatever you want with the statechart code if it interests you, but opinions are also welcome.

To give you an idea of my background and the timeline of my programming experience:

  • 2016 I was Honorably Discharged from the Navy and starting learning javascript from online resources combined with some intro to CS classes.
  • Started learning Elixir around the end of 2018 after having built a few practice full stack projects using javascript (with React) and python.
  • Attended a coding bootcamp in NYC Jan 2019 - Dec 2019 for javascript (was learning AWS, Docker, and more Elixir and OTP concepts on the side). For the final project I was able to create the backend in Elixir, designed and implemented the frontend in React, and used Phoenix for the REST API with Postgres as the database (it’s no longer live now as I had it hosted on AWS and the free tier expired, but there’s a gif on my website: jameswgood.com and the github repo for it is here: GitHub - Dactyl-Digital/notetacular_server and the client: GitHub - Dactyl-Digital/notetacular_client). I created that project in ~2 months. Implemented a minimal authentication system from scratch in order to learn the kind of techniques that auth libraries might use (referenced one of Jon Calhoun’s Go books which had a pretty thorough coverage of the implications of implementing an auth system and handling cookies securely from scratch).
  • Attended another program Jan 2020 - June 2020 which was for data science and was also a year long program, so I can also use Python’s tools for Data Science (I haven’t extensively created additional projects since then, but I can do basic statistical work in Jupyter notebook with Pandas and some visualization using plotly).
  • Jan 2021 - June 2021 designed and implemented the UI for a startup idea using React. It was a paid contract position.
  • June 2021 - Current I wanted to open source this once I had the code base and documentation in a better condition, I implemented this in about 3 weeks or so, but it’s a statechart library (largely following the spec of the JavaScript implementation of XState). I’ve been using the statechart successfully in software that I’ve wanted to create since I’ve started learning to code (and that’s part of the reason why I haven’t polished up this project more) GitHub - JamesGood626/meditative.
  • I’ve also experimented with GraphQL and OTP on some side projects and have the following books to use as a reference if I need to work with it

https://www.amazon.com/Elixir-Action-Sa%C5%A1a-Juri-cacute/dp/1617295027/ref=sr_1_1?[…]5930841%2C1943526176%2C1454935480%2C1421599872&srpt=ABIS_BOOK

4 Likes

Meditative is such a good name for a State library.

1 Like

It might be worthwhile stating what the library does at the top of the readme, and moving the licence to the bottom.

4 Likes

I always wanted to do UML statecharts in Elixir. Hope Ill find time to contribute.

There is a very good C implementation, the QP from Miro Samek.

Its on on Github and a good reference I think.
Especially you could have a look at the qhsmtest here: qpc/examples/workstation/qhsmtst at master · QuantumLeaps/qpc · GitHub

stepping through a dispatch in the test-statechart should be very intereseting when building sth like this.

the dispatch function is here: qpc/qep_hsm.c at master · QuantumLeaps/qpc · GitHub

I think I may have a good tag line for the library too. “A library to help you from losing your sh** when dealing with state” haha

1 Like

Thank you for your feedback.

I know the README needs a major overhaul. And at least a few examples of what the API looks like for defining a Statechart. I can use some of the test cases possibly, but some of those were just arbitrary rather than modeling an actual use case.

https://xstate.js.org/viz/
Do you mean in a visualizer along the lines of something like this?

Or do you mean Model Based Testing?