Just wanted to leave a comment about the ChangeLog which is a list of commits. It would be nice if they sat down for a day (or two) to write down proper release notes that made reference to various commits and outlined exactly what is changing, like if there are backwards compatibility issues or if there are very important bugs solved.
The changelog here looks like a git log :/ I mean, I can do better on my own projects (and have been trying to do so with node-oauth-libre) but for a major project it would be nicer if it had nice release notes.
There is a lot to like about Node. I had a look a couple of years ago but lack of a definitive library to handle callback hell put me off. How is the situation these days?
You have a number of ways of keeping a handle on async code now.
1. Native ES6 promises will cover most of your basic needs. See https://developer.mozilla.org/en/docs/Web/JavaScript/Referen.... In fact, unless you have very specific needs not covered by native promises, you shouldn't drop a third party library into your project.
2. For more advanced operations on promises, use Bluebird. See http://bluebirdjs.com and http://bluebirdjs.com/docs/api-reference.html. It has a ton of features built on top of native ES6 promises. If you're using an older version of Node, it also acts as a polyfill. It can also make it easy to work with libraries that only expose a callback-based interface. So yeah, Bluebird is the shit.
3. co is a generator-based control flow library that can make your async code look more like synchronous code. It's pretty cool, but I haven't personally used it in a project, nor do I know of anyone else who uses it. It builds on top of promises and generators, and isn't very hard to understand under the hood. See https://github.com/tj/co. I wouldn't recommend it, but it might be something to play with because ...
4. ... async/await is coming to JavaScript! At a very high level, this pair of keywords is syntax sugar for what co already does as a library. This is the final stage in the evolution of taming callback hell in JavaScript, and it builds on top of everything that has come before (promises and generators). Here's a tutorial: https://blog.risingstack.com/async-await-node-js-7-nightly/
We've been using async/await (transpiled with babel) for last one year in our production API code. There really is not any need to use those async control flow libraries anymore.
The Koa web framework built by the guys behind Express is pretty neat. You can do stack like calls with it, rather than callbacks, via generator functions.
Not sure what the uptake is like but you can find more at http://koajs.com.
Whole standard api is still using callbacks so you would need to write your wrappers around it to not use callbacks.. And async/await is not solving anything because your definitions of fuctions will still need callbacks/promises under the hood anyway (unless you use libraries that do it for you). I like how Go solves that, gorutines and you write your code as it would be normal sync code.
Tried with node.js for a few months and now back to php7/lavarel, node.js eco-system still evolves quickly and I need a stable backend right now, so far php7 works well for me and seems the development is faster.
Someone already mentioned about the co library. My personal experience is that it is excellent and massively simplifies async calls. The API resembles the async/await pattern: you use the keyword "yield" instead of "await". Async calls look as if they are sync. The code that includes heavy use of async methods such as in a database application greatly benefits from co in terms of code readability.
Many people are complaining that the standard library still uses callbacks and so even though you have async/await, you can't use it with the standard library.
I wholeheartedly agree. I don't understand why someone hasn't build a compat library that simply promisifies all the standard library (it isn't that big), taking the edge cases into account.
This is probably not the answer you're looking for, but you could look into ways that make callbacks enjoyable. The syntactic sugar provided by CoffeeScript goes a long way to make readable (and, dare I say, elegant) what would be a tangled mess in straight up JavaScript:
I think the mental gymnastics needed to write non blocking code also makes you understand the flow of your program, witch allows good abstractions. After a while it becomes a second nature and you get a mental picture of all branches.
Thinking about code as events (button.onclick = showPicture), makes you a better programmer, as this is how a computer work. And when your program has to scale across several CPU's or servers, it will come naturally to you.
Multi threaded solutions can be easier at first, but when you need to have threads that communicate, and handle locks etc, that too becomes hard.
Does this make the npmrc config for cafile redundant now in my MITM environment? The amount of projects that just can't handle the CA or worse, a proxy setting, is very irritating.
Will we not have to make a separate config for every app that also bundles node (e.g. vscode) or anything that uses node to get a file (vue-cli, node-pre-gyp, etc)?
I recently left a job that has a proxy. I would estimate the my time spent there working on proxy related issues to be more than 2 months over the 5 years I was there. Is it too unreasonable to evaluate the cost of these proxies beyond the maintenance cost?
I don't think so. They try as hard as possible. A lot of it is directly related to V8. In Node.JS v8.0.0 nightly they currently support 70% of the ES2015 spec without flags.
[+] [-] omouse|9 years ago|reply
The changelog here looks like a git log :/ I mean, I can do better on my own projects (and have been trying to do so with node-oauth-libre) but for a major project it would be nicer if it had nice release notes.
[+] [-] kosinus|9 years ago|reply
I guess the commit list is the first thing that pops out when skimming, but it's less important than the notable changes.
'Notable changes' is more akin to the release notes I think you want.
As for breaking changes, Node.js follows semver. A major version lists breaking changes more clearly.
[+] [-] koheripbal|9 years ago|reply
[+] [-] SeanDav|9 years ago|reply
[+] [-] GeneralMaximus|9 years ago|reply
1. Native ES6 promises will cover most of your basic needs. See https://developer.mozilla.org/en/docs/Web/JavaScript/Referen.... In fact, unless you have very specific needs not covered by native promises, you shouldn't drop a third party library into your project.
2. For more advanced operations on promises, use Bluebird. See http://bluebirdjs.com and http://bluebirdjs.com/docs/api-reference.html. It has a ton of features built on top of native ES6 promises. If you're using an older version of Node, it also acts as a polyfill. It can also make it easy to work with libraries that only expose a callback-based interface. So yeah, Bluebird is the shit.
3. co is a generator-based control flow library that can make your async code look more like synchronous code. It's pretty cool, but I haven't personally used it in a project, nor do I know of anyone else who uses it. It builds on top of promises and generators, and isn't very hard to understand under the hood. See https://github.com/tj/co. I wouldn't recommend it, but it might be something to play with because ...
4. ... async/await is coming to JavaScript! At a very high level, this pair of keywords is syntax sugar for what co already does as a library. This is the final stage in the evolution of taming callback hell in JavaScript, and it builds on top of everything that has come before (promises and generators). Here's a tutorial: https://blog.risingstack.com/async-await-node-js-7-nightly/
[+] [-] MehdiHK|9 years ago|reply
[+] [-] aswerty|9 years ago|reply
Not sure what the uptake is like but you can find more at http://koajs.com.
[+] [-] madeofpalk|9 years ago|reply
1) Promises.
2) Caolan's async is wonderful for handling all sorts of 'async' problems, like async map and stuff. As close as a de facto library as you can get.
[+] [-] coldtea|9 years ago|reply
[+] [-] lossolo|9 years ago|reply
[+] [-] k__|9 years ago|reply
So if you know these from another language, RxJS is worth a try :)
[+] [-] ausjke|9 years ago|reply
[+] [-] stymaar|9 years ago|reply
[+] [-] zubi|9 years ago|reply
[+] [-] pitaj|9 years ago|reply
[+] [-] norswap|9 years ago|reply
I wholeheartedly agree. I don't understand why someone hasn't build a compat library that simply promisifies all the standard library (it isn't that big), taking the edge cases into account.
[+] [-] athenot|9 years ago|reply
[+] [-] raksoras|9 years ago|reply
[+] [-] kozhevnikov|9 years ago|reply
[+] [-] skynode|9 years ago|reply
[+] [-] lenkite|9 years ago|reply
[+] [-] unknown|9 years ago|reply
[deleted]
[+] [-] unknown|9 years ago|reply
[deleted]
[+] [-] z3t4|9 years ago|reply
I think the mental gymnastics needed to write non blocking code also makes you understand the flow of your program, witch allows good abstractions. After a while it becomes a second nature and you get a mental picture of all branches.
Thinking about code as events (button.onclick = showPicture), makes you a better programmer, as this is how a computer work. And when your program has to scale across several CPU's or servers, it will come naturally to you.
Multi threaded solutions can be easier at first, but when you need to have threads that communicate, and handle locks etc, that too becomes hard.
[+] [-] Already__Taken|9 years ago|reply
Does this make the npmrc config for cafile redundant now in my MITM environment? The amount of projects that just can't handle the CA or worse, a proxy setting, is very irritating.
Will we not have to make a separate config for every app that also bundles node (e.g. vscode) or anything that uses node to get a file (vue-cli, node-pre-gyp, etc)?
[+] [-] inyorgroove|9 years ago|reply
[+] [-] dorianm|9 years ago|reply
The PR is pretty good: https://github.com/nodejs/node/pull/8334/files
[+] [-] hobozilla|9 years ago|reply
[+] [-] campers|9 years ago|reply
[+] [-] SpencerWood|9 years ago|reply
[+] [-] unknown|9 years ago|reply
[deleted]
[+] [-] 0X1A|9 years ago|reply
[+] [-] simlevesque|9 years ago|reply
You can check the progress here: http://node.green/
[+] [-] unknown|9 years ago|reply
[deleted]
[+] [-] jrvidal|9 years ago|reply
[+] [-] forgottenacc57|9 years ago|reply
[+] [-] k__|9 years ago|reply
[+] [-] crudbug|9 years ago|reply
[+] [-] caub|9 years ago|reply
[deleted]