HackerTrans
TopNewTrendsCommentsPastAskShowJobs

cowboyd

no profile record

Submissions

Effection 3.0 – Structured Concurrency and Effects for JavaScript

frontside.com
6 points·by cowboyd·3 years ago·2 comments

The Await Event Horizon in JavaScript

frontside.com
6 points·by cowboyd·3 years ago·2 comments

comments

cowboyd
·3 months ago·discuss
I think writing an effect library yourself is a tough ask, but some of them have gotten really, really good. And they get you things that are simply not possible with promise. Check out Effection if you want a more vanilla javascript syntax, or Effect if you're really into expressing things functionally.
cowboyd
·3 months ago·discuss
Is it safe to just "stop calling next() on a generator?" like the post suggest?

To me that sounds like dropping the task on the floor. Specifically, this will not invoke any finally {} blocks:

More correctly, you should invoke `return()` on the generator. Otherwise, you won't provide execution guarantees. This is how Effection does it. There is no equivalent in async functions, so it sounds like the same problem would apply to the GC technique.
cowboyd
·2 years ago·discuss
JavaScript generators are unmined gold! We've done a lot of usage of JavaScript generators as delimited continuations; using them to implement the classic shift/reset operations in JavaScript. https://github.com/thefrontside/continuation

Built on those delimited continuations is structured concurrency for JavaScript (https://frontside.com/effection)
cowboyd
·2 years ago·discuss
> yes but what do I say to my colleagues when they realize they need to learn generators (it's a non-trivial hurdle for many people)

Just tell them that they already know them.

`yield*` is

- a superset of `await` so if you understand `await`, you understand `yield*`

- infinitely more powerful because it can handle any effect, not just Promise resolution.

- It's just javascript syntax that predates `await`
cowboyd
·3 years ago·discuss
JavaScript’s async/await constructs have a critical lack of power which makes them unsuitable to implement structured concurrency.