TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

ES6 Generators Deliver Go Style Concurrency (2013)

19 点作者 stevekinney将近 8 年前

6 条评论

markwaldron将近 8 年前
I read until Node.js 0.11 was mentioned and then scrolled up and realized it was written in 2013. Please add to title!
评论 #14889105 未加载
slaymaker1907将近 8 年前
I think that even with generators, you don't quite get Go style concurrency due to lack of concurrency for non-IO bound tasks. For a real world use case, suppose you are compiling TypeScript. Without web workers or running in a separate process, the compilation will block because it is CPU bound. You can get around this with generators by explicitly putting in pause points through yielding, but that is assuming that one can break up the task and that it doesn't depend on some external blocking library.
评论 #14888831 未加载
emilsedgh将近 8 年前
Can someone compare the concurrency method using async&#x2F;await vs. generators? What are the pro&#x2F;cons of each?<p>It seems that with Async&#x2F;Await, Generators are not as useful and are more niche. Am I wrong?
评论 #14889077 未加载
codedokode将近 8 年前
I think it is a bad idea to use generators to emulate threads. Because the code becomes difficult to understand and it is easy to make a mistake (for example forget to put a `yield` operator somewhere). I saw examples of such code.<p>If you want threads, then make a syntax or API for them rather than implement hacks nobody will want to deal with later.
评论 #14889176 未加载
jiyinyiyong将近 8 年前
<a href="https:&#x2F;&#x2F;github.com&#x2F;ubolonton&#x2F;js-csp&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ubolonton&#x2F;js-csp&#x2F;</a> ?
piotrkaminski将近 8 年前
Title needs a (2013) annotation.