3 ms·
It's similar to manual memory management: you have to remember to do the other side of the thing you're doing. Structured concurrency is one approach to solvin
by samsquire 4y ago
It's similar to manual memory management: you have to remember to do the other side of the thing you're doing.
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 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-multinames-multiexpressions https://github.com/samsquire/ideas4#558-assign-location-mult...
- tech2 4y agoPython 3.11 introduced asyncio.TaskGroup[0] to cover the same use-case as trio nurseries (scoped await on context manager exit). It's imperfect, sure, but it improves matters. [1] https://docs.python.org/3/library/asyncio-task.html#asyncio.TaskGroup https://docs.python.org/3/library/asyncio-task.html#asyncio....
- klabb3 4y ago> It's similar to manual memory management 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.
- samsquire 4y agoThanks for your comment. 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)