@Mark: kudos for you. totally right. I think, that all the claims about how 
bad async coding style is, just comes because the developers come from 
languages, which do not know this style. its only unfamiliarity with this 
paradigm. i guess subroutines had a hard start too as they appeared.

callback chains can be hard to maintain, but long sequential methods, 
deeply nested control structures, wide-spread call hierarchy also. there 
are built in methods to reduce nesting, EventEmitters + Streams, If you 
design your code to reduce the need of closures, you can just write simple 
functions like Marks example, so your code has a max nesting of 2, the 
function itself and simple if-else or if-return checks. 

i think it's not only good to write own async-lib, it's worth to look into 
functional languages as Haskel, LISP, Scala to understand how functional 
code can be written.  

Am Sonntag, 30. Dezember 2012 06:16:58 UTC+1 schrieb Mark Hahn:
>
> > Imagine writing program consisting of 300 async calls
>
> My app currently has several thousand such calls.  
>  
> >  If nodejs team believes current solutions are optimal
>
> There is no optimal solution.  If there were one everyone would jump on it.
>
> I think it is great that you developed an interesting approach to the 
> async problem.  I think every programmer new to node should write an async 
> library.  I wrote such a library and I learned a lot, not just about 
> programming node, but about the nature of async code.  I used it for a 
> while.
>
> Over the last several years I have found it easier and easier to just use 
> "boilerplate" as you described it.  Here are some examples ...
>
> *Linear code ...
> *
> doThing1 = ->
>     blah blah blah
>     doThing2()
>
> doThing2 = ->
>     blah blah blah
>     done()
>
> doThing1()
>
>
> *Looping ...*
>
> angryBirds = [bird1, bird2, bird3]
> do flingOneBird = ->
>     if not (bird = angryBirds.shift()) then done(); return
>     bird.fling()
>     flingOneBird()
>
> I have used this boilerplate so many times that I can type it without 
> thinking.  It has also become very easy to read.  I don't think it is hard 
> for others to read, but I may be wrong.
>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to