Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

http://www.python.org/dev/peps/pep-3104/ describes the rationale for python's closure design.

Personally, to me Javascript is horrendously broken at what it does. In addition to being fatally underspecified as a language, the asynchronous model as implemented in JS results in callback spaghetti (or black magic with Streamline or something). Most JS evented code has extremely poor readability, since logic flow is continuously interrupted.

The best asynchronous event programming idioms I've seen in Python use decorators and yield.

  @event_handler
  def f(input):
      do_stuff()
      x = yield do_more_stuff() # asynchronous call
      return {"result": x}


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

Search: