Hacker News new | past | comments | ask | show | jobs | submit login

I personally like the coroutine approach better (greenlets) since your code looks synchronous without squinting and usually performs well (there are various optimization in Stackless Python and PyPy has support as well). With libraries like gevent, and its API inspired by multiprocessing, asynchronous handling of code blocking on i/o just becomes another option next to using threads, processes or computing cluster.

Whereas with node.js/twisted (excluding @inlineCallbacks) approach the implementation detail—that is how do you talk with OS kernel about I/O—becomes the force shaping how you design your program and your API.

Sure, there's place for callbacks in Python. But as Python programmers, we can afford to reserve them for where they belong, like handling high-level events (i.e. observer pattern).




agreed. I had to use twisted this year, and I find the whole approach really wrong from an API POV. You have to force everything to use twisted-way, and this impacts a lot the design of the whole app. inlineCallbacks has its issues as well (it sometimes lead to wrong stack-traces, and you are shit of out luck trying to understand what's going on then, but maybe that's just an implementation flaw).

The use of generator has its flaw as well: as pointed already by other, it is difficult to compose them effectively, making refactoring quite a PITA.

Gevent seems like the best option in python, but I have never used it, so maybe it has its drawbacks as well.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: