Async vs Multithreading

  Рет қаралды 37,020

Tsoding Daily

Tsoding Daily

Күн бұрын

Пікірлер: 140
@SiddheshPardeshi-mp9cr
@SiddheshPardeshi-mp9cr 18 күн бұрын
new intro format is dope btw
@Digitalgems9000
@Digitalgems9000 12 күн бұрын
heck yea it is
@mawaldne
@mawaldne 18 күн бұрын
“If you want to have some things, you have to develop them yourself, like a real programmer” - zozin
@mojojojo890
@mojojojo890 18 күн бұрын
5:37 "This is not Rust, this is actually a good language"
@RustIsWinning
@RustIsWinning 18 күн бұрын
How could he do this to me 😭
@stefanalecu9532
@stefanalecu9532 17 күн бұрын
​@@RustIsWinning womp womp
@ukrmapper
@ukrmapper 17 күн бұрын
i have laughed a lot
@Digitalgems9000
@Digitalgems9000 12 күн бұрын
haha
@Pale_ghost
@Pale_ghost 9 күн бұрын
@@RustIsWinning profile pic is a trap, rust developer 100%
@the.monologue
@the.monologue 18 күн бұрын
"Streamed Offline" glorious humour
@dusliangames
@dusliangames 18 күн бұрын
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 18 күн бұрын
It'd be valid with the fd00:: prefix but yeah
@dusliangames
@dusliangames 18 күн бұрын
@@swordoman2158 fe80 is a valid prefix
@dusliangames
@dusliangames 18 күн бұрын
@@swordoman2158 fe80 is a valid prefix
@stefanalecu9532
@stefanalecu9532 17 күн бұрын
​@@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 17 күн бұрын
@@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
@iglobrothers645
@iglobrothers645 18 күн бұрын
Twitch chat gone for once and Mr Azozin is hyper focused and doesn't even meme around once
@RicardoValero95
@RicardoValero95 11 күн бұрын
Great video! It was clear, practical, no bs, and super insightful. Loved it!
@pseudo_flame5424
@pseudo_flame5424 18 күн бұрын
Another master class by Mr Azozin
@mbarrio
@mbarrio 18 күн бұрын
Good stream, I'd love to see epoll or iouring implemented. That cpu core doing a lot of nothing bugs me out.
@TsodingDaily
@TsodingDaily 18 күн бұрын
On my todo list :)
@brianl2607
@brianl2607 16 күн бұрын
@1:38:00
@andymora48
@andymora48 17 күн бұрын
То чувство когда русский прогер слушает русского прогера на английском. Но твой английский единственный который я выкупаю без субтитров❤
@27182818284590452354
@27182818284590452354 16 күн бұрын
Иногда и забываю, что он на аглицком говорит, мысли-то очень родные.
@MarioMakesSftwr
@MarioMakesSftwr 18 күн бұрын
love the "2 hours earlier" clip you've been doing
@jdeleca
@jdeleca 18 күн бұрын
Really cool to learn how the async thing really work
@danielvanderstelt
@danielvanderstelt 18 күн бұрын
Tsodin thinking about how to design the future ... Talk about where this channel has elevated to ...
@JeremyW-r3o
@JeremyW-r3o 14 күн бұрын
Should look at this in elixir. Async is nice, but it pushes towards a monolith design, and doesn’t solve many problems such as isolation of errors / fault tolerance and recovery. Threading doesn’t do that either necessarily and generally I avoid multithreading. The problem is multi-processing in environments like C are extremely expensive.
@aidennwitz
@aidennwitz 18 күн бұрын
c3fut stands for c3futanari in my head
@sergiuap9837
@sergiuap9837 18 күн бұрын
a man of culture
@Momoyon
@Momoyon 17 күн бұрын
Hell yea
@q_rsqrt5140
@q_rsqrt5140 18 күн бұрын
Thanks for final motivation to learn C++ coroutines by implementing similar simple async echo server
@calapp
@calapp 15 күн бұрын
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.
@ukrmapper
@ukrmapper 17 күн бұрын
5:27 "Like in Rust, but this is not Rust, this is actually good programming language" 🤣🤣
@filevich
@filevich 9 күн бұрын
0:20 "let's kill this shit" 😂😂😂
@danielvanderstelt
@danielvanderstelt 18 күн бұрын
I spend 3 hours debugging the Future and in the end I was just missing a different lifetime ...
@evilPutty69420
@evilPutty69420 17 күн бұрын
this sounds like my real life
@anon_y_mousse
@anon_y_mousse 18 күн бұрын
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 18 күн бұрын
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 18 күн бұрын
@@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 16 күн бұрын
@@anon_y_mousseinheritance… speed… seems about right
@anon_y_mousse
@anon_y_mousse 16 күн бұрын
@@luvzware What are you talking about?
@XFlugtier
@XFlugtier 6 күн бұрын
At work, I once spent two whole days troubleshooting, only to discover it was just a missing semicolon in a frustrating scripting language. At that time, it didn’t give me an error to point that out. Am I an impostor? D:
@berndeckenfels
@berndeckenfels 18 күн бұрын
The tcp listen queue (backlog) is not specific to async, btw
@victordvickie
@victordvickie 18 күн бұрын
Would also love to learn about what is actor model, channels, and more related to async.❤
@multicoloredwiz
@multicoloredwiz 18 күн бұрын
Looks like we're dead :(
@beyondcatastrophe_
@beyondcatastrophe_ 18 күн бұрын
~~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~~ Edit: Misread the future, my bad
@tzorake
@tzorake 18 күн бұрын
Thank you!
@vasilnikolov8576
@vasilnikolov8576 18 күн бұрын
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 18 күн бұрын
ctags or cscope & key combos.
@LeaoMartelo
@LeaoMartelo 18 күн бұрын
It mostly comes down to knowing the libraries you're working with and typing properly (I suck specially at long function names)
@4hnme
@4hnme 17 күн бұрын
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
@cubodix
@cubodix 18 күн бұрын
i lose track of time looking at this
@cubodix
@cubodix 18 күн бұрын
c3 looks nice
@2udo
@2udo 16 күн бұрын
Have you ever considered switching to a dynamic window manager?
@theevilcottonball
@theevilcottonball 11 күн бұрын
Nah static is better.
@2udo
@2udo 6 күн бұрын
@@theevilcottonball dwm > i3
@Kknewkles
@Kknewkles 18 күн бұрын
Was this the one where Jon raided the stream?
@senkrouf
@senkrouf 18 күн бұрын
idk but I was there CHROOTing alone
@TsvetanDimitrov1976
@TsvetanDimitrov1976 18 күн бұрын
Why not using a threadpool and having the best of both worlds? Maybe something like tbb.
@coffee-is-power
@coffee-is-power 16 күн бұрын
c3fut is basically tokio for C3
@asg8813
@asg8813 18 күн бұрын
How does our program know that the task is completed? Does it use a different thread for it internally?
@yusuf.isyaku
@yusuf.isyaku 18 күн бұрын
If i understand you well you mean the server? Servers are meant to run forever unless you stop it manually or it crashes.
@dnkreative
@dnkreative 18 күн бұрын
It's called cooperative multitasking
@at0m_cyb3r
@at0m_cyb3r 18 күн бұрын
Please do more of the Olive.c episodes
@nunomiguel8498
@nunomiguel8498 18 күн бұрын
tutorial on how to lose weight pls
@ryzh6544
@ryzh6544 18 күн бұрын
Move more, eat less. 🥲
@mikadofxx9030
@mikadofxx9030 18 күн бұрын
​@@ryzh6544hydrate with water
@y00t00b3r
@y00t00b3r 18 күн бұрын
@@ryzh6544 > Move more, eat less. no. Learn about the insulin response.
@ryzh6544
@ryzh6544 18 күн бұрын
@@y00t00b3r ok, so the other way is to get addicted to drugs
@ArefShafaa
@ArefShafaa 18 күн бұрын
@@y00t00b3r can your mRNA dooo thaaat?!
@steelrazor4782
@steelrazor4782 18 күн бұрын
o7 Tsoding caved to using the project.json
@azharalibhutto1209
@azharalibhutto1209 18 күн бұрын
Great ❤❤❤
@joseoncrack
@joseoncrack 18 күн бұрын
Ok, you've become a C3 addict.😅
@GreyDeathVaccine
@GreyDeathVaccine 16 күн бұрын
New lang called C3? But I haven't learned Rust and Zig yet. :D
@theevilcottonball
@theevilcottonball 11 күн бұрын
Just use ALGOL-W. Don't buy into the hype.
@RudyRdx
@RudyRdx 18 күн бұрын
Now this video is cool
@ronakmehta8106
@ronakmehta8106 17 күн бұрын
Any are you ok ? are you okay any ?
@sciencedaemon
@sciencedaemon 6 күн бұрын
No idea why you bother with all that telnet, async, etc. here. One can easily mess with NREPL and related in Clojure and be miles ahead (or Babashka doing similar).
@Rhyrkon
@Rhyrkon 18 күн бұрын
Lets go!
@lettever801
@lettever801 18 күн бұрын
no "Look's like we're live"? unwatchable
@wheezard
@wheezard 18 күн бұрын
it's not a vod, he just recorded this vid by himself
@nel_tu_
@nel_tu_ 18 күн бұрын
​@@wheezardit's not serious, he just made a joke
@weekipi5813
@weekipi5813 12 күн бұрын
2:09:00 he thought he was live "chat chat i must show u" 😂
@roycohen.
@roycohen. 16 күн бұрын
bro i'm a fake programmer. litearlly not gonna make it at this rate
@caddr
@caddr 18 күн бұрын
zozin pog
@bity-bite
@bity-bite 18 күн бұрын
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 18 күн бұрын
I think there is no powerful editor or IDE tgan emacs. He just didn't configure LSP.
@ryzh6544
@ryzh6544 18 күн бұрын
It's called compiler driven development
@lolcat69
@lolcat69 18 күн бұрын
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 18 күн бұрын
@@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 18 күн бұрын
Because real programmers do it this way...
@David-ng9qh
@David-ng9qh 18 күн бұрын
build system with json, yikes
@pagenotfound_code_404
@pagenotfound_code_404 18 күн бұрын
wouldn't it be more appropriate to title this "Processes vs Multithreading"?
@Israel220500
@Israel220500 18 күн бұрын
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 18 күн бұрын
​@@Israel220500 huh.. how is it implemented then? i guess i should watch the full stream to find out
@Israel220500
@Israel220500 18 күн бұрын
​@@pagenotfound_code_404Single threaded event loop, like in JavaScript
@tdiblik
@tdiblik 18 күн бұрын
"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 18 күн бұрын
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 18 күн бұрын
my 4 core raspberry pi02 with 512 mb ram begs for forgiveness
@waxlbloh6450
@waxlbloh6450 18 күн бұрын
@RudyRdx what ram does a thread even use other than a lazily allocated stack
@beyondcatastrophe_
@beyondcatastrophe_ 18 күн бұрын
@@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 18 күн бұрын
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 18 күн бұрын
How many pure hardware threads do you think you can pull from your CPU?? Think about that...
I made Coroutines from scratch
2:09:30
Tsoding Daily
Рет қаралды 27 М.
"BEST C++ CODE ever written" // Code Review
27:38
The Cherno
Рет қаралды 78 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Why Your Backend Shouldn't Serve Files
19:40
Boot dev
Рет қаралды 73 М.
40x Faster Binary Search
1:24:22
ThePrimeTime
Рет қаралды 112 М.
What do you need select/poll/epoll for
2:11:21
Tsoding Daily
Рет қаралды 28 М.
The Genius of the N64's CACHE Instruction
21:15
Kaze Emanuar
Рет қаралды 139 М.
They Made a Sequel to C
1:53:24
Tsoding Daily
Рет қаралды 113 М.
Inside the V3 Nazi Super Gun
19:52
Blue Paw Print
Рет қаралды 2,3 МЛН
System76 accidentally built the fastest Windows Arm PC
21:02
Jeff Geerling
Рет қаралды 443 М.
Why Are Threads Needed On Single Core Processors
16:07
Core Dumped
Рет қаралды 229 М.
38C3: Hacking the RP2350
57:15
Atomic Central
Рет қаралды 7 М.
Just Because Its New Doesn't Mean Its Good (neovim) | Prime Reacts
20:50