IMHO, node needs as few non-IO browser non-compliant APIs as possible. If
something like setImmediate will suffice, use it instead of nextTick. If
something like thisTick is necessary, ideally it would be done in pure
JavaScript or in a browser-compliant way so any modules depending on it can
more easily be ported to the browser.

See:
https://github.com/substack/node-browserify/blob/ac208b825a68d5a0f0390eee5450eec8605529a5/wrappers/node_compat.js


For me, it's ultimately about code reuse, and node not
being perceived (valid or not) as a fork of JavaScript.The node and
JavaScript communities as a whole will be far better served with compatible
APIs. If an internal APi will suffice, keep it internal and use
setImmediate externally. If thisTick is necessary externally, if possible,
implement it in pure browser-compliant JavaScript a la Streams, etc...

Cheers,
Adam Crabtree

On Fri, Jun 1, 2012 at 9:54 AM, Jorge <[email protected]> wrote:

> On Jun 1, 2012, at 6:29 PM, Jorge wrote:
> > On May 30, 2012, at 12:57 AM, Tim Caswell wrote
> >>> On Tue, May 29, 2012 at 5:22 PM, Jorge <[email protected]>
> wrote:
> >>>
> >>> FYI: setImmediate === nextTick and identical to a setTimeout(f,0)
> without the clamping.
> >>
> >> so I guess in a way setImmediate(fn) could be described fairly
> accurately as a faster setTimeout(fn, 0).  As I understand timer events get
> put at the end of the queue as well.
> >>
> >> <snip>
> >
> > LOL, see "nextTick(f) vs SetTimeout(f, 0)" (it's from ~ 2 years ago :-P):
> >
> > <
> http://groups.google.com/group/nodejs/browse_thread/thread/b564ac42ac53e424/7b85530b465f578d
> >
> > --
> > Jorge.
>
>
> A jewel from that thread:
>
>
> On Aug 30, 2010, at 4:36 AM, Tim Caswell wrote
> > On Aug 29, 2010 6:43 PM, "Vitali Lovich" <[email protected]> wrote:
> >> That setTimeout(f, 0) can be optimized to perform significantly better
> than it currently does.
> >
> > Why complicate the code for a use case that shouldn't exist?  Namely
> using setTimeout when you really mean nextTick.
> >
> > <snip>
>
>
> :-P
> --
> Jorge.




-- 
Better a little with righteousness
       than much gain with injustice.
Proverbs 16:8

Reply via email to