Comments (5)
A great example of this is node's use of callbacks. Early on node experimented with a feature called 'promises' that added a number of features to make async code appear more linear. It was taken out of node core for a few reasons:
- they are more complex than callbacks
- they can be implemented in userland (distributed on npm as third party modules)
Whoever wrote this, cannot be taken seriously.
If promises are considered more complicated for beginners, then it should be stated accordingly. Otherwise, it only creates confusion - the beginners read this and take it absolutely, to never look at promises again. Bad-bad teaching.
The correct statement is along these lines: Promises offer the best approach to asynchronous programming, though they do require additional learning. (just like everything that is worthwhile)
from art-of-node.
A correct statement would explain the differences and trade offs you make without any bias. Nothing can be better in all ways. You always make a trade off. In this case more code (in trade off with gaining a better/different/simpler api) and therefore more complexity.
Some people might find promises easy to grasp and some might require additional learning and vise versa with callbacks. In the node case I prefer teaching how to use callbacks first and then explain what promises can give you on top, i.e. what you gain (or lose) by using them.
from art-of-node.
@dmitriz i guess it adds complexity for newbies. When i started to work i used callbacks from the beginning, but i got Promises only after 2 years of working.
from art-of-node.
@dmitriz Callbacks are certainly an easier way of understanding the asynchronous flow. Newbies should start with callbacks. After some time, you get hands on promises very naturally.
from art-of-node.
@dmitriz here's an interesting update on the state of promises in core node: https://medium.com/@isntitvacant/adding-promise-support-to-core-a4ea895ccbda#.3nl0mjvrn
from art-of-node.
Related Issues (20)
- Time Server Problem HOT 1
- Sorry Again Wrong repo
- Remove the laser from the hard drive HOT 3
- Can we simplify the callbacks pseudocode please? HOT 7
- I get this error after running npm install learnyounode -g. Ubuntu 14.04 HOT 2
- parseInt mystery HOT 2
- Why not use GitHub pages to host this doc? HOT 5
- Question on "require" HOT 3
- CoolBear example throws a error in RequireBin HOT 3
- Link mentioned in the doc is not working/changed
- Callbacks pseudocode missing passed arguments HOT 1
- README file contains a broken link to a git/github resource HOT 2
- Can I be an admin on this repo? HOT 1
- RequireBin example error HOT 2
- Wrong number?
- asynch file IO how complex it can be? HOT 3
- RequireBin Example Doesn't Work on Chromium
- Error in solution of My First Async IO lesson HOT 1
- Requirebin link domain leads to gambling website
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from art-of-node.