step
step over
step out
run
pause
restart
Breakpoints
Log

Dec 2020  

Prototype of a textual dataflow programming language

Many programmers want to design a programming language at some point. This is one of such attempts. Is my first try, and it might be uninformed and naive, but have to start somewhere :)

My inspiration comes from systems like Observable and Nodes, that demonstrate interesting programming paradigms without designing a language from scratch, but rather building on top of Javascript.

I was also inspired by visual dataflow environments like Pure Data, NoFlo, and Nodes. The thing that I don't like much about those, is using graphical elements to design programs. It works well in some cases, but I still like text editing more.

I wanted to explore an alternative, text based interface for dataflow programs. Such languages exist, for example:

I wanted to make something similar, but interactive (more like Observable), and with more lightweight and minimal syntax.

Language design

The main requirement for the design is simple and minimal syntax. Another requirement is easy JS interop, so that for any features that are not supported by the language, it's possible to just use inline JS code, or call JS functions.

Syntax is simple, and has only a few building blocks:

Simple example, "hello world"

Following interactive example shows usage of literals, variables and the log function. Here, a literal is assigned to a variable, and then log function is used for output.

step
step over
step out
run
pause
restart
Breakpoints
Log

Another simple example

Next example shows assigning a number to a variable, and repeating expressions.

step
step over
step out
run
pause
restart
Breakpoints
Log

Mult-agent simulation (flocking) example

For even more complex example, I selected multi-agent flocking simulation. Explanations of the "boids" flocking algorithm can be found on pages by Craig Reynolds and Conrad Parker. It is often used as a demo for interactive graphical applications and agent-based frameworks, for example:

Compared to other implementations, code is seems to be more compact (~50 LOC vs >100 LOC). Another feature is that the main "gist" of the algorithm is outlined within first few dozen lines, and the rest of the code is within a set of utility functions.

I think that this style promotes describing structure of the algorithm in short concise way. Also, it encourages using short functional bits of code. But for now it's just a hypothesis, and to confirm it have to write more code based on the finished language implementation.

step
step over
step out
run
pause
restart
Breakpoints
Log

Refenences & links

FBP

Domain-specific language for Flow-Based Programming

NoFlo: two years of flow-based programming

https://jpaulm.github.io/fbp/index.html

https://noflojs.org/

https://cables.gl/

https://nodes.io/

Flocking

http://www.kfish.org/boids/pseudocode.html

https://cs.stanford.edu/people/eroberts/courses/soco/projects/2008-09/modeling-natural-systems/boids.html