12 ms·
So the new framework of choice now seems to be Node according to his graphs. I'm building in Node as we speak and I'm not loving the Promise pattern to solve ca
by davmar 11y ago
So the new framework of choice now seems to be Node according to his graphs. I'm building in Node as we speak and I'm not loving the Promise pattern to solve callback hell. Will I get over it? Have others?
- 0x0 11y agoThere was a pretty elegant post on how Python's coroutines can replace callback hell with almost-synchronous-looking async code on HN the other day: https://news.ycombinator.com/item?id=10220712 https://news.ycombinator.com/item?id=10220712 Wonder if something similar will catch on in the node ecosystem?
- lastofus 11y agoEveryone forgets that Gevent has been around for years, and lets you write completely synchronous looking async code.
- vangale 11y agoI think a better way of looking at it is there isn't enough "cross pollination" in big open-source frameworks and languages.
- M2Ys4U 11y agopromises, async functions and generators will make writing async code look more sync in javascript/node. Whether or not this is a good thing or not, I'm undecided.
- supster 11y agoYeah ES7 has async and await which are pretty similar to that source: http://www.sitepoint.com/simplifying-asynchronous-coding-es7-async-functions/ http://www.sitepoint.com/simplifying-asynchronous-coding-es7...
- hayksaakian 11y agoES6 has yield https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- olouv 11y agoHave you tried bluebird? It solved all my issues with async workflow in NodeJS, crazy-fast performance coupled with a very nice lodash-like API that makes working with data a breeze.
- davmar 11y agoi'm using it and it's nice as you said. i'm not a node expert yet, this is my first large project. i'm sure i'll get more fluent as i go along but this programming style was an unanticipated twist in the road.
- dkulchenko 11y agoSwitching from Ruby, I used the Fiber pattern (await-defer) heavily in Node via node-fibers & synchronize.js which alleviated a lot of the pain.
- raksoras 11y agoShameless plug: https://github.com/raksoras/luaw https://github.com/raksoras/luaw
- zachrose 11y agoYou might get over it! I feel I have, and now see callbacks as suggestions of where to break my code apart. For example, callbacks nested more more than a two deep are usually a remonder that I'm really trying to describe a series of steps with a common error and success handler, and the library "async" has a method called waterfall that does exactly this. Naming those steps keeps them simple, exposes commmonalities, and often leads to reuse. That said, the thrust of this article is that you should make your technical decisions based on the absolute most trending thing at the moment, and I think that's bogus. Plain old syncronous programming has its place.
- danneu 11y agoI use Koa ("Express' successor") which uses co/generators to let you write familiar sync-looking code.
- idibidiart 11y agoUse Node 4.x with ES7 and Async/Await for replacement to Promise pattern. Use async-csp for more demanding scenarios. Node 4.x is awesome (relative to Node 0.12)