Getting started with Tokio. The ultimate starter guide to writing async Rust.

Поделиться
HTML-код
  • Опубликовано: 1 фев 2025

Комментарии • 74

  • @TheRealKitWalker
    @TheRealKitWalker Год назад +18

    Wow. Appreciate the hard work in compiling all this information in a precise way. Thanks. Very refreshing.

  • @r2_rho
    @r2_rho Год назад +15

    Easily the best explanation ive seen on tokio. Thanks for this!

  • @BooTheDev
    @BooTheDev Год назад +20

    Super cool video! I was confused about async in rust for a long time but could not find the great one like this. Thanks!

    • @dreamsofcode
      @dreamsofcode  Год назад +2

      I'm glad you found it useful! Let me know if there's any other topics I should cover as well!

    • @katzetante5599
      @katzetante5599 Год назад

      Same 😂

  • @brivism
    @brivism Год назад +10

    Wtf man. This content is pure gold!
    Love the quality 🔥🔥

  • @aaronraycove9517
    @aaronraycove9517 Год назад +3

    Your video didn't directly address the issue I was running across. But thanks for explaining this in more detail, because having that understanding helped me figure out the issue I was having. This is awesome Thanks so much.

    • @dreamsofcode
      @dreamsofcode  Год назад

      Really glad to hear it helped! What was the issue you were facing? Maybe I can make a video about it :)

  • @sparschaler3536
    @sparschaler3536 Год назад +2

    Great video.
    Thanks for not begging me to subscribe, which I had already done half way through.

    • @dreamsofcode
      @dreamsofcode  Год назад

      I'm sure RUclips viewers have been told to subscribe many times in their lives 🤣

  • @kamleshahire6634
    @kamleshahire6634 5 месяцев назад +1

    This is the best explanation I have seen on tokio. Thanks for this!

  • @skytech2501
    @skytech2501 Год назад +13

    Awesome guide to async! Please make the follow-ups for other tokio async modules. Thanks 👍

  • @egorpanfilov
    @egorpanfilov 7 месяцев назад +1

    Fantastic intro, thank you so much!

  • @olivierlasne2346
    @olivierlasne2346 4 месяца назад +1

    That's awesome content. Thanks a lot for the effort you put into this

  • @TechBuddy_
    @TechBuddy_ Год назад +6

    This is by far the best explanation of tokio, this is just fantastic. I love you man 💓

    • @dreamsofcode
      @dreamsofcode  Год назад +1

      Aww thanks! I'm glad you liked it!

  • @jeffreyefemena1082
    @jeffreyefemena1082 10 месяцев назад +1

    best explanation to tokio i've seen thank you

  • @irlshrek
    @irlshrek Год назад +3

    loving the rust content!

  • @programmingfunda8213
    @programmingfunda8213 Год назад +4

    thanks, keep motivating us towards rust

  • @anush8
    @anush8 Год назад +2

    Earned a sub man. Great video.

  • @foxcirc
    @foxcirc Год назад +5

    I prefer smol/async-executor. It is much more lightweight and compiles like 10x faster. The only issue is that there are less libraries written for it then there are for Tokio, but this has not been that big of a deal for me.

  • @jonforhan9196
    @jonforhan9196 Год назад +4

    Great video! I learned a lot!

    • @dreamsofcode
      @dreamsofcode  Год назад

      Thank you! I appreciate the feedback. I'm looking forward to doing some more async Rust content!

  • @a314
    @a314 Год назад +2

    Great content. Please do a video about structured concurrency in rust.

    • @dreamsofcode
      @dreamsofcode  Год назад +1

      I've added to the backlog!

    • @a314
      @a314 Год назад

      @@dreamsofcode awesome 🙂

  • @AyoDamilareMichael
    @AyoDamilareMichael 5 месяцев назад +1

    Your voice here is way better than the current one

    • @dreamsofcode
      @dreamsofcode  5 месяцев назад +1

      I'll rollback the firmware

  • @meka4996
    @meka4996 3 месяца назад +1

    Very nice. Thank you.

  • @nurmohammed9642
    @nurmohammed9642 Год назад +11

    Appreciate your hard work!
    Reading from file in async context does not boost performance, because OS generally does not provide async API,
    Tokio spawn a thread from thread pool to work with file.

    • @dreamsofcode
      @dreamsofcode  Год назад +4

      You're correct, it's no faster than reading from a file normally, but allows concurrency due to the use of the thread pool. Which can be somewhat quicker as it need not create a new thread to do so! But the file operation is the same.

    • @nurmohammed9642
      @nurmohammed9642 Год назад +2

      @@dreamsofcode quicker at coding, slower at runtime (I mean, what is the point of async, if it make your code slower) you can't mix async code with sync code... I like to call `spawn_blocking` on sync api...

    • @alexsyrotenko9981
      @alexsyrotenko9981 2 месяца назад

      It is possible with io_uring (if you're running Linux)

  • @utubercj
    @utubercj Месяц назад

    Fantastic tutorial

  • @JitenPalaparthi
    @JitenPalaparthi 8 месяцев назад +1

    Excellent stuff..

  • @MrKeebs
    @MrKeebs Год назад +3

    Incredible intro and channel. Have a sub! Thank you!

    • @dreamsofcode
      @dreamsofcode  Год назад +1

      Thank you! I'm glad you enjoyed the video.

  • @sndb6352
    @sndb6352 Год назад +12

    How did you made your terminal to this beautiful theme?

    • @dreamsofcode
      @dreamsofcode  Год назад +14

      Ahh thank you, I use tmux + neovim + catppuccin theme!

    • @sndb6352
      @sndb6352 Год назад +2

      In which web site you found this wallpaper?

  • @adewumisunkanmi5593
    @adewumisunkanmi5593 11 месяцев назад +1

    thanks for this

  • @motbus3
    @motbus3 8 месяцев назад +1

    2:20 if you build release mode, it seems it resolves it automatically

  • @saysthetedd
    @saysthetedd Месяц назад

    real good vid

  • @matthewb192
    @matthewb192 2 месяца назад

    The issues i have with c and c++ is the messy ecosystem and build systems. Rust seems to address both of these and tbh i don't find the code complex at all. I keep finding myself wondering when the hard part is going to appear.

  • @gosnooky
    @gosnooky Год назад +2

    Been starting at that code at 6:00, and I can't figure out how it sorts those strings.

    • @khalidbashir2037
      @khalidbashir2037 Месяц назад

      @@gosnooky it uses systems sort command to to sort the words

  • @learntry9074
    @learntry9074 Год назад +2

    Thank you

  • @justafreak15able
    @justafreak15able 5 месяцев назад +1

    Question: why rust doesn't have a std lib async runtime? Or is tokio better ?

  • @ryanleemartin7758
    @ryanleemartin7758 Год назад +1

    huh, I tokio just provided a way to do async/await. I didn't know it had channels and green threads as well.

  • @anonymmc2764
    @anonymmc2764 Год назад +4

    Great content! I have one question regarding the futures though: If the future is only executed once await is called (generally speaking) that implies we would lose some performance here, would it not? Let's say we have an async database call. If we were to execute the call right away it might have completed already once we await it. But since execution is lazy it's only executed once we await it. This might not be a huge problem since we can use our resources for something else while awaiting the database's response (due to the use of a thread pool) but it would still add to our overall latency, would it not? Or do I have a fundamental misunderstanding of lazy execution in this context?

    • @michaelaboah1322
      @michaelaboah1322 Год назад +1

      In the case that data is not ready for a future it goes into a PENDING state which will run a wake function when there is data available. Kinda like how u get mail when u hear the truck. Futures are designed to be incredibly efficient and zero cost

    • @discreaminant
      @discreaminant 10 месяцев назад +1

      No u r on the right track btw
      In this case you can use join! macro to do other job while awaiting the db operation
      let (res, _) = join!(ur_db_operation, async {
      // ur other job here
      });

  • @haliszekeriyaozkok4851
    @haliszekeriyaozkok4851 Год назад +43

    Tokio is not a framework, it is a runtime. There is huge difference between each other. Axum, rocket etc is frameworks and they depending on tokio runtime.

    • @SamuelSarette
      @SamuelSarette 10 месяцев назад

      The first two seconds the calls in a runtime. Haven't watched more to know if he slips up later, but yeah, you're right there's a difference

    • @minnow1337
      @minnow1337 10 месяцев назад +4

      t’s a runtime in the same way people call react a library. In practice I’d say both are practically frameworks

    • @rasibn
      @rasibn 5 месяцев назад

      It's literally a framework

  • @danielmontalvo1929
    @danielmontalvo1929 Год назад +3

    TOOOOKIOOOOOOOOO

  • @naive_algorithm
    @naive_algorithm Месяц назад

    In js async await makes functions synchronised, but in other languages it's opposite 😢😢😢😢
    Don't I understand asynchronous programming?

  • @pb8655
    @pb8655 Год назад +3

    someone tell me if and why this is an L take but shouldnt some of these features be in the std lib?

  • @metaltyphoon
    @metaltyphoon Год назад +2

    The fact that you have to use Tokio’s version of already implemented functionality on the std is really annoying.

  • @EhdrianEh
    @EhdrianEh Год назад

    This is great! Now, when to pin and unpin please :)

  • @justADeni
    @justADeni Год назад

    Reminds me a lot of Kotlin coroutines.

  • @spectator5144
    @spectator5144 Год назад +2

    beeg?

  • @cryptodavidw
    @cryptodavidw 6 месяцев назад

    at the same time != concurrently

  • @catmaxi2599
    @catmaxi2599 5 месяцев назад

    Everything is great until you have async traits lmao