"im not monetized in the first palce, so fuck that" bro is a coding chad.
@rubyciide554213 күн бұрын
He is the only chad you can find on KZbin that programs 🫡. Rest are money hungry corporate slaves
@thissundae13 күн бұрын
I often forgot he's a guy in the middle of Siberia his whole life
@FreezeBadGuy12 күн бұрын
@ yeah bro it makes sense hes a total bad ass about it. This guy will rule his own country one day.
@actualwafflesenjoyer2 күн бұрын
@@FreezeBadGuy citizenship only for c programmers
@nikkehtine13 күн бұрын
Halfway through the explanation of coroutines he yielded his viewers to another stream. Great explanation Mister Zozin!
@bean_TM14 күн бұрын
chat in subtitles is a fantastic idea. chaotic good
@JohnDoeNobody14 күн бұрын
He’s always been doing this lol, this is just the first time he’s told anyone about it.
@Omena014 күн бұрын
@JohnDoeNobodyhe has before
@HugoNobrega8713 күн бұрын
@JohnDoeNobodywell definitely not always, I think just a few months at this point
@dasten12313 күн бұрын
why? Chat is fucking stupid
@igz555313 күн бұрын
Super interesting, not the best UX but original nonetheless
@ErikBongers14 күн бұрын
This is a great tutorial explaining the architecture of co-routines. No half-baked analogies, but an under-the-hood get-your-hands-dirty demonstration. Thank you!
@seventhtenth14 күн бұрын
"2 hours earlier" narrative gives a lot of hype. Thank you for sharing the streams
@c0d_0x1612 күн бұрын
I don't know if I'm just obsessed with your work, but really, you're the most versatile and knowledgeable programmer I've seen or heard of 😮. Your channel is a rear gem. Thank you for this amazing content.
@Spike.Spieko14 күн бұрын
Ngl, starting the video with "What the f**k ...." is such an OP intro.
@playerguy214 күн бұрын
For Tsoding (on the off chance you _do_ read this): alloca(), and see last sentence. Damn, I was just experimenting with implementing coroutines a week ago. Yes, the stack is the limiting factor. I ran into a bug where I implemented a generator with an out parameter and main() printf'd it out. Thing is: the output pointer in the generator function was offset by 0x4 away from the correct value after every the longjmp. Turns out, by jumping, the stack was effectively freed and printf() overwrote it. Returning from the func also segfaulted (I wonder why). The solution, which made me feel like a genius, a God amongst men, was to insert a call to alloca(16) right after the setjmp, before printf(). It would offset rsp by 2 pointers worth (return address and the out param), reserving the stack frame, protecting it from printf, and it worked! From there it's a case of using alloca(0) to measure the stack size, alloca() to protect, memcpy() to save and restore it, longjmp() to yield and resume.
@ToyosatomiminoMiko-z8tКүн бұрын
had to deal with coroutines recently in C and i pretty much just have a chunk of the coroutine struct dedicated to storing its own stack of about 8KB (and 2 jmpbufs for the caller/callee) if the callee's jmpbuf wasnt initialised(so if its the first time its been called), then i just poked at the stack pointer(and saved important information in static variables so that they'd still be accessible) and called the coroutine, which, when it yielded, longjmp'd back, returning us to our previous stack safely it was pretty bodgy (and i dont think i explained it quite well) but man did it feel great when i came up about that idea
@wahyuwardani36858 күн бұрын
having video like this in youtube is insane, keep kicking ass dude!
@FryAndLeelaAndBender14 күн бұрын
I must agree with Mr. Programmer here: at least for me, FASM (Flat Assembler) is like I think every assembler should be - simple to understand, elegant, easy to program code and with an easy command-line invocation - no make, no cmake, no nothing; everything in its purest form...
@brayn750414 күн бұрын
I never requested a topic but I would love it if you explore Kotlins coroutines. Would be nice to see your take and view on it. Thank you Tsoding for the amazing work that you do. Kotlin's coroutines are even more concise and supports multi-threading as well so if possible, would be great to see what you think of it. It would definitely give you some new perspective on how to implement this and for others, better understanding of such a complex topic. Thank you.
@diadetediotedio691814 күн бұрын
Kotlin coroutines are closer to futures than to the mill thing or go, they transform into state machines and are polled by a runtime. What I like on them is that you can control precisely where they will run, so if you just want to dispatch some in the local thread and keep it single threaded you just `runBlocking` and it usually just works
@my_online_logs14 күн бұрын
any coroutines support multithreading bruh because its m:n mapped on os thread
@my_online_logs14 күн бұрын
@@diadetediotedio6918eh no bruh, kotlim coroutines is like golang, its stackfull. futures is stackless coroutines, rust and java are stackless coroutines. stackfull coroutines give the user easier to use but in very high load your performance will be lesser than stackless coroutines because each your coroutines need their own stack
@diadetediotedio691813 күн бұрын
@ This is actually pretty much false. Kotlin coroutines are stackless coroutines, they only look more like stackful coroutines because design decisions of the language (such as not having some kind of 'await' keyword), but you still need to mark functions as 'async' (in kotlin terms, 'suspend') and it still works the same. You should remember that kotlin runs on the JVM, so they improvised the solution that could have interoped well with Java and cannot do something like Go did.
@naxaes788914 күн бұрын
How many here see a new Tsoding repository in the github feed and then are left in excitment of the new video that's about to drop?
@polskafan14 күн бұрын
If go calls it goroutines, can we call it tsoroutines?
@MrMeltdown14 күн бұрын
Bro-routines. Bro-yield. Bro-go. Bro-run….
@seventhtenth14 күн бұрын
@@MrMeltdowntsoro bhodhi
@machine.angel.77714 күн бұрын
1 minute ago is assembled
@kaporos13 күн бұрын
About the relocation issue, you can change all of your mov rsi, toto with lea rsi, [toto] to use relative adressing and avoid the need for relocation
@hand-eye451713 күн бұрын
I saw the video description , and said no way 😂 your nuts man . Hopefully I can become like you one day
@kahnfatman14 күн бұрын
I thought I was crazy. But you are crazy!
@dastan33114 күн бұрын
Using macros and void * in C, it is possible to implement almost all the features found in other languages. However, there is a risk of introducing a lot of errors, and of course, writing a lot of code. But that's real engineering!😅
@User948Z7Z-w7n14 күн бұрын
16 seconds ago is unbelievable
@marcocaspers313618 сағат бұрын
I don't know if it's been answered already, but, when "deleting" items by swapping in the last item with the current one that has to be deleted you change the order of the list. While it won't be an issue if there's only 2 items on the list, it can get interesting if there are more than 2 items on the list. It won't matter if there is no interdependency or if the order in which things happen don't matter, but where the order matters or there are interdependencies it's going to mess things up. If the goal is testing hypothesis then this is fine, but as a generic library function I wouldn't want the odd chance of this happening, or it should at least have been documented clearly that this is a side effect of the implementation that may or may not be wanted.
@polnio14 күн бұрын
I just saw on the Wikipedia page of GNU assembler that with a recent version of GNU assembler, you can tell him to use intel syntax instead of AT&T. I didn't tested though, but it seems more interesting than make the linking by hand
@JamesSjaalman14 күн бұрын
BTW: coroutines are explained in Knuth#1, including code in (MIX) assembler. Suggested reading!
@joseoncrack13 күн бұрын
I need to re-read that. I have the full collection.
@kasparzubarev12 күн бұрын
In microcontrollers, and in Linux kernel you have interrupts, that make the program switch context to handle the interrupt and continue after the interrupt is handled
@_bitties14 күн бұрын
Best 1st minute intro
@multicoloredwiz14 күн бұрын
This project is so cool. Loved the intro Gasbabbs btfo!!!!
@nousername937412 күн бұрын
I admire you and your work
@bobby956813 күн бұрын
From scratch is what we're here for!
@solanacean2812Күн бұрын
I don't know much about fasm, but in fasmg/fasm 2 the built-in command 'struc' doesn't really define a structure, as the name suggests, but rather a labeled macroinstruction. Kinda like 'somestupidname db 0' defines the labeled form of instruction and 'db 0' the unlabeled one. To define a structure one has to include 'struct.inc' and use 'struct' macro: struct Context _rsp rq 1 _rbp rq 1 _rip rq 1 ends contexts db sizeof.Context * COROUTINES_CAPACITY dup ? assert Context._rsp = 0 assert Context._rbp = 8 assert Context._rip = 16
@hand-eye451713 күн бұрын
I saw the video title , and said no way 😂 your nuts man . Hopefully I can become like you one day
@elgalas12 күн бұрын
Epic, most epic stream ever. fasm, all hail fasm! All hail tsoding!
@asdfmonstrosity13 күн бұрын
Very cool! Afaik Lua implemented single threaded coroutines using pure c89. It is less convenient in the C api though, you need to pass continuation functions for 'the rest of the function', which might be inmediately run if no yield, or run elsewhere after a longjmp. Its pretty cool though. And the API from Lua code matches pretty similarly your code, coroutine.yield instead of coroutine_yield, etc.!
@olaff66714 күн бұрын
you can use intel syntax with gnu assembler with as -msyntax=intel
@johangonzalez489413 күн бұрын
I'll just mention Duff's Device as it is (somehwat) related to the title, and i want to share a little piece of hacky C that may not be as widely known.
@rogo733011 күн бұрын
I think you don't need special handlers to check file descriptors and stuff. You just need a way to talk back to the "main" execution context that yielded context will immediatly block/yield because it awaits file descriptor. It can be done just by passing memory between that will contain some information. That way "main" just need to understand on what couroutine should be synchronized (files, sockets, left disk space, system realtime, it does not matter), and then "main" will just decide to run coroutine again.
@blackhaze385613 күн бұрын
long time without watching Tsoding channel. Where is the 'hello and welcome to yet another recreational programming session?' part? 😢
@nerdicon482213 күн бұрын
why u push rbp into the stack and pop it at the end doesn't call and ret instruction do that automaticaly?
@chevychavanne443313 күн бұрын
Tsoding, you don't have to worry about the order of your static data in asm by using sections and segments. I'm pretty sure .bss section is where uninitialized variables go
@fredesch315812 күн бұрын
11:47 You don't understand tsoding! If a functional programmer actually got shit done, they'd be changing state, and everything they do need to be a pure function!
@luserdroog13 күн бұрын
Came for the codez. Stayed for the cussing.
@cryptonative12 күн бұрын
Came for the code stayed for the code
@JonathanZigler11 күн бұрын
Heck yeah
@deckard5pegasus67314 күн бұрын
My C code is filled with gotos. I never used gotos until I started programming Mac OSX carbon API back in 2003. And the Apple Carbon code had a really nice way of checking errors and cleaning up with gotos. Since then I always used it. The code is much more readable, and gets rid of nested if statements and many return points in the function For example: void someFunc(int param1) { int ret = error; if (some_proble) goto _ERROR; .... whatever code ..... ........ ret = ok; _ERROR: ...clean the function here... return ret; // only return point in the function. }
@monx14 күн бұрын
13:15 Recreational programming manifesto 😂
@froop239313 күн бұрын
You should provide timestamps for each "fck". So i exactly know where the interesting parts of your vids are 🤣 btw: realy great content explainig and demonstrating the heart of coroutines in a live session
@MrMeltdown14 күн бұрын
No I don’t know what a co-routine is…you gonna tell me or what? Love your content.
@jermeekable13 күн бұрын
i mighta missed it but did he mention pinning?
@FryAndLeelaAndBender13 күн бұрын
I love the part when Mr. Programmer says: "Fuck GNU assembler"... hahahaha 😂😂😂😂
@user-sq1oi9qp8w14 күн бұрын
how did you integrate twitch live chat into cc?
@naranyala_dev12 күн бұрын
a CHAD programming session
@elgalas13 күн бұрын
1:00:39 uxn mentioned
@PyguK14 күн бұрын
How is it possible, that Mr Tsoding have 5000 views, but only about 10% likes? Are rly 90% of the viewers disliking the video and still watching it? I think its a great video with a lot to learn from, so thumbs up from my part. Keep Going, great project
@FryAndLeelaAndBender13 күн бұрын
@@PyguK Probably many of the viewers use a smart TV to watch the videos and don't put a like because they forget to do that...
@FryAndLeelaAndBender13 күн бұрын
@@PyguK Also, not giving a like isn't similar to dislike thr video. It's more like being indiferent about it...
@nel_tu_13 күн бұрын
💀
@igz555313 күн бұрын
That’s typical for any video, 10% likes generally
@PyguK13 күн бұрын
@@igz5553 ah ok, didnt knew thats normal. Thanks 2 all 4 the replies.
@btarg113 күн бұрын
Please do some more game development streams! I'd love to see you make a game in C
@rustyname14 күн бұрын
What exactly do you want from writing software anymore?
@elgalas14 күн бұрын
Async/await in JS used to be polyfilled with generators
@rafalk552714 күн бұрын
C protothreads?
@AzharAli-n5c9 күн бұрын
great
@RiteshRanjan-x4k13 күн бұрын
Program in DOSbox
@christophjasinski48047 күн бұрын
Go team watching to figure out why it took them so long 🤣
@Aziqfajar13 күн бұрын
8:08
@amitmalaker544514 күн бұрын
you have this similar example in the c9xme you know??? ikykyk...
@delq14 күн бұрын
poggers
@btarg113 күн бұрын
C++ and c# already have equivalents out of the box, this is so entirely pointless yet I still find it cool for some reason
@infastin379512 күн бұрын
The one in C++ is unusable crap
@elishahar26392 күн бұрын
hello i am posting from my son's account. he watched this and had a seizure when he saw goto, and is now in the hospitle. needless to say i am disliking and calling youtube.
@alejandroulisessanchezgame692414 күн бұрын
First
@_f0x60414 күн бұрын
You don't need to say wtf that often to look cool bro. Peace
@colonthree14 күн бұрын
OwO
@cybermats200414 күн бұрын
asmr?
@simonfarre490714 күн бұрын
Coroutines are horrible. Debugging coroutines are horrible. Thank god for real parallelism and multi threading and epoll. Btw, coroutines are functional programming ideas or a declarative programming paradigm. Use a thread pool and post tasks instead. Coroutines are just bad. Hot take.
@2mj0lk10 күн бұрын
another genius here lmfao, humanity is doomed
@delicious_seabass14 күн бұрын
While this is cool and all and I wish C actually had real coroutines, rolling your own in assembly is probably a bad idea, if not for 'educational purposes'. For one thing, you'd have to implement this for each architecture, but more importantly debuggers will get confused about what is happening. If you want something like a coroutine, then just do a switch statement with an enum.
@diadetediotedio691814 күн бұрын
> While this is cool and all and I wish C actually had real coroutines, rolling your own in assembly is probably a bad idea, if not for 'educational purposes'. > If you want something like a coroutine, then just do a switch statement with an enum Nah, this is pure bullshit.
@delicious_seabass14 күн бұрын
@@diadetediotedio6918 Good argument. Thanks for copy-pasting. I almost forgot what I wrote.
@diadetediotedio691814 күн бұрын
@@delicious_seabass I think an argument would be a not enjoyable thing to do in this case, as you just came and felt the need to say this "should not be done" without nobody requesting that specific view. But I will actually respond to your points, so you may feel more inspired to develop your ideas. Your reasoning for why it is a bad idea revolves around the 2 stablished things, which I will mention and respond in order: > [For one thing, you'd have to implement this for each architecture] You don't need to if you are not planning to run for each architecture, but if you need to you just need to implement for each architecture, this is not a reason why it is a bad idea, it is just work. > [but more importantly debuggers will get confused about what is happening] Which says nothing about nothing, most debuggers of languages with any kind of async mechanism get lost on the tracks, even high level languages like C# have problems with that (with the debugger jumping around and getting into multiple spots every step you go), concurrency and parallelism are inherently hard to debug and that's why usually people rely more on logging for those kinds of systems. Either way, this is only a problem insofar you are concerned with that particularly, it don't make the whole thing a "bad idea". And lastly, about your "proposed solution", > [If you want something like a coroutine, then just do a switch statement with an enum.] This is nowhere near the convenience of coroutines, if the point is to do things manually then just spawn threads and pass things around, or do a manual futures library like he already did. This is a pointless alternative.
@delicious_seabass14 күн бұрын
@@diadetediotedio6918 First of all, I don't need your permission or anyone else's to give my opinion. Comments are enabled for a reason. Secondly, I never said "should not be done". That's your terrible reading comprehension. I said "it's probably a bad idea", as in not definitively. I still believe people have brains and don't need to be coddled, so they can make up their own minds. What I was simply doing was pointing out some issues people may not have considered if they go down this route. The reason I mention the arch is because C is cross-platform and while people may target a specific arch at first, they also might change their mind and want to port things later. Now it's not a simple recompile for said target arch - now they gotta go add a new implementation for their custom coroutines because they use them everywhere, and its otherwise a rewrite of their C code. Also, there is the possibility the arch can change with new versions, so now you're on the hook for each update should it break things. If you don't have an issue with all that, then great! Knock yourself out. As for debugging, I don't know why you brought up async and concurrency. I'm talking about messing with regular control flow. If you do that, debuggers don't understand what happens when you randomly jump using assembly because they base their flow on the C code and not the assembly. This is why its difficult to debug things like fibers, for example. They usually continue running the program or run to the next breakpoint if it exists, missing anything before. If you don't have a problem with that, then cool. Have fun printf debugging all your coroutines. Lastly, it's kind of funny you mention convenience here, since debugging is not important to you. Also, I'm not sure why you think you need to spawn threads or use futures. Like what do you think a coroutine does exactly? It just saves the execution state so it can continue it later before jumping to a new location. You can do this manually with, like I said, a switch and an enum that gets incremented, and possibly some gotos if need be. Your code will be fully debuggable, easier to follow, and compileable to different platforms. Sounds pretty damn convenient to me! ... I need to stop arguing with randos who have anime profile pics.