Re: [nodejs] Fundamentals: Callbacks in Node?

2014-08-11 Thread Fedor Indutny
Matt, This couldn't happen with any other js-engine, because of the ECMAScript semantics. The code that creates request handler closure is executed only once, which means that the closure is created only once. Cheers, Fedor. On Mon, Aug 11, 2014 at 10:00 PM, Matt wrote: > I don't know where y

Re: [nodejs] Fundamentals: Callbacks in Node?

2014-08-11 Thread Matt
I don't know where you heard that, but it's not true of V8 (or I doubt of any modern JS engine). There are plenty of benchmarks out there that can prove this. You can however separate out for basic code hygiene - you get a lot of indentation with nested callbacks. Matt. On Sun, Aug 10, 2014 at

Re: [nodejs] Fundamentals: Callbacks in Node?

2014-08-11 Thread Fedor Indutny
It is created only once. However, if you define function in a closure - it'll be allocated each time the closure is executed. On Sun, Aug 10, 2014 at 6:13 PM, David J Lima wrote: > In the plain javaScript world I've learned that nested functions can be > problematic because the inner function

Re: [nodejs] Re: new node module: fd-slicer

2014-08-11 Thread Matt
On Sun, Aug 10, 2014 at 1:49 AM, Andrew Kelley wrote: > Can't you just use a stream multiplexer (AKA "Tee") for this? > > > How does this address the problem in any way? > > You create one read stream, then multiplex it to two writers. Isn't that the problem you were trying to solve? Matt. --

[nodejs] Fundamentals: Callbacks in Node?

2014-08-11 Thread David J Lima
In the plain javaScript world I've learned that nested functions can be problematic because the inner function is "re-created" every time the outer function is called. Apparently the inner function is garbage collected and the constant re-creation of it has a cost on performance. function out

Re: [nodejs] error with Cluster + Express

2014-08-11 Thread Sam Roberts
On Sat, Aug 9, 2014 at 8:32 PM, Tushar Jain wrote: > I am trying to use cluster module with express, while doing so if I write > code for clustering in a post request handler, I am getting an EINVAl, > cannot write to IPC channel error. Not sure what "code for clustering in a post request handler

Re: [nodejs] Expanding ChildProcess.prototype?

2014-08-11 Thread Alex Kocharin
 First of all, it's a bad idea to extend native prototypes. Some third party modules can rely on that, etc, etc. So instead of `child.kill` you could write external function and call it as `kill(child)`.  Ohh... that sentence looks weird... poor children. There is also a possibility to capture requ

[nodejs] Re: error with Cluster + Express

2014-08-11 Thread Phillip Johnsen
Hi Tushar, being a little more specific about what you are trying to accomplish and sharing some code would help. Have you tried one of the many clustering examples google has found? i.e: http://rowanmanning.com/posts/node-cluster-and-express/ Usually you wouldnt need to write any clustering sp