Here's how this looks in twisted (handling exceptions, capturing (but ignoring) outputs, etc...):
@defer.inlineCallbacks
def insertCollection(collection):
for ob in collection:
yield db.insert(ob)
...as much as people talk about the complexity of twisted with respect to async programming, they've really figured it out over the many years of the life of the project.
I agree with substack that you can do this without changing the language, but you do have to get something usable to people at some point.
I think most people who write any code in node.js run into this issue. I am a casual user, but ran into it a couple of days ago and did some research to find that there are many third-party modules I could bring in to do a for loop, but nothing built-in. The old way of doing this in twisted (manually managing deferreds) really turned a lot of people off. By the time twisted got inlineDeferreds and inlineCallbacks, people already had their impressions of how difficult things are.
I still think node.js is fun and viable, but it does need a for loop.
Comments
Here's how this looks in twisted (handling exceptions, capturing (but ignoring) outputs, etc...):
...as much as people talk about the complexity of twisted with respect to async programming, they've really figured it out over the many years of the life of the project.I agree with substack that you can do this without changing the language, but you do have to get something usable to people at some point.
I think most people who write any code in node.js run into this issue. I am a casual user, but ran into it a couple of days ago and did some research to find that there are many third-party modules I could bring in to do a for loop, but nothing built-in. The old way of doing this in twisted (manually managing deferreds) really turned a lot of people off. By the time twisted got inlineDeferreds and inlineCallbacks, people already had their impressions of how difficult things are.
I still think node.js is fun and viable, but it does need a for loop.