Sorry for digging up an old post I'm thinking about writing a C++ streaming json parser addon. The implementations I've found so far are done in javascript and are perhaps much slower than buffering the full response and doing JSON.parse (a couple of streaming json authors say that the speed is 2 to 3 times slower.
I'm thinking about feeding both the hooks and the stream itself in the addon so that it can emit only the events that I'm interested in. The alternative would be to pass in each chunk to the C side, but from what I understand, constant intercommunication between the C binding and javascript is "slow". My use case is to create an http proxy that aggregates from multiple restful json sources. For certain service calls, it'd have to read and aggregate some of the calls. I wish do as much streaming as I can to reduce the amount of overhead this proxy would induce as an additional http layer. Clearly more complexity involved, but do you think the speed tradeoff is worth it especially in regards to http performance anyways? Thanks! On Sunday, April 15, 2012 9:41:38 PM UTC-7, Isaac Schlueter wrote: > > I'd recommend not doing the "stream" bit in C++, and instead have a > much simpler binding layer that does a single action, and then use > JavaScript to wrap up the queue of writes and emitted data blobs. > > Check out the zlib binding in src/node_zlib.cc and lib/zlib.js in > node's source. It does something similar to this. > > > On Sun, Apr 15, 2012 at 20:39, rhasson <rha...@gmail.com <javascript:>> > wrote: > > I'm working on a C++ NLP binding and wanted to implemented a streaming > > interface so that text could be added to a stream in JS, my native > binding > > will receive it, extract the text process it and emit a "data"events with > > the responses. > > > > How would I go about reading a stream that was either passed in as an > > argument or was piped in via "pipe"? I'm assuming I'll have to implement > > the pipe interface as well which I'm not sure how to do yet > > > > Thanks, > > Roy > > > > -- > > 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<javascript:> > > To unsubscribe from this group, send email to > > nodejs+un...@googlegroups.com <javascript:> > > 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 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 --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.