Async vs Multithreading

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ • 118

  • @SiddheshPardeshi-mp9cr
    @SiddheshPardeshi-mp9cr 3 дні тому +162

    new intro format is dope btw

  • @mojojojo890
    @mojojojo890 3 дні тому +98

    5:37 "This is not Rust, this is actually a good language"

  • @mawaldne
    @mawaldne 3 дні тому +65

    “If you want to have some things, you have to develop them yourself, like a real programmer” - zozin

  • @dusliangames
    @dusliangames 3 дні тому +69

    It could be funny to change the ipv6 address in the bottom to "fe80::dead:beef:cafe:6969", it's a valid address. and nice easter egg.

    • @swordoman2158
      @swordoman2158 3 дні тому +6

      It'd be valid with the fd00:: prefix but yeah

    • @dusliangames
      @dusliangames 3 дні тому

      @@swordoman2158 fe80 is a valid prefix

    • @dusliangames
      @dusliangames 3 дні тому

      @@swordoman2158 fe80 is a valid prefix

    • @stefanalecu9532
      @stefanalecu9532 2 дні тому +3

      ​@@swordoman2158 I believe fe80 would be valid too as that's a link-local address, like having 192.168.1.20 in your bar. It just has to be a valid address, not an useful one

    • @swordoman2158
      @swordoman2158 2 дні тому +1

      @@stefanalecu9532 You're almost right. In IPv6, link-local addresses are configured automatically with a special algorithm that uses interface's MAC address. There are also "unique local addresses" in IPv6 that can be anything you want and they have the fd00 prefix. The only difference between them I know is that unique local addresses can be routed

  • @mbarrio
    @mbarrio 3 дні тому +26

    Good stream, I'd love to see epoll or iouring implemented. That cpu core doing a lot of nothing bugs me out.

  • @the.monologue
    @the.monologue 3 дні тому +25

    "Streamed Offline" glorious humour

  • @andymora48
    @andymora48 2 дні тому +5

    То чувство когда русский прогер слушает русского прогера на английском. Но твой английский единственный который я выкупаю без субтитров❤

    • @27182818284590452354
      @27182818284590452354 День тому

      Иногда и забываю, что он на аглицком говорит, мысли-то очень родные.

  • @pseudo_flame5424
    @pseudo_flame5424 3 дні тому +17

    Another master class by Mr Azozin

  • @iglobrothers645
    @iglobrothers645 3 дні тому +10

    Twitch chat gone for once and Mr Azozin is hyper focused and doesn't even meme around once

  • @aidennwitz
    @aidennwitz 3 дні тому +38

    c3fut stands for c3futanari in my head

  • @MarioMakesSftwr
    @MarioMakesSftwr 2 дні тому +2

    love the "2 hours earlier" clip you've been doing

  • @calapp
    @calapp 7 годин тому

    Very nice! Next steps could be to use a multi-threaded async approach to get the best of both worlds, also (you already mentioned it) putting the thread/task to sleep instead of spinning. Also why that hate on Rust? I know you appreciate simplicity but the tooling and expressiveness are unmatched imo. Again very nice video! Hope to see more of these! Thank you.

  • @danielvanderstelt
    @danielvanderstelt 3 дні тому +2

    Tsodin thinking about how to design the future ...
    Talk about where this channel has elevated to ...

  • @jdeleca
    @jdeleca 3 дні тому +2

    Really cool to learn how the async thing really work

  • @q_rsqrt5140
    @q_rsqrt5140 2 дні тому +1

    Thanks for final motivation to learn C++ coroutines by implementing similar simple async echo server

  • @anon_y_mousse
    @anon_y_mousse 3 дні тому +2

    I miss the good ol' days of BASIC where you could just add a line at the top like `on error goto 935` and put your error handling code there. Not to mention the chat comments as caption data, which I hope maybe I was just too early. Also, I prefer wood blocks and hash tables rather than two lists. I'm not sure why you'd avoid a hash map, but if the implementation in C3 sucks then why not write your own.
    Perhaps worth mentioning, what I came up with in my own language with regards to inheritance and structs is that you could just place the typename for another structured object within your own struct, and it'll include it right there, sort of like anonymous structs in C, except that you can predefine it. For instance: struct Foo { ... }; ... struct Bar { Foo; ... }; The advantage being that you can place the inner struct anywhere within that you want.
    That said, can you use interfaces in C3 to do similar inheritance shenanigans?

    • @eliashaider6857
      @eliashaider6857 3 дні тому

      He mentioned several times that the list swapping doesn't change anything about the lifetime management compared to hashmap or other data structures.
      As for inheritance and gotos... Keep cookin', buddy - just don't mix your soup with mine ;)

    • @anon_y_mousse
      @anon_y_mousse 2 дні тому

      @@eliashaider6857 Yeah, my concern wasn't about lifetime management but speed and memory use. Two lists would likely use as much memory, if that's even a concern for anyone these days and would scale horribly in terms of speed as more connections were made.

    • @luvzware
      @luvzware День тому

      @@anon_y_mousseinheritance… speed… seems about right

    • @anon_y_mousse
      @anon_y_mousse День тому

      @@luvzware What are you talking about?

  • @2udo
    @2udo 17 годин тому

    Have you ever considered switching to a dynamic window manager?

  • @danielvanderstelt
    @danielvanderstelt 3 дні тому +2

    I spend 3 hours debugging the Future and in the end I was just missing a different lifetime ...

  • @berndeckenfels
    @berndeckenfels 3 дні тому

    The tcp listen queue (backlog) is not specific to async, btw

  • @victordvickie
    @victordvickie 3 дні тому

    Would also love to learn about what is actor model, channels, and more related to async.❤

  • @ukrmapper
    @ukrmapper 2 дні тому

    5:27 "Like in Rust, but this is not Rust, this is actually good programming language" 🤣🤣

  • @nunomiguel8498
    @nunomiguel8498 3 дні тому +14

    tutorial on how to lose weight pls

    • @ryzh6544
      @ryzh6544 3 дні тому +15

      Move more, eat less. 🥲

    • @mikadofxx9030
      @mikadofxx9030 3 дні тому

      ​@@ryzh6544hydrate with water

    • @y00t00b3r
      @y00t00b3r 3 дні тому +5

      @@ryzh6544 > Move more, eat less.
      no. Learn about the insulin response.

    • @ryzh6544
      @ryzh6544 3 дні тому +1

      @@y00t00b3r ok, so the other way is to get addicted to drugs

    • @ArefShafaa
      @ArefShafaa 3 дні тому +1

      @@y00t00b3r can your mRNA dooo thaaat?!

  • @multicoloredwiz
    @multicoloredwiz 3 дні тому +2

    Looks like we're dead :(

  • @vasilnikolov8576
    @vasilnikolov8576 3 дні тому +2

    Hi Mr Tsoding,
    I see you always code with no autocomplete&lsp, which is a big shock for me. I've used vim and the likes for a long time, and getting autocomplete to work has always been a top priority, before even starting to work on a project. However, it seems there is some merit to not using it. Can you give some tips on how to try, and why you're doing it. To an LSP fan, it seems both liberating, and relying too much on the external documentation.

    • @SlinkyD
      @SlinkyD 3 дні тому +2

      ctags or cscope & key combos.

    • @LeaoMartelo
      @LeaoMartelo 3 дні тому +1

      It mostly comes down to knowing the libraries you're working with and typing properly (I suck specially at long function names)

    • @4hnme
      @4hnme 2 дні тому +1

      LSPs are distracting, not using one makes you focus on your code more - that's the whole merit. you can have dumb autocomplete without language servers, though it won't be useful most of the time.
      if you wanna try going old-school and ditching everything besides syntax highlighting, then just go for - it will be tough at first, but the more you do it, the less you will be reliant on external tooling when writing code. i can't say whether it will make you more productive, but changing your habits is at least a good exercise for brain flexibility

  • @Kknewkles
    @Kknewkles 3 дні тому +1

    Was this the one where Jon raided the stream?

    • @senkrouf
      @senkrouf 3 дні тому

      idk but I was there CHROOTing alone

  • @cubodix
    @cubodix 3 дні тому +2

    i lose track of time looking at this

    • @cubodix
      @cubodix 3 дні тому

      c3 looks nice

  • @asg8813
    @asg8813 3 дні тому

    How does our program know that the task is completed? Does it use a different thread for it internally?

    • @yusuf.isyaku
      @yusuf.isyaku 3 дні тому

      If i understand you well you mean the server? Servers are meant to run forever unless you stop it manually or it crashes.

  • @GreyDeathVaccine
    @GreyDeathVaccine День тому

    New lang called C3? But I haven't learned Rust and Zig yet. :D

  • @beyondcatastrophe_
    @beyondcatastrophe_ 3 дні тому

    Your `client_async_write_everything` doesn't write everything, it just tries to write a bit, modifies `client.i` as if to resume, but since you do that only once, that does nothing, you need a nested `fut::forever` to drain the buffer before reading more

  • @coffee-is-power
    @coffee-is-power День тому

    c3fut is basically tokio for C3

  • @TsvetanDimitrov1976
    @TsvetanDimitrov1976 3 дні тому +1

    Why not using a threadpool and having the best of both worlds? Maybe something like tbb.

  • @at0m_cyb3r
    @at0m_cyb3r 3 дні тому

    Please do more of the Olive.c episodes

  • @tzorake
    @tzorake 3 дні тому

    Thank you!

  • @dnkreative
    @dnkreative 3 дні тому

    It's called cooperative multitasking

  • @steelrazor4782
    @steelrazor4782 3 дні тому

    o7 Tsoding caved to using the project.json

  • @RudyRdx
    @RudyRdx 3 дні тому

    Now this video is cool

  • @ronakmehta8106
    @ronakmehta8106 2 дні тому

    Any are you ok ? are you okay any ?

  • @joseoncrack
    @joseoncrack 3 дні тому

    Ok, you've become a C3 addict.😅

  • @lettever801
    @lettever801 3 дні тому +4

    no "Look's like we're live"? unwatchable

    • @wheezard
      @wheezard 3 дні тому +2

      it's not a vod, he just recorded this vid by himself

    • @nel_tu_
      @nel_tu_ 3 дні тому +3

      ​@@wheezardit's not serious, he just made a joke

  • @Rhyrkon
    @Rhyrkon 3 дні тому

    Lets go!

  • @azharalibhutto1209
    @azharalibhutto1209 3 дні тому

    Great ❤❤❤

  • @roycohen.
    @roycohen. День тому

    bro i'm a fake programmer. litearlly not gonna make it at this rate

  • @bity-bite
    @bity-bite 3 дні тому +4

    Why not use an actual IDE or editor instead of having to compile your code every so often to check for stuff like syntax errors?

    • @nnkbrain
      @nnkbrain 3 дні тому +4

      I think there is no powerful editor or IDE tgan emacs. He just didn't configure LSP.

    • @ryzh6544
      @ryzh6544 3 дні тому +10

      It's called compiler driven development

    • @lolcat69
      @lolcat69 3 дні тому +5

      Why tho? What's the point of knowing always the errors in your code so you can fix them, if the compiler will just tell you those errors at compiled time? Lol

    • @bity-bite
      @bity-bite 3 дні тому +2

      @@lolcat69 Fixing silly semicolon and typo errors the moment they happen and not having to fix 100s of them at once. You know, saving time?

    • @FryAndLeelaAndBender
      @FryAndLeelaAndBender 3 дні тому +3

      Because real programmers do it this way...

  • @David-ng9qh
    @David-ng9qh 3 дні тому

    build system with json, yikes

  • @caddr
    @caddr 3 дні тому +1

    zozin pog

  • @pagenotfound_code_404
    @pagenotfound_code_404 3 дні тому

    wouldn't it be more appropriate to title this "Processes vs Multithreading"?

    • @Israel220500
      @Israel220500 3 дні тому +5

      No. He is developing futures which are even more lightweight than OS threads. Processes are threads with their own memory space.

    • @pagenotfound_code_404
      @pagenotfound_code_404 3 дні тому

      ​@@Israel220500 huh.. how is it implemented then? i guess i should watch the full stream to find out

    • @Israel220500
      @Israel220500 3 дні тому +3

      ​@@pagenotfound_code_404Single threaded event loop, like in JavaScript

  • @tdiblik
    @tdiblik 2 дні тому +1

    "the borrow checker would have solved that, am i right" good one, but it would also make the video 10h and burned your laptop in the process xd

  • @waxlbloh6450
    @waxlbloh6450 3 дні тому

    why would you want to not create threads you poor cpu works so hard to extract some paralellism from your code why do you make its life harder

    • @RudyRdx
      @RudyRdx 3 дні тому +4

      my 4 core raspberry pi02 with 512 mb ram begs for forgiveness

    • @waxlbloh6450
      @waxlbloh6450 3 дні тому

      @RudyRdx what ram does a thread even use other than a lazily allocated stack

    • @beyondcatastrophe_
      @beyondcatastrophe_ 3 дні тому +13

      @@waxlbloh6450 While RAM is some concern, the bigger concern is the threads themselves. The CPU can only have a little true parallelism, on a PI that is 4 threads. As Tsoding mentioned in the video, you want to handle many clients, so the hardware is not enough for this, the OS needs to handle that. This is called scheduling. The expensive part here is switching between threads, a context switch is very heavy, which is why calling syscalls should not be done too often. Keeping everything in one threads minimizes the number of context switches, especially when you don't actually need the CPU (as Tsoding also mentions, the server does not do any work, it barely needs CPU time, so why pay for the context switch)

    • @kibels894
      @kibels894 3 дні тому +6

      Once you have futures you can have a thread pool or additional processes to poll them on all CPU cores. This is just the first step. Thousands of threads is never good though.

    • @FryAndLeelaAndBender
      @FryAndLeelaAndBender 3 дні тому +3

      How many pure hardware threads do you think you can pull from your CPU?? Think about that...