I designed a syntax for this: that everything is a state machine progression, a bit like sequence types in the article.<p><pre><code> state1a state1b state1c | state2a state2b state2c | state3a state3b state3c
</code></pre>
This means wait for state1a, state1b state1c in any order, then move to the next sequence of things to wait for.<p>In a multithreaded server or multimachine distributed system, there are global states you want to wait for and then trigger behaviour. The communication can be inferred and optimised and scheduled.<p>It's BNF syntax - inspired by parsing technology for parsing sequences of tokens but tokens represent events.<p>If you use printf debugging a lot, you know the progression of what you see is what happened and that helps you understand what went wrong. So why not write or generate the log of sequence of actions you want directly not worry about details?<p>But wait! There's more. You can define movements between things.<p>So take an async/await thread pool, this syntax defines an async/await thread pool:<p><pre><code> next_free_thread(thread:2);
task(task:A) thread(thread:1) assignment(task:A, thread:1) = running_on(task:A, thread:1) | paused(task:A, thread:1);
running_on(task:A, thread:1)
thread(thread:1)
assignment(task:A, thread:1)
thread_free(thread:next_free_thread) = fork(task:A, task:B)
| send_task_to_thread(task:B, thread:next_free_thread)
| running_on(task:B, thread:2)
paused(task:A, thread:1)
running_on(task:A, thread:1)
assignment(task:B, thread:2)
| { yield(task:B, returnvalue) | paused(task:B, thread:2) }
{ await(task:A, task:B, returnvalue) | paused(task:A, thread:1) }
| send_returnvalue(task:B, task:A, returnvalue);
</code></pre>
Why not just write what you want to happen and then the computer works out how to schedule it and parallelize it?<p>I think iteration/looping and state persistence and closures are all related.<p>I have a parser for this syntax and a multithreaded barrier runtime which I'm working on, I use liburing. I want to get to 500 million requests per second of the and ~50ish nanosecond latency of LMAX Disruptor.<p>The notation could be used for business programming and low level server programming I think.