On Tuesday, October 2, 2012 11:44:23 PM UTC-4, Raynos wrote:
>
> domains have a parallel to sync code. Use event emitters for your sync 
> flow. promises only have a parallel to sync code if you use promises for 
> sync & async code.
>

By "sync code" I meant code with functions that return values and throw 
exceptions. (One might call this "normal code" :P.) Sure, you can do 
everything with (sync) event emitters, but you lose guarantees like only 
one return value, only one thrown exception, and never both from the same 
function. You cannot make assumptions like that about your code's flow if 
it's entirely structured through event emitters, which makes things harder 
on the programmer---you can no longer focus on just getting things done but 
instead have to worry about the technology you're using to do it. And of 
course you have to rebuild all of the sync mechanisms like function 
composition (obviously easy if your EEs are streams), exception bubbling 
(harder, e.g. domains are top-down while exceptions bubble bottom-up), 
catch clauses, finally clauses, etc.

Not sure what you mean by the last sentence. What I meant by saying 
promises parallel sync code is that there is an exact correlation between 
promise concepts and sync code concepts, e.g. fulfillment value <-> return 
value, rejection reason <-> thrown exception, rejection propagation <-> 
exception bubbling, fulfillment value transformation <-> functional 
composition, rejection transformation <-> catch clauses, and so on. You 
should never use promises for sync code IMO.

-- 
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to