Re:The love and hate of Node.js
by dc-tech-fan on Wednesday May 16, 2012 @01:18PM
(#3982994)
> The only technical problem where I've seen node be a unique solution is dealing with third party apis concurrently.
Use a library like Async, it makes this really easy.
https://github.com/caolan/async
(assume redis, mongo, facebook, and callback are all functions)
async.parallel([ redis, mongo, facebook], callback);
callback is called when all of the others are complete. If you have dependencies, like facebook needs the output of redis and mongo then use async.auto which will automatically run things in parallel and in the order you need them.
Yes, what I was saying is that Node makes that really simple, and PHP, Python, Ruby, etc don't.
That's more of a side effect of having everything be asynchronous though.
Re:The love and hate of Node.js
by anonymoushn on Wednesday May 16, 2012 @02:49PM
(#3983433)
This is really simple in Python using greenlet, stackless, or gevent.
The only technical problem I've seen that node is an easier solution is dealing with third party apis concurrently. It wouldn't be very straightforward to have a redis query, a mongo query, a facebook query, and a sendgrid query all open at the same time and managing the results when they all come in (and keeping program flow maintainable) in PHP, Python, Ruby, etc. Probably not a common problem or desired feature, though.
We're 100% Node on heroku with a custom buildpack, using a hosted Mongo service, some Node written cron jobs (which were pretty interesting to write), and redis and we serve 5 digits worth of hits every day at least, and I'm more than happy with performance. I never once look back and regret the decision to use node. I don't necessarily care about sharing code, having frontend developers do everything, etc like some node guys throw around naively, but I am looking forward to bringing somebody on that can grasp adding in a new API route, throw in a Mongoose find, and render a template with some variables. We have EJS templates serverside and clientside for that reason, and that could just as easily be done in PHP or Python.
However, I am enjoying working with node, the node community, and the interesting modules and stuff that are being released. I will say that there's a good bit more active "lets hack this up into a module and open source it over the weekend" kind of people in node than others at the moment.