I can always find many good questions and good answers when I wander around so. Their “good” lies not only in the value of knowledge, but also in how to express it: how to “ask questions” or “answer”. I posted an article in SF not long agoComparison between webcomponents and reactThis is a typical example. Today, I found that I did not dare to enjoy this article alone. I just translated it and continued to dedicate it to you（ The only answer is long and I’m waiting for a better one. I’ll add it when I have time.)
Koa / Co / Bluebird or Q / Generators / Promises / Thunks interplay? (Node.js)
What is the relationship between koa / Co / Bluebird or Q / generators / promises / thunks?
I’m investigating building a web app in part with Koa, but I don’t quite have a handle on the hows, whens, and whys of choosing between – and applying – the range of supportive “making async easier” technologies/approaches (listed below).
I’m doing research on koa related parts when creating web applications, but it’s difficult for me to choose how, when, and why to use a series of technologies / methods (listed below) to “make asynchronous programming easier”.
Overall the disparate guidance on the web about this subject still leaves things blurry, especially in respect to evolving best practices, or at least better ones, and under what scenarios. There seems to be little or nothing on the web that puts it all in context.
Although there are a variety of guidance on this topic on the Internet, it is not clear about the best practices or better practices in various scenarios. It seems that there is almost no “Encyclopedia” on the Internet.
I’m hoping the responses to this big arse sprawling post can correct that. Also maybe the questions below can inspire someone to write a thorough blog post or the like to address this matter. My sense is I’m not even close to the only one who would benefit from that.
I hope that the reply to my “foot binding” question can change this situation. At the same time, I hope the following questions can inspire someone to write a blog or something and summarize it. I feel that I’m not the only one to benefit from this.
So I’d be pleased if the bright community could help answer and provide clarity to the following questions in respect to the technologies listed below (in bold type):
Therefore, I am very glad that someone can provide a clear answer to the following questions (in bold type) from the following perspectives:
a) How, and under what circumstance (as applicable) are they complements, supplements, substitutes, and/or overlapping solutions to one another?
a) Under what (applicable) circumstances, how can they complement, replace and / or repeat each other?
b) What are their trade-offs in respect to speed-performance, error handling ease, and debugging ease?
b) What are the advantages and disadvantages of speed / performance, ease of error handling and ease of debugging?
c) When, where, and why may it be better to use “this” versus “that” technology, technologies-combo, and/or approach?
c) When and where would it be better to replace “that” technology / technology mix / method with “this” and why?
d) Which technologies or approaches, if any, may be “dimming stars”.
d) Which technology or method, if any, may have been “yesterday’s yellow flower”.
Koa is a minimal foundation for build Node apps geared for taking advantage of ECMAScript-6 features, one feature in particular being generators.
Koa is a minimal infrastructure for developing node applications that benefits from ES6 features, especially generators.
Co is a library of utilites for running ECMAScript-6 generators (which are native to Node .011 harmony), with the goal to allieve some/much(?) of the need to write boilerplate code for running and managing generators.
CO is a tool class library that runs ES6 generators (native support in node. 011 harmony mode). Its goal is to help write some / more (?) Template code for running and managing generators.
Co is intrinsically part of Koa(?).
CO is essentially a part of KOA.
If and how does one use Co differently in Koa than in a non-Koa context. In other words, does Koa wholly facade Co?
Can and if so, how can co be used in a way different from koa in non koa situations? In other words, is koa just a “vest” co?
Could Co be replaced in Koa with some other like generator library if there is/was a better one? Are there any?
Is there any other generator Library in koa that can replace co?
Promise Libraries such as “Q” and Bluebird
They are in a sense “polyfills” for implmententing the Promises/A+ spec, if and until Node natively runs that spec.
They are polyfills implementations of promises / A + specification when and until node natively implements the specification.
They have some further non-spec convenience utilities for facilitating the use promises, such as Bluebird’s promisfyAll utility.
They implement some convenient methods outside the specification to better use promises, such as Bluebird’s
My understanding is the ECMAScript-6 spec does/will largely reflect the Promises/A+ spec, but even so, Node 0.11v harmony does not natively implement Promises. (Is this correct?) However when it does, will technologies such as Q and Bluebird be on their way out?
I understand that the ES6 specification in will largely embody the promises / A + specification, but even so, node 0.11v harmony does not have a native promises implementation (right?). If implemented in the future, will technologies like Q and Bluebird become obsolete?
I’ve read something to the effect that “Q” and Bluebird support generators. What does this mean? Does it mean in part that, for example, they to some degree provided the same utility as Co, and if so to what degree?
I’ve read that Q and Bluebird support generators. What’s the meaning of this? Does that mean they provide the same functionality as CO in some way? If so, to what extent?
Thunks and Promises
(translation note: both are terms, better not to translate)
I think I have an fair handle on what they are, but hoping someone can provide a succinct and clear “elevator pitch” definition on what each is, and of course, as asked above, to explain when to use one versus the other — in a Koa context and not in it.
I think I have understood the two, but I still hope someone can provide a concise “elevator promotion” and explain the comparison between the two in the case of using and not using KOA.
- Pro and cons to using something like Bluebird’s promisfy, versus say using Thunkify (github com/visionmedia/node-thunkify)?
Compare the promise library and thunk Library (such as Bluebird)https://github.com/visionmedia/node-thunkify）Between the advantages and disadvantages
To give some further context to this post and its questions, it might be interesting if Koa techniques presented in the following webpages could be discussed and contrasted (especiallly on a pros vs cons basis):
In order to provide more background information for this issue, it would be better if the following information related to koa technology could be discussed and compared together (especially the comparison of advantages and disadvantages)
a) http://www.marcusoft.net/2014/03/koaintro.html (Where’s the thunks or promises, or am I not seeing something?)
b) https://strongloop.com/strongblog/node-js-express-introduction-koa-js-… (Again, where’s the thunks or promises?)
c) http://github.com/koajs/koa/blob/master/docs/guide.md (What does the “next” argument equate to, and what set it and where?)