News for hackers. Stuff that matters.
Re:Show HN: HTTP/2 Python-Asyncio Web Microframework by BrandoElFollito on Monday April 23, 2018 @07:07PM (#16908297)
> asyncio is just one (really really poor) implementation of async/await coroutines on Python.

Are there other implementations or is it just that the one existing (asyncio) is just poor?

I tried to understand asyncio a few times and failed. Threading was easy, Promises in JS were easy and I blocked on asyncio.

Re:Show HN: HTTP/2 Python-Asyncio Web Microframework by cutler on Monday April 23, 2018 @07:36PM (#16908447)
Me too. Grokked JS promises but async/await threw me. Why is single-threaded async, eg. Node and Python/AsyncIO, such a big deal when we have languages like Elixir, Go and Clojure which have real concurrency and no trade-offs?
Re:Show HN: HTTP/2 Python-Asyncio Web Microframework by Fukkaudeku on Tuesday April 24, 2018 @03:00AM (#16910485)
There are other implementations, such as Curio (https://github.com/dabeaz/curio) or Trio (https://github.com/python-trio/trio). Both are simpler and more hand-holdy (and less footgun) than asyncio.

Disclaimer: I am a trio dev, though.

Re:Show HN: HTTP/2 Python-Asyncio Web Microframework by BrandoElFollito on Tuesday April 24, 2018 @04:07AM (#16910795)
Thanks, the trio tutorial is really enlightening!

I was hoping (with Python, not trio in particular) that it would all end up with something like Promises which make coding really easy but I guess not.

This is of course a matter of personal taste, but having

  call_a_asynch_function(with, some, parameters)
  .then(with_the_result_when_it_comes => do_something)
  some_other_codre_which_runs_synchronously
  and_some_more
seems easier to my eye than the whole idea of calling await in async functions
Re:Show HN: HTTP/2 Python-Asyncio Web Microframework by mcintyre1994 on Tuesday April 24, 2018 @05:14AM (#16911083)
Python doesn't really have the syntax for it, the promise library uses lambda which is pretty bulky: https://pypi.org/project/promise/

I wonder if you could do something nicer using the `with` syntax?

    with async_fn(with, params) as result:
        do_something(result)
    this_runs_sync()
    then_this_does()
It's still going to be annoying when they nest, maybe an async with which makes its whole content act like promises with `then` calls?

    async with fetch_thing() as result:
        json = async_jsonify(result)
        post_result = async_post(json)
        json_result = async_jsonify(post_result)
    then_sync_stuff()
Though you also want to be able to return promises, I suppose you could allow `return async with`, and you also need to be able to catch them. Not sure if this makes any sense to look further at, but I don't think we're getting arrow functions and the JS syntax without those is pretty clunky.