--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
2) As of node 0.6.0, node-fibers is just a module. It never was a fork, but in node 0.4.0 it was much more of a hack. In node 0.6.0 it works just like any other module, you install it, require it, and use it.
3) Depending on how you use fibers, it may be possible to rewrite your code using generators, it may not be. Fibers will give you a superset of functionality and it's up to you to look at what generators will be and build your code to support them in the future if that's what you want.
but, common-node (and maybe some other libraries) have abstracted away that callback when you're living in their abstraction by using fibers under the hood (i'm sure Oleg will pop in any minute to explain how). the way yield is described for generators does not lend itself to ever being abstracted to that degree.
the issue for us is that quick maintainability is as important as performance - the example of mongo query nested callbacks (like in the tests of node-mongo-native) is just way too messy (and if everyone else thinks it's fine then I'm in the 1% that don't).
Lets not go into that discussion again. I think last time we
concluded, that projects are vastly different in their setup, and thus
in their needs. I can tell myself of different projects where on one I
was happy with callbacks and others it just went down. Last time we
had even talked down to examples where it was not succefully explained
by the "you doing it all wrong crowd" who said everything that
experiments with alternative designs to code than callbacks is doing
heresy.
Anyway. I won't jump into that discussion once again :-)
@john.tiger. You can also have a look at node-streamline. I rewrote a
web based monbodb live data analytics engine from callbacks to
streamline and was quite happy with the result. And don't let you drag
into these religous debattes, you just decide what works for you :-)
flow control mentioned -> fibers mentioned -> someone calls fibers (incompatible || a fork || "not node") -> Marcel defends fibers as "just a module" -> Oleg mentions common-node as "not just a module" -> Mikeal makes a disparaging remark -> Axel disagrees, promotes streamline.
if you start at any single point the other will always descend from it. sometimes Oleg and Mikeal are swapped in position.
comments like this make me scratch my head.
there are thousands of developers here on this mailing list maintaining node code using callbacks. there are products that do daily deploys across thousands of node processes that use callbacks.
there are hundreds of thousands of liberal arts graduates using and maintaining code that uses jquery (with callbacks!).
if you think that callbacks are a blocker for maintainability i can't help but wonder why all these other people seem to be fine but the it's such a blocker for you that you would need to opt out of what the vast majority of the community are using, testing, and running in production every day.
2) As of node 0.6.0, node-fibers is just a module. It never was a fork, but in node 0.4.0 it was much more of a hack. In node 0.6.0 it works just like any other module, you install it, require it, and use it.
3) Depending on how you use fibers, it may be possible to rewrite your code using generators, it may not be. Fibers will give you a superset of functionality and it's up to you to look at what generators will be and build your code to support them in the future if that's what you want.
On Fri, Feb 10, 2012 at 12:55 PM, Mikeal Rogers <mikeal...@gmail.com> wrote:
fibers and generators (as described in harmony) have a large delta between them.if you read the harmony spec for generators you'll notice that the yield statement pushes it's way all the way up the call stack so you can't abstract it away the same way common-node does with fibers.what you should probably do is just use normal node, the way 99% of the community does :)
On Feb 10, 2012, at February 10, 20121:35 PM, Marco Rogers wrote:
1) node will support harmony generators the second they are stable in v8. The language evolves with v8, node doesn't touch it.2) To my knowledge, node-fibers is a fork of node with patches to both node and v8 to enable fibers. So you can't just run node, you have to run node-fibers.3) I think it would be very easy to paint yourself into a corner here. But there are lots of abstractions on top of fibers that could possibly be implemented later with generators instead. Keep in mind that when you dig into the details, fibers seem to allow deeper semantic changes in node than the version of generators in harmony. I'm not the best person to explain the difference, but I've understood enough of the talk to know they are not equivalent paradigms. Generators enable a subset of functionality that fibers does.Hope this helps.:Marco--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
var concatAsync = Jscex.compile("async", function(path1, path2) {
// read first file
var file1 = $await(fs.readFileAsync(path1, 'utf8'));
// read second file
var file2 = $await(fs.readFileAsync(path2, 'utf8'));
console.log(file1 + file2);
}));
You can even make it parallel easily.
var concatAsync = Jscex.compile("async", function(path1, path2) {
var data = $await(Task.whenAll(
"file1": fs.readFileAsync(path1, 'utf8'),
"file2": fs.readFileAsync(path2, 'utf8')));
console.log(data.file1 + data.file2);
}));
No preprocessor, no external compilation, just run directly with any ES3
engines.
The doc in English is outdated but the samples
(https://github.com/JeffreyZhao/jscex/tree/master/samples/async) are always
fine:
Jeffrey Zhao
Blog: http://blog.zhaojie.me/
Twitter: @jeffz_cn (Chinese) | @jeffz_en (English)
console.log(file1 + file2);
});
Chris
--
Hmm... I wouldn't really say that. For example, there are loop
expressions and autoreturn. Also, the body of a "class" has some
magic.
> The big difference in my mind is that I can think of what the resulting JS
> will be almost perfectly when I read or write CS. My mind isn't good enough
> to do that with streamline.
Hmm... I don't think that it's necessary to do that in either of those
languages. IMO, having to think about what the generated JS is or
having to look at it (e.g. for debugging) is a major bug, just like
having to look at the generated machine code that gcc creates from C++
code is a bug, too. (That's also why line number mapping for
coffeescript is being worked on, it's basically complete, just without
tests and with a bug that makes it not work correctly inside of string
interpolation. https://github.com/jashkenas/coffee-script/pull/2050 )
You only have to know what the code will do, not what it will look
like. And that usually is a lot easier. I can't tell you how
streamline works, but I grasped the basic concept "underscore is like
a blocking call that resumes on callback", and I think that this
should be sufficient. Are you going to say gcc is bad because it
optimizes code in ways you don't know or understand?