Comment by ecshafer

Comment by ecshafer 21 hours ago

12 replies

I like the look of this direction. I am not a fan of the `async` keyword that has become so popular in some languages that then pollutes the codebase.

davidkunz 20 hours ago

In JavaScript, I love the `async` keyword as it's a good indicator that something goes over the wire.

Dwedit 18 hours ago

Async always confused me as to when a function would actually create a new thread or not.

  • metaltyphoon 12 hours ago

    Why? Asynchrony has nothing to do with multiple threads. In fact you can have async with only a single thread!

warmwaffles 20 hours ago

Async usually ends up being a coloring function that knows no bounds once it is used.

  • amonroe805-2 20 hours ago

    I’ve never really understood the issue with this. I find it quite useful to know what functions may do something async vs which ones are guaranteed to run without stopping.

    In my current job, I mostly write (non-async) python, and I find it to be a performance footgun that you cannot trivially tell when a method call will trigger I/O, which makes it incredibly easy for our devs to end up with N+1-style queries without realizing it.

    With async/await, devs are always forced into awareness of where these operations do and don’t occur, and are much more likely to manage them effectively.

    FWIW: The zig approach also seems great here, as the explicit Io function argument seems likely to force a similar acknowledgement from the developer. And without introducing new syntax at that! Am excited to see how well it works in practice.

    • newpavlov 20 hours ago

      In my (Rust-colored) opinion, the async keyword has two main problems:

      1) It tracks code property which is usually omitted in sync code (i.e. most languages do not mark functions with "does IO"). Why IO is more important than "may panic", "uses bounded stack", "may perform allocations", etc.?

      2) It implements an ad-hoc problem-specific effect system with various warts. And working around those warts requires re-implementation of half of the language.

      • echelon 20 hours ago

        > Why IO is more important than "may panic", "uses bounded stack", "may perform allocations", etc.?

        Rust could use these markers as well.

    • ecshafer 20 hours ago

      Is this Django? I could maybe see that argument there. Some frameworks and ORMs can muddy that distinction. But most the code ive written its really clear if something will lead to io or not.

    • warmwaffles 18 hours ago

      I've watched many changes over time where the non async function uses an async call, then the function eventually becomes marked as async. Once majority of functions get marked as async, what was the point of that boilerplate?