3 ms·
This is probably the most common hiccup in getting started with node. I think this is the reason node.js is either loved or hated : if you get over this acti
by gridmaths 13y ago
This is probably the most common hiccup in getting started with node.
I think this is the reason node.js is either loved or hated : if you get over this activation energy hump, you love it, if not you hate node.. to a first order approximation.
Basically, to get over this hump, you need a small piece of code which can handle a sequence of tasks in order : I wrote serialq npm to a minimal implementation of this, and there are much better ones for production use.
So, once you have a sequential task Queue, you can use it to program in a more procedural way to get started with your early apps.. then you will use it only for a few edge cases like startup initialization, and you will be comfortable with callback-heaven :]
Callback-heaven is not a new idea.. you may not have heard of CICS COBOL system.. its an ancient mainframe terminal client-server app framework system with some of the same ideas.
As a side note, be aware you don't need to have many levels of indentation in your code.. its a bad symptom in node javascript or in any other language. Just as novice programmers can make deeply indented code in Pascal or C.. you can do it in your node.js program. Just realize its bad style and think of nicer ways to structure it. Async does not imply deep indenting.