by samsquire · 3y ago · 0 comments
Structured concurrency is one approach to solving this problem. In a structured concurrency a promise would not go out of scope unhandled. Not sure how you would add APIs for it though in Javascript.
See Python's trio nurseries idea which uses a python context manager.
https://github.com/python-trio/trio
I'm working on a syntax for state machines and it could be used as a DSL for promises. It looks similar to a bash pipeline but it matches predicates similar to prolog.
In theory you could wire up a tree (graph if you have joins) of structured concurrency with this DSL.
https://github.com/samsquire/ideas4#558-assign-location-mult...
[1] https://docs.python.org/3/library/asyncio-task.html#asyncio....
Funny, I used this very analogy about concurrency the other day. I think we live in a manually managed concurrency era, because we haven’t entirely figured out the right mix of patterns to get to the point when it makes sense. In the future, I expect all non-low-level languages simply agrees on one or two models, just like RAII and GC solved the manual memory management problem. That, and we still have a lot of bugs from concurrency related matters which we basically have no way to test.
Structured concurrency is most certainly part of the solution, but I there are a few devils in the details that are a lot of work (or careful thought) to get right.
I would really enjoy talking to you more about this.
From what you wrote, I agree, we are indeed in an era where concurrency and its notation has yet to settle on an elegant approach.
With microservices and distributed systems simultaneous independent execution and ordering and consistency then the problems of concurrency reveal themselves.
Do you have any ideas how you would want to define concurrency? What notation would you like to be capable of writing? What is your favourite representation of concurrency? (Such as bash pipelines)