PropagationLang is a programming language written to explore a few curiosities gained by taking the programming language course at NTNU. I have always wanted to write my own language, and with the extra knowledge i now have, it was a lot easier to do.




Current status: Not running


Api list


Future libraries TBD

How does it work?

The language is inspired by Observable, a relatively seldom used library in JavaScript which was used by Fuse(Now Fuse Open), an old project of my employer. Observable is cool, as it defines a variable using the function that needs to be ran in order to calculate its value, and the value is automatically calculated every time the dependent variable changes. This makes it easy to chain calculations, and removed a lot of the need for events for responding to variable changes. Think of it as a re-usable promise. However, observable isn't flawless. For example, making observables work when the function has multiple dependent variables is difficult, as observable is pretty much made for a single variable change. This language is an "what if?", where i try to fix the issue by introducing atomic operators. Atomic operators are prebuilt functions in the language that takes care of evaluating variables. They can take as many inputs as they want. They are called atomic operators, as they are the most granular operations you can do.

Just like with observables, this language works by defining relationships between variables. In PropagationLang's case, the atomic operators are used to define the relations. In theory, if the atomic operators were made to be strictly reversable, this language could be relational. However, as the atomic operators are one-way, this is not the case.

The interpreter consists of a variable store, and a dirty queue. The variable store contains objects that map a variable name to its current value, as well as the Atomic operator that is used to evaluate potential new values. Some of the variables in the variable store are inputs or outputs. When execution starts, all inputs are checked for "new content", and are marked as dirty if they have new content of interest to evaluate. Once all inputs are iterated over, the interpreter works through the dirty queue, popping from the queue and re-evaluating variable values until the queue is empty.

A variable is dirty if one of its dependent variables have a new value, different than last time it was evaluated. When a variable is marked as dirty, it is pushed onto the dirty queue, unless it already is in said queue.

Modules are discrete, computable, black-boxed segments. Inputs and outputs are used to expose the interesting parts of them to the outside world. The language does not currently support using modules inside other modules, as it is exam period at the time of writing, and i'd like to study for my exams. The plan is to add this feature long-term

So, what kind of stuff is this good for?

I can imagine simulation of logic being the most straight forward example of its useability. My goal is to write a simple processor for this language. Other possible use-cases is other situations where your program is acting like a factory floor, with few inputs and a lot of processing steps.

Feature list

Future goals/TODO