Rust's Journey to Async/Await

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 พ.ย. 2024

ความคิดเห็น • 85

  • @PaulSebastianM
    @PaulSebastianM 5 ปีที่แล้ว +298

    The amount of information he kept in his head during this presentation... the flawless delivery... so coherent and easy to understand... great programmer! 😲

    • @andrewevans5750
      @andrewevans5750 5 ปีที่แล้ว +11

      this is basically a repeat of operating systems class without the creating an operating system and doing scheduling components

    • @Adam-cn5ib
      @Adam-cn5ib 5 ปีที่แล้ว +7

      It's a lot easier to keep track of the words & definitions if you understand the fundamental key concepts

    • @Seomon1
      @Seomon1 5 ปีที่แล้ว +5

      He just understands the concepts, It's easy to talk about things you understand. Presentations like people do them in school all the time, imo, is time efficient maybe but this is quality because he knows what he is talking about.

    • @pictureus
      @pictureus 4 ปีที่แล้ว +16

      @@Seomon1 Sure, but there are also a lot of people with knowledge that aren't that great of teachers.
      Tbh The Rust book is the best programming books I've encountered.. Not just "do this, this is the way" but it also covers why Rust does this; how does it work in the underlying operating system etc. So basically a CS class baked into the book itself and the whole book is a ELI5 kind of thing.
      Steve is a gift to the community!!

  • @gregfletcher2360
    @gregfletcher2360 5 ปีที่แล้ว +129

    We're lucky to have Steve in the Rust community. Such a great ambassador

    • @1173mrwan
      @1173mrwan 4 ปีที่แล้ว +6

      yupe, the guy talks with so much enthusiastic and excitement. it's so fun to watch.

  • @thingsiplay
    @thingsiplay 3 ปีที่แล้ว +17

    After watching/listening this talk, I appreciate even more the work of all those involved people have done to create programming languages.

  • @CliffordFajardo
    @CliffordFajardo 4 ปีที่แล้ว +30

    Really great talk. I highly appreciated how Steve was able to independently speak of so many topics, which chronologically tied to the story of how Rust got async await.
    Aside: I had been wanting to revisit topics like native vs green thread, sync/async blocking and non-blocking, io models and a lot of the topics he addressed on a per individual slide basis

  • @dovh49
    @dovh49 5 ปีที่แล้ว +30

    Correction. F# conceived of Async/Await first implemented with Computation Expressions. Computation Expressions are a general form of Async/Await which can make monadic code appear to be imperative programming style. C# first implemented Async/Await without computation expressions but later made them computation expressions but that made the Async/Await kind of awkward since it isn't always doing concurrent programming. Typically if someone in C# is using a computation expression outside of Async/Await they use the "from/in" style.

    • @dovh49
      @dovh49 5 ปีที่แล้ว +3

      See docs.microsoft.com/en-us/dotnet/fsharp/language-reference/computation-expressions

    • @Adam-cn5ib
      @Adam-cn5ib 5 ปีที่แล้ว +6

      Nobody cares about Microsoft languages

    • @dovh49
      @dovh49 5 ปีที่แล้ว +11

      @@Adam-cn5ib I love you too. You're a wonderful person with a strong and beautiful spirit.
      If you have the time to watch the video I highly recommend it. It was a great presentation!

    • @jimlynchcodes
      @jimlynchcodes 4 ปีที่แล้ว

      That's just making async code look synchronous. It doesn't use the glorious terminology "async" and "await". :D

    • @weluvmusicz
      @weluvmusicz 4 ปีที่แล้ว +1

      @@Adam-cn5ib I know you are a nobody! :)

  • @panstromek
    @panstromek 5 ปีที่แล้ว +49

    The `.await` syntax is actually pretty reasonable, I don't understand why no one has used it before in other languages. Chaining async code is often very awkward in javascript, because you need wrap await calls in parenthesis and order of operations switches from left to right side of expression and vice versa, often multiple times. And it's not like a minor issue that was not obvious from the start, it's something you hit after five minutes into async and deal with it every time you use it.

    • @defendliberty1289
      @defendliberty1289 4 ปีที่แล้ว +1

      .net (f#, c#) had that since a long time ago. The more primitive ideas have existed in GUI programming fir ages. None of this has been invented by the Javascript community as implied here. Most are recycled ideas with extra "syntax sugar".

    • @panstromek
      @panstromek 4 ปีที่แล้ว +5

      @@defendliberty1289 I didn't imply it was invented by javascript community and it wasn't even my point.

    • @iamrohandatta
      @iamrohandatta 4 ปีที่แล้ว +7

      First when I saw that `.await` syntax, I was so disappointed. But then, on a later slide, when he showed that chained await example, I just realised this is so brilliant!! Why haven't people used this elsewhere? Chaining of awaited values is a hell in js with parenthesis all around. Doing it this way is sooo fluid to write! I already love this `.await` without ever having written a single line of async rust yet! 😆

    • @deformercr6680
      @deformercr6680 3 ปีที่แล้ว

      to be fair though, if you want .await in JS, why no just use Promises?

    • @panstromek
      @panstromek 3 ปีที่แล้ว

      @@deformercr6680 Good point and I actually do that. I definitely use Promises directly more often than async/await syntax

  • @pseudo_goose
    @pseudo_goose 5 ปีที่แล้ว +96

    "1.38. For sure."
    _lands in 1.39_

  • @urisimchoni3936
    @urisimchoni3936 5 ปีที่แล้ว +17

    I'm so happy the rust folks went that way. There's also another aspect to the green vs native dilemma, which is system instrumentation tools (dtrace, linux uprobes, systemtap, ...). Often when you're doing some non-trivial instrumentation you're interested in pairing two events (e.g. entry into function A and entry into function B) based on the thread they happened on, and you can't do this with green threads because the OS thread is just a "carrier" for green threads.

  • @UberOcelot
    @UberOcelot 4 ปีที่แล้ว +4

    Such a great talk! It really exemplifies how Rust's approach to mature slowly, has allowed it to snowball fantastic world-class features by building upon also fantastic world-class features. Now anyone can empower themselves with highly correct, performant, and maintainable code. How would you get the wrinkles out of your home-rolled solution that will cause mysterious bugs in production on your own when it takes an whole community and researchers drawing on years of experience just to get something actually right. When you think about it, most of our programming languages were not design openly. The foundations were already laid before open contributions started flowing in. Or capricious standards bodies fossilized languages long before they should have been. In the end the Rust community really is it's killer feature.

  • @andrewevans5750
    @andrewevans5750 5 ปีที่แล้ว +7

    Wow, a green threads presentation without java, lol. Thanks, appreciate the history and information. Trying to use Rust to recreate Celery and even build a broker. Hoping to stick with Rust over Go. used to program a lot of Scala so the language feels similar with the exception of ownership and syntax of course ;)

  • @ChumX100
    @ChumX100 3 ปีที่แล้ว

    Always a pleasure to listen to Steve. Very entertaining! I'm happy that Rust was able to learn from other languages, managed to get through all those problems and eventually reached its current state. Goes to show what a healthy and open community can do.

  • @jimlynchcodes
    @jimlynchcodes 4 ปีที่แล้ว +5

    Wow. Few programming talks are so entertaining, informative, and inspiring! 🦀 ❤️

  • @slmjkdbtl
    @slmjkdbtl 5 ปีที่แล้ว +4

    I think that rust doc bug still exists today. Such a good talk

  • @anotherelvis
    @anotherelvis 5 ปีที่แล้ว +11

    Great talk

  • @krumbergify
    @krumbergify 4 ปีที่แล้ว +2

    Fantastic presentationen. Entertaining and packed with lots of knowledge.

  • @libra_x1
    @libra_x1 2 ปีที่แล้ว

    Timeless presentation, thank you.

  • @jercos
    @jercos 5 ปีที่แล้ว +2

    Apache's prefork MPM is so-called because it forks before connections arrive, relying on accept() to distribute among the processes. Not concurrent, but not fork-per-connection, as each process returns to handling connections. The distribution of connections is thus also parallel.

    • @kilburnsc
      @kilburnsc 5 ปีที่แล้ว

      Also, it is still used because there are several modules that are not thread-safe and hence cannot run under the other models (e.g.: mod_php)

  • @chenkaishao6002
    @chenkaishao6002 4 ปีที่แล้ว +1

    The definition block is helpful with understanding the big picture. That's what separates a good presenter from a bad professor.

  • @srcmake
    @srcmake 4 ปีที่แล้ว +2

    Amazing presentation!

  • @ksceriath8346
    @ksceriath8346 4 ปีที่แล้ว +4

    15:44 vs 17:38

  • @Luredreier
    @Luredreier 3 ปีที่แล้ว +1

    3:12
    Not entirely true although that hardly matters with regards to this talk.
    You can get instruction level parallelism.
    Especially if you do out of order execution.
    This means that you have a single core with specialized execution resources for various different tasks (more than just a touring complete core in other words) where all the resources are available for the core, but every individual step of a program doesn't necessarily require every resource in the core, so you allow the core to start other tasks before the previous ones are done.
    It could be different pipeline stages, so getting data from memory and figuring out what exactly the instruction is could be one task, then actually making a calculation is one and the next instructions data can be fetched and prepared while the first one is going through the actual math/logic then finishing up the task could be a last stage.
    If you also have out of order execution rather than just a superscalar one you could also have a instruction queue and look at it to see if any of the instructions in it can be executed simultaneously.
    Say if you both have two fixed numbers that have to be added together but also a logical evaluation like if this number is bigger then that number return true or whatever and a third instruction say multiplying two floating point numbers the those three could potentially be done at the same time if they don't have any dependencies like any numbers required for those instructions potentially being changed by earlier instructions, that way you can have one queue where you both have the instructions that's about to be executed in a queue and you can have the finished results of them stored in a queue too and the processor will only do whatever it needs to do with the finished result when all the previous instructions have been executed and that final one is placed in the right order.
    But its actual *execution* doesn't have to be done in order, one by one.
    So that way you can get the code executed faster and it won't matter as much that you have more specialized resources then what each individual instruction can use since the out of order execution ensures that the resources are actually used.
    You can also have multiple threads with limited extra resources allowing the second thread to make use of whatever resources the first one doesn't use etc.

  • @giaphatha88
    @giaphatha88 3 ปีที่แล้ว

    super comprehensive talk!

  • @cherubin7th
    @cherubin7th 3 ปีที่แล้ว +2

    I don't want to use Rust anymore, because of async. I tried to avoid it, but it seems to become more and more common with crates. Why can't I just disable it, or tell the program that it should just block like on normal functions, or do something like .not_await

  • @willian_z
    @willian_z 5 ปีที่แล้ว +5

    14:46
    "If you see this module it says the same thing two times. I don't know."

  • @austecon6818
    @austecon6818 3 ปีที่แล้ว

    Great talk. Wow. Thank you. Learned so much from this.

  • @darkenblade986
    @darkenblade986 2 ปีที่แล้ว

    awesome talk.

  • @chrisf1600
    @chrisf1600 5 ปีที่แล้ว +3

    I'm confused by the definition of concurrency in the introduction. @3:21, the slide actually seems to be talking about time-slicing, not concurrency. Concurrent = "running with", from the Latin, ie multiple tasks "running with" one another. MIT agrees : web.mit.edu/6.005/www/fa14/classes/17-concurrency/. Am I missing something ?

    • @guibirow
      @guibirow 4 ปีที่แล้ว

      In simple terms:
      Parallel = run at the same time with own resources
      Concurrent = compete for resources
      Asynchronous = use of the resources effectively.
      The concurrent example demonstrates two tasks competing for CPU time.
      A parallel code will run in parallel until they start to compete for resources(e.g: CPU Time, Memory). When there are more tasks than the amount of resources to serve these tasks, they start compete for these resources and run concurrently even though they started in parallel. This is the main reason async is required, to make good use of these resources.

  • @abdulhamitkumru
    @abdulhamitkumru 3 ปีที่แล้ว

    great presentation

  • @JeremyChone
    @JeremyChone 3 ปีที่แล้ว

    Impressive talk.

  • @bilbobaggins2102
    @bilbobaggins2102 5 ปีที่แล้ว +1

    Nice! very informative.

  • @davidboreham
    @davidboreham 2 ปีที่แล้ว

    Good to hear about the c10k doc this century! I was mentioned as a contributor in the original version but it appears Dan deleted my part :( Good times.

  • @harambeexpress
    @harambeexpress 4 ปีที่แล้ว +3

    I dropped my last project in Rust because I was spoiled from using async/await in Python. Rust is definitely back on the menu.

  • @wk02
    @wk02 5 ปีที่แล้ว

    Awesome presentation!

  • @emvdl
    @emvdl 3 ปีที่แล้ว

    Thank you!

  • @friedrichdergroe9664
    @friedrichdergroe9664 4 ปีที่แล้ว

    Nice presentation. Talk about juggling a bazillion considerations amidst tip-toing through a minefield...!

  • @simonstrandgaard5503
    @simonstrandgaard5503 3 ปีที่แล้ว

    Well explained. Thank you.

  • @paulojorgediasyt
    @paulojorgediasyt 4 ปีที่แล้ว +2

    Awesome presentation! Many thanks Steve.

  • @pm71241
    @pm71241 3 ปีที่แล้ว

    Futures and Promises are great .... but having tried to decipher a python Twisted stacktrace more than once, I approach them with caution :)

  • @friohao5398
    @friohao5398 4 ปีที่แล้ว +1

    Maybe the system kernel itself should be changed to the green threads?

    • @alexgorodecky1661
      @alexgorodecky1661 4 ปีที่แล้ว

      Frio Hao, totally. Async/await not general purpose lang feature. Just CS community madness! But it will be fixed

  • @jcbritobr
    @jcbritobr 5 ปีที่แล้ว +3

    I think someone needs to create some sample codes ASAP, because there are no examples in the internet about async/await. I still don't know how to use them.

  • @Textras
    @Textras 4 ปีที่แล้ว

    Very good talk.

  • @GrigorySapunov
    @GrigorySapunov 4 ปีที่แล้ว

    Thanks! Cool talk!!!

  • @sociocritical
    @sociocritical 5 ปีที่แล้ว

    Isn't select() blocking asynchronos io in a way since it's blocking but it can react to multiple different events?

    • @krumbergify
      @krumbergify 4 ปีที่แล้ว +1

      Yes, its blocking but not async unless you use it to invoke a custom callback supplied by the user.

  • @edgeeffect
    @edgeeffect 2 ปีที่แล้ว

    Nobody ever seems to explain why Green Threads are "Green".

  • @akshatagarwal1631
    @akshatagarwal1631 4 ปีที่แล้ว +2

    Steve looks like 24 and 37 at the same time

  • @alexgorodecky1661
    @alexgorodecky1661 4 ปีที่แล้ว

    "Green threads is slower when calling C code"? For what?

    • @TheFuryal2
      @TheFuryal2 4 ปีที่แล้ว +2

      calling C code, duh

    • @guibirow
      @guibirow 4 ปีที่แล้ว +2

      Probably is related to context switching between a green thread and an actual thread that will probably require some synchronization

    • @itellyouforfree7238
      @itellyouforfree7238 3 ปีที่แล้ว +5

      @@guibirow no, he even explained it. it has to do with the fact that green threads don't use a C-compatible stack, therefore when you do an extern call to C you have to first set up a fake stack that the C ABI expects

  • @driziiD
    @driziiD 4 ปีที่แล้ว

    if golang is synchronous/non-blocking why the `go` keyword ?

  • @qianqian888
    @qianqian888 5 ปีที่แล้ว +2

    mark

  •  5 ปีที่แล้ว +1

    I find the blocking/non-blocking explanation a bit non-intuitive. Blocking is usually used in terms of GUI where its clear that application is blocked/frozen. In backend world it means that you've basically put the thread to sleep and are wasting resources but you have not blocked anything from outside point of view. I wonder if there is a better expression?
    Edit: still a great talk

    • @victorsavu7724
      @victorsavu7724 4 ปีที่แล้ว

      Hi ! I used to do a bit of GUI programming a while back and I have a feeling that I might see where you're coming from. However, since intuition is quite personal (and elusive), I don't know how best to help. I thought I'd write some things that you might know even better than I do in a way that feels intuitive to me in the hope that it helps you build your own intuitive explanation.
      The problem with blocking in GUIs comes up in single threaded GUI frameworks (which most of them are; especially on mobile). It usually refers to blocking the GUI thread which handles most of the I/O (user input and graphical output), which is bad because then the screen does not get updated and the user cannot interact with the app and the world explodes. On the backend, the I/O is usually some network or socket read/write operation and, by contrast to GUI operations, any OS thread can handle them. So even if one thread is *blocked* waiting on some response from a database while a web client tries to connect, it is reasonable to believe that there is another thread available that is not blocked and which can begin serving that client. And if there isn't we just spin up a new thread and keep the client happy. As you said, up to now, nothing looks blocked from the outside point of view. The problem starts when the server has to deal with a high frequency of client requests (think in the order of 10,000 requests per second). In that case, when a client request comes in, there may already be 10,000 threads already blocked serving other clients and the program may not be able to spin another thread because it would run out of memory. The client request would need to be rejected and this is where the "blocking" gets to be see from the outside point of view: the browser "hangs", the user cannot browse the website and the world explodes. The "blocking" on the backend would manifest as the inability to serve client requests, which, if I think about it, is not that different from the definition of "blocking" in the frontend :)
      Sorry for the verbose answer and for only saying things you most likely already knew. If this helped or offered some kind of perspective, I'd love to hear the intuitive explanation you arrived at on this topic. Cheers!

  • @kwang7225
    @kwang7225 5 ปีที่แล้ว +7

    I still favor the golang model.

    • @recklessroges
      @recklessroges 4 ปีที่แล้ว +2

      Which is find until the golang garbage collector comes and bites you.

    • @biskitpagla
      @biskitpagla 2 ปีที่แล้ว

      same here. at least rust lets you choose your poison. hopefully the rust world will never see something like node's colored function fiasco.

  • @WorstDeveloper
    @WorstDeveloper 4 ปีที่แล้ว +3

    The Rust async ecosystem is a mess of incompatible forced runtimes. You no longer pick a library because it's good, you pick it because it supports your currently used runtime. And if there's no library for your runtime, you're f***ed. Crates even specify their runtime in their name, such as "tokio_tungstenite". This is ridiculous. I've never seen a more broken, badly thought out async/await implementation.

  • @tingfeifu6539
    @tingfeifu6539 3 ปีที่แล้ว

    语速真快呀

  • @danielboutrin7719
    @danielboutrin7719 3 ปีที่แล้ว

    boring , someone ignoring supercomputer rebranding part of working stuff into a new stuff
    Blocking/Async allow to check the data coming but are not processed until all check are done. Instead of blocing , check and then process

  • @hank-uh1zq
    @hank-uh1zq 3 ปีที่แล้ว

    Promises, futures were in the literature long before the millennial giving the presentation could do his alphabet lessons.

  • @Badmarble24
    @Badmarble24 4 ปีที่แล้ว

    He's wrong about concurrency. You can do multiple things at the same time even on a single core CPU, e.g. using the processor, and writing to stdout is possible, in parallel using a concurrent approach (such as what go has)

  • @tobateksingh4933
    @tobateksingh4933 4 ปีที่แล้ว

    Detail video in Hindi

    • @joonasfi
      @joonasfi 4 ปีที่แล้ว

      Popcorn make with butter

  • @FeelingShred
    @FeelingShred 4 ปีที่แล้ว

    Rust being created by Mozilla makes me skeptical of it. Firefox has HORRID performance, and this has been a problem for YEARS now. To be perfectly clear: Chromium runs just fine on my 1.20 GHz laptop. Firefox did NOT. (even on Linux) What makes them think they will be able to create the ultimate programming language when they weren't even able to fix their flagship product? Sorry for the cynicism but I think we're all fucking tired of snake oil salesmen out there.

  • @karelhrkal8753
    @karelhrkal8753 2 ปีที่แล้ว

    43:50 yea that syntax definitely looks weird. You would be expecting .await()? instead, but this way, in emphatises that it is not a function, so I think it works fine. Also BIG PLUS that you can put it at the end, it really makes long chains better:
    a.b().await?.c().d().await()?.e
    is much better than
    (await(await (a.b())?.c().d())?.e