Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How Does Async Work?

How Does Async Work?

If you work with Node.js or Python you might have heard of asynchronous programming a.k.a. async/await.
It lets you do something else while you wait on some work to be done in the background - like reading a file or sending some data over the network.
But what is it, really? And are there differences between the programming languages?
Let's go on a trip through async-land and discover callbacks, event loops, and state machines.
We will look at Node's, Python's, and Rust's async features and how they work under the hood.

Matthias Endler

September 24, 2019
Tweet

More Decks by Matthias Endler

Other Decks in Technology

Transcript

  1. ~ Matthias Endler ~ Backend engineer at trivago Mostly Go,

    Rust, Python Interested in low level stuff 2
  2. ~ Matthias Endler ~ Backend engineer at trivago Mostly Go,

    Rust, Python Interested in low level stuff endler.dev and Hello-rust.show 2
  3. 3

  4. 3

  5. 6

  6. 7

  7. 7

  8. 8

  9. 9

  10. 10

  11. 10

  12. 12

  13. 13

  14. 16

  15. 16

  16. 17

  17. 19

  18. 20

  19. 21

  20. 21

  21. 25

  22. 25

  23. 26

  24. 43

  25. 45

  26. 46

  27. 47

  28. What is Rust? * Systems programming language * Started at

    Mozilla (firefox) * used by Amazon/Microsoft/Dropbox... * Main goals: safety, performance * fearless concurrency 50
  29. 51

  30. 53

  31. 54

  32. 55

  33. requests/s 57 2.000.000 1.500.000 1.000.000 500.000 0 Rust
 (minihttp) java


    (rapidoid) go
 (fasthttp) go
 (stdlib) node.js
 (stdlib)
  34. 58

  35. Summary * asyncio in Python is based on coroutines *

    async in javascript is based on callbacks * Rust's futures are zero-cost 60
  36. Credits * Pixel backgrounds by slance.com * Truck and engine

    logos by Pixelart maker * Jake Archibald - in the loop 61