B-threads: programming in a way that allows for easier changes

Colored sections represent changes we have to make to our code when new requirements arise

Append-only development

You might be thinking: how else would we go about changing software?Remember, our goal is to find a way that allows for easier-adjustment.

Event trace

As a mental exercise let’s imagine a system where we have no access to the source-code that composes it. The only way to understand what the system does is through its output: the event trace.

Alignment with requirements

As we continue from our earlier ATM example we can add new requirements in this append-only fashion. B-threads are “piled-a-top” looking much more similar in context to actual requirements. Usually requirements are spread across different code modules and functions, but b-threads are much more aligned to what the actual requirement entails.

Synchronization point

This yellow imaginary line that crosses through all of the b-threads and decides which event is triggered is actually called formally a synchronization point.

Implementing new requirements require modification of several modules in our system


Obviously this article cannot go much into all the details and research that has been made in this context. There other concepts such as priority, event-selection mechanisms, model-checking and much more that can be found in literature. One place to start is googling on scholar: “harel behavioral programming”.

My talk at React Finland 2019 which is a summary of this article
My talk at ReactJS Day Italy 2018


  • “Moving” this imaginary line by requesting, waiting and blocking events allows for incremental development.
  • Alignment with requirements and how humans think about behavior.
  • B-threads are “piled-a-top” with no component-specific interface, connectivity or ordering requirements.


  • Different way of thinking about programming.
  • Ironically, more natural ways of programming are perceived as unnatural because of our past training.
  • Does it scale with thousand or million concurrent b-threads?
  • Not currently used by many people.
  • Lack of best-practices, tools, community etc.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store