dvlsg / async-csp

CSP style channels using ES7 async/await
MIT License
317 stars 18 forks source link

Comparison to js-csp #24

Closed MrLoh closed 6 years ago

MrLoh commented 6 years ago

Very interesting library. Thank you for sharing. I’d be interested to know wether you have some perspective on how this implementation compares to the more popular generator based js-csp library.

They have an issue about using async instead of generators but it doesn’t contain much information on the trade offs. https://github.com/ubolonton/js-csp/issues/73

dvlsg commented 6 years ago

I would agree with their sentiment -- adding promises to the interface does add overhead, and it's probably not inconsequential. There are potentially a lot of unresolved promises floating around at any given time when using async-csp, and the concern about performing within try/catch blocks for the promises is also valid. I can't say for sure exactly how much overhead the promises add, because I haven't profiled them in similar scenarios, but I can't imagine async-csp would be the faster of the two.

However, personally, it's overhead that I find quite useful. Most of the javascript / typescript / etc code I write today makes heavy use of async / await (or at least chained promises), so I find myself wanting to continue interfacing with promises anyways.

MrLoh commented 6 years ago

Thanks for the response. I totally agree with you that Promises make for a much more concise API that allows easy interoparability with other parts of the code. I'll have an eye on performance though.