But the value of running everywhere is also why ES6 is not a panacea. As you say, soon we won't need promises "on the server". But I want my codebase to run correctly everywhere. Promises are a bandaid that I'll need for quite a while yet.
for LANG in Java Scala Ruby Python C C++ Groovy Clojure; do s/PHP/$LANG/; done
If all you have is a room full of PHP developers and all you need is a REST site, then well you could do worse but I would like to discourage you from the practice.
Similarly, unless you have a highly specialized need - fun asynch chat server or complex app where business logic is being directly shared between client and server - I too would discourage locking one's self into that platform.
Javascript is not the worst thing ever, but why bother if you don't have to?
Dont you mean you won't see standalone Promises, and instead Promises + Generators?
What do we get using this new shiny instead of the older shiny bluebird or the old shiny Q?
I'm impressed that you apparently completely failed to realise co is an abstractive layer over promises, something it states upfront:
> Generator based flow-control goodness for nodejs (and soon the browser), using thunks or promises
What you yield from your generator is not magical pixie dusts, it's promises.
co thunkifies promises: https://github.com/visionmedia/co/blob/master/index.js#L209-...
The generator is the driver, but the driver on its own its useless if it's got nothing to drive.
And what it has to drive is promises (or thunks since most existing node code is thunks-based I guess it makes sense to support that. taskjs uses promises more or less exclusively for the same purpose, Python 3.4's asyncio uses behaving much like JS promises, etc...)
Typically in apps using 'co', functions will return generators, not promises. Promises were probably added because of all the existing code out there.
Here is a file from my ongoing project, should explain how generators are being used. See getPosts() or addPost() https://github.com/jeswin/fora/blob/master/server/src/models...
[Edit: Just read your earlier (Gr.GP) comment. Might want to avoid the unnecessary snark, especially when there's a chance you might be wrong.]
No.
> Typically in apps using 'co', functions will return generators, not promises. Promises were probably added because of all the existing code out there.
Again, generators in and of themselves don't do anything (for async code). Something needs to be generated/yielded, and that thing is the reification of an asynchronous operation. Such as a promise[0]. Generators and promises fulfil different roles, generators are used as imperative "sugar" for chaining promises.
The generators you yield will ultimately resolve into a series of async operations (promises or "thunks"), yielding a generator is convenience (not very useful convenience either, since `yield*` exists the ability to yield generators just complexifies the driver)
[0] and in the case of co a "thunk"[1], because node
node certainly recognizes this. However, there is no need to do anything here since JS is taking care of this with ES6. Even if you don't want to use ES6, there are now multiple ways to compile it down to ES5.
Hence the slowly rising mindshare of Promises
Promises are declining, and honestly doesn't really solve the problem in most cases. A couple of years from now, you won't see promises on the server. You should see tjholowaychuk/visionmedia's co[1]; that's how JS is going to look like in future.
In terms of expressiveness, there isn't much to choose between dynamic languages. While it took some getting used to, programming JS wasn't that different from writing Python. However, JS/node is succeeding because this is the first time ever that we have a language/platform that is truly write-once, run-anywhere. A significant advantage in favor of node.
[1] https://github.com/visionmedia/co