I made Futures from scratch

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

КОМЕНТАРІ • 135

  • @VladyslavPrydatko
    @VladyslavPrydatko 18 днів тому +261

    no "hello everyone and welcome to yet another recreational programming session with mista zozin" at the beginning?
    i demand a reupload.

  • @joepeach-o9v
    @joepeach-o9v 18 днів тому +150

    At first I read title as "I made Futures in Scratch"

    • @antropod
      @antropod 18 днів тому +1

      Deez nuts

    • @thecomputerfreak
      @thecomputerfreak 18 днів тому +20

      Would be funny to see Tsoding programming in Scratch. But aslong as it not compatible with Raylib, I don't think he will😅

    • @berndeckenfels
      @berndeckenfels 18 днів тому +1

      Me too, hehe

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

      Hey hey you, calm down now don't give him ideas

    • @craftrumzen2393
      @craftrumzen2393 17 днів тому +1

      Bro, he changed the title

  • @unknown_error101
    @unknown_error101 18 днів тому +48

    This was a very helpful video!! However, I didn't know who I was doin' this recreational programming session with which makes me very sad. I hope Mista Zozin comes back one day sigh.

  • @lack_of_awareness
    @lack_of_awareness 18 днів тому +23

    those c3 compiler error messages are so good lmao. they are straight to the point of what the issue was and suggestion on how to solve it

  • @StevenMartinGuitar
    @StevenMartinGuitar 18 днів тому +61

    Can we implement 'Sassy C' compiler where all the errors are sarcastic and grumpy?

    • @3mwithjoao
      @3mwithjoao 18 днів тому +24

      1. Undefined variable (undefined: varName) "Oh, sweetie, did you forget to introduce your variable to the compiler? It's not psychic, you know."
      2. Missing return statement "Leaving early? The compiler isn’t done with you yet-return what you promised, darling."
      3. Syntax error (unexpected token) "Syntax is not your playground; the Go compiler plays by strict rules. Try again, rebel."
      4. Type mismatch (cannot use X as Y) "Oil and water don’t mix, sugar. Neither do incompatible types. Fix it or stay mismatched forever."
      5. No package found (cannot find package) "You didn’t RSVP to the package party? No wonder Go can’t find it."
      6. Declared and not used "Why declare something and then ghost it? Go is all about commitment, honey."
      7. Import declared and not used "Inviting libraries you don’t intend to use? Rude. Clean up your imports, superstar."
      8. Function redeclared "Two functions with the same name? Drama queen alert! Pick one and let it shine."
      9. Non-exported field accessed "You can't just waltz into private fields like you own the place. Be respectful and export them first."
      10. Circular imports "Round and round you go. This import circus has no end. Time to break the loop, darling."

    • @RustIsWinning
      @RustIsWinning 18 днів тому +6

      I want to see a compiler that will compliment me if things go well and will support me if something doesn't

    • @inertia_dagger
      @inertia_dagger 17 днів тому +7

      ​@@RustIsWinning cargo-mommy, you're welcome

  • @RabeezRiaz
    @RabeezRiaz 17 днів тому +9

    This was an amazing stream. So many random CS/programming concepts randomly kept coming up in the most natural way.
    Not only that but the classic Zozin humor mixed with the actually meaty project reignited my passion for my own side project that needs some love.

  • @TechBuddy_
    @TechBuddy_ 17 днів тому +8

    It's actually Ryan Dahl (the creator of node and deno) who made the get back javascript petetion

    • @JuliaOrtiz-ti6ku
      @JuliaOrtiz-ti6ku 17 днів тому +3

      And it’s not just a petition to convince oracle, they are trying to free the mark by alleging trademark abandonment

  • @SimGunther
    @SimGunther 18 днів тому +49

    Anything in the universe of structural programming, including futures, coroutines, and continuations, is just a fancy way of hiding gotos

    • @Zex-4729
      @Zex-4729 18 днів тому +3

      yeah, make gotos great again!

    • @hedlund
      @hedlund 18 днів тому +40

      _Anything_ in programming is a fancy way of hiding something lower-level. It's the whole point of the concept of abstraction.

    • @Archimedes.5000
      @Archimedes.5000 18 днів тому +4

      @@hedlundand yet goto is like way fucking simpler lmao

    • @infastin3795
      @infastin3795 18 днів тому +1

      Coroutines don't use goto at all though.

    • @__Brandon__
      @__Brandon__ 18 днів тому +1

      For loops and while loops are just goto as well, but it is a common enough pattern that giving it a name and abstracting it out is useful

  • @Martinit0
    @Martinit0 10 днів тому

    6:00 It's called "cooperative multitasking". Cooperative because the program is not interrupted by the kernel but gives up control voluntarily.

  • @sahilpathan2475
    @sahilpathan2475 18 днів тому +16

    Bro i can watch this guy all day ngl❤️ Keep it up

    • @Zipperheaddttl
      @Zipperheaddttl 18 днів тому +4

      I can't, I use his videos to go to sleep. And now his voice makes me doozy

    • @AloisMahdal
      @AloisMahdal 11 днів тому +2

      @@Zipperheaddttl are you aware of his cynical rants? if not, maybe that explains your nightmares :D
      (jk, i love his rants, even though i don't usually agree but he does not take them seriously himself so that's that...)

  • @infrxion1516
    @infrxion1516 17 днів тому +2

    Not sure if you care now that you got it working, but you don't actually need to do the thing for Rejects where you set the excuse later. The problem was that you were using the question mark operator after the WOULD_BLOCK when you were constructing the Reject, which was trying to propagate the error when you just wanted to create an instance of IoError.

  • @errelin1326
    @errelin1326 18 днів тому +8

    Amazing you are in fact showing to us all the time what you’ve said: learn programming instead of programming langs

  • @hamzakhiar3636
    @hamzakhiar3636 17 днів тому +1

    i love the enthusiasm & and the simplicity even tho i don't understand the concept that much nor much C, i wanted to implement this on my own but i couldn't get it well; but i loved the vid; made me wanna pursue some of my side projects

  • @simonfarre4907
    @simonfarre4907 17 днів тому +2

    Is this not just writing a Promise that "looks like" a future, and because of that, won't work at all. A future still needs an execution context (i.e. some thread that manages it, that gets signalled when it can awaken and start polling). This is just... i don't even know what this is?

  • @oserodal2702
    @oserodal2702 18 днів тому +16

    5 minutes in, and I'm already seeing Mr. Streamer doing a big sin in asynchronous programming, executing a promise using a spin-lock.

    • @TsodingDaily
      @TsodingDaily  18 днів тому +26

      You need to start from somewhere

    • @oserodal2702
      @oserodal2702 18 днів тому

      ​@@TsodingDailyValid

    • @dzentsetsu
      @dzentsetsu 18 днів тому

      He is an evil man (just like Oracle)

    • @limplash
      @limplash 18 днів тому

      i would say this stream is more like the library interface design (API) ... once we come to a proper `runtime` for these futures .. we will worry about execution

  • @AbegazNap
    @AbegazNap 13 днів тому +1

    The fact that this guy doesn't have millions of subs is truly sad. What a chad of a programmer, truly elite in communication as well

  • @naive_algorithm
    @naive_algorithm 18 днів тому +2

    In js async, await make function behave like synchronised, then why we need async,await in other language like c#,rust,dart what are synchronised by default?

    • @andreffrosa
      @andreffrosa 17 днів тому +2

      Because the functions marked as async in those languages run in separate threads and thus you need wait to coordinate

    • @naive_algorithm
      @naive_algorithm 17 днів тому +1

      @andreffrosa my actual question is,does js serve different purpose from other synchronise language? Because by default js doesn't block thread like c#,rust,dart.

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

      @@naive_algorithm js has an execution loop, when calling [async function] fn() you dont execute it directly, you push it to a list of functions to be executed and the execution of the current block continues, this is fundamentally different to other common langs

  • @lkuty
    @lkuty 5 днів тому

    Is `&self` as the first argument the same as `Future* self` (for the Future struct)?

  • @ecosta
    @ecosta 10 днів тому

    1:17:40 - To be honest, I wasn't confident on the cleanness of the result until those macros were introduced. Damn, that is neat AF. I can't wait to watch the remaining of the video...

  • @adamp9553
    @adamp9553 18 днів тому

    Have to look at the assembly in order to know for sure if something is only temporary on the stack.
    Also, something like a logical OR (!a | b!) is necessary to execute both where boolean OR || skips if first is satisfactory.

  • @Odod4000
    @Odod4000 18 днів тому +4

    I really like your videos. Keep it up and stay penger!

  • @ronakmehta8106
    @ronakmehta8106 18 днів тому +3

    panim in c3 ??

  • @ovi1326
    @ovi1326 17 днів тому +1

    I get why you went the javascript promises route instead of rust futures. The rust ones are state of the art tho, I guess it could be a fun little project to reimplement say smol in something like zig (or heck - C11 maybe)

  • @shahab5191
    @shahab5191 18 днів тому +1

    is there any lsp for c3?

  • @10e999
    @10e999 18 днів тому +1

    Not interested in C3, but I realy like the idea of recreating async primitives from scratch.
    Next goroutine + go runtime?

  • @Archimedes.5000
    @Archimedes.5000 18 днів тому +1

    4:00 that's an awfully complicated explanation of "it's a loop that does nothing until condition happens and then it calls registered callback functions once"

  • @chri-k
    @chri-k 18 днів тому +2

    you might have been interested in the fact that macros can take a trailing block of code as an argument.
    that would get rid of the })}) hell at the end, and turn it into
    fut(...).@then(...) { ... }.@then( ... ) { ... };
    the trade-off is that you can't return a value from such a block.

    • @jaymr2795
      @jaymr2795 17 днів тому

      He did this in the video but didn't like how it looks. I think you should watch the video before commenting something like this.

    • @chri-k
      @chri-k 17 днів тому +1

      @ peculiar
      did i accidentally skip something and not notice?

    • @jaymr2795
      @jaymr2795 17 днів тому

      @@chri-k maybe. He did it towards the end when he finished his then implementation

  • @GoldoEb
    @GoldoEb 16 днів тому

    1:44:00 it's probably because the C3 webpage uses TLS ECH which is banned in Russia.

  • @bhaveshsuthar7239
    @bhaveshsuthar7239 14 днів тому

    Is asynchronous behaviour possible on a system with single processor?

    • @spacey6960
      @spacey6960 9 днів тому

      As long as you have an operating system that runs on 1 processor then yes. The OS is more important than the core count.

  • @softwet4341
    @softwet4341 18 днів тому

    What is that bar at the top of the screen? I also use i3wm and I really need this.

    • @NexushasTaken
      @NexushasTaken 18 днів тому

      it's a Tab layout, usually its mapped to Mod+w

    • @softwet4341
      @softwet4341 18 днів тому

      @@NexushasTaken thanks

    • @eeriemyxi
      @eeriemyxi 17 днів тому +1

      The nicest thing about i3wm compared to its competition is its way superior documentation. If you're not reading it, you're missing out.

  • @facundoferrero1395
    @facundoferrero1395 16 днів тому +1

    you should try Clay, its an ui library built in c, supports raylib

  • @dream11tatyabichoo92
    @dream11tatyabichoo92 18 днів тому

    in functional programming its closures to the rescue

  • @fntr
    @fntr 8 днів тому

    what font do you use?

  • @anon_y_mousse
    @anon_y_mousse 16 днів тому +1

    One of the things I don't like about C3 is also something I don't like about C++. Introducing a new double character token where they didn't exist to express a slightly different form of the singular character token is cancer. As far as references in my own language, I opted to use @ to represent them and for taking the address of something. I really dislike the r-value reference versus l-value reference dichotomy in C++. I get why the committee thinks they need to be manually differentiated by the user, but they're wrong. You just need to be more aggressive with scanning the parse tree, especially when you consider that they only really make sense when the compiler can see what you're referencing. I am curious though, why no one seems to ever engage with the discussions I try to have.

    • @meanmole3212
      @meanmole3212 8 днів тому +1

      Your concerns about the use of double character tokens in languages like C++ and C# are quite valid and resonate with many developers who prefer simplicity and clarity in syntax. The introduction of new tokens to differentiate between similar concepts can indeed lead to confusion and a steeper learning curve, especially for those new to the language.
      Using a single character, like @, to represent references in your own language is an interesting approach. It simplifies the syntax and reduces the cognitive load on the programmer. The distinction between l-value and r-value references in C++ can feel unnecessarily complex, especially when the underlying concepts could potentially be inferred by the compiler through more sophisticated analysis of the parse tree.
      Your point about the compiler's ability to understand context is crucial. If the compiler can accurately determine the nature of the references based on the surrounding code, it could eliminate the need for developers to manually specify these distinctions. This could lead to cleaner, more intuitive code, allowing developers to focus on logic rather than syntax.
      As for the lack of engagement in discussions around these topics, it can be frustrating. The programming community often gravitates towards established norms and practices, which can make it challenging for new ideas to gain traction. Additionally, discussions about language design can become quite technical and abstract, which might deter some from participating.
      It might help to share your thoughts in more focused forums or communities that prioritize language design and syntax discussions. Engaging with like-minded individuals who share your passion for language simplicity could lead to more fruitful conversations. Keep pushing for clarity and simplicity in programming languages-it's a conversation worth having!
      I hope you did not reach this line.

  • @Protoex
    @Protoex 16 днів тому

    From my whole ~4 hour experience in C3, fault == enum, and we only question mark when we wanna "throw".

  • @CoderBen-zz4kw
    @CoderBen-zz4kw 18 днів тому +1

    Someone could have given you futures as Christmas presents. 😅
    Anyways, love your content, would definitely get time to see it on Christmas.

  • @antropod
    @antropod 18 днів тому +7

    WOOD_BLOCK

  • @vincenzkoop43
    @vincenzkoop43 16 днів тому

    I'd like to see zozin elaborate on the callbag standard by andré staltz

  • @elgalas
    @elgalas 18 днів тому +1

    Isn't Oracle a bunch of layers and zero devs?

  • @27182818284590452354
    @27182818284590452354 16 днів тому

    Pointers to literals should be safe, it's not like the data segments of the executable go away while it runs.

    • @anon_y_mousse
      @anon_y_mousse 16 днів тому

      Unless it's all on the stack. The compiler could potentially just insert a sub from the stack then push a bunch of immediate values into that space.

    • @27182818284590452354
      @27182818284590452354 16 днів тому

      @@anon_y_mousse Surely, not with the operator && in front of it. Although I doubt that C3 compiler does anything like that probable pessimization.

  • @naranyala_dev
    @naranyala_dev 17 днів тому

    amazing show, thank you

  • @sergeygong2224
    @sergeygong2224 16 днів тому

    What's wrong with subtitles?

  • @kitastro
    @kitastro 18 днів тому

    just works in 8 months, just have to give birth

  • @freebyte
    @freebyte 18 днів тому +1

    "**any**ways"

  • @shrddr
    @shrddr 18 днів тому

    I swear there was a stream on same topic before and it was great. Alright time to learn about promises again I guess!

  • @cycomkid
    @cycomkid 17 днів тому

    What if we want to call a javascript fetch function from this fetch while working with wasm.
    The javascript fetch will call the callback, but how can we poll for that, without blocking the thread.

  • @gempf
    @gempf 17 днів тому

    dynamic dispatching

  • @minghaoliang4311
    @minghaoliang4311 16 днів тому

    Discovering Monad

  • @houcineelbaz3610
    @houcineelbaz3610 18 днів тому

    What an intro!

  • @swapansaha2368
    @swapansaha2368 18 днів тому +1

    Can u try vulkan with c??? Pls pls pls man I request

  • @hubstrangers3450
    @hubstrangers3450 16 днів тому

    Thank you....

  • @berndeckenfels
    @berndeckenfels 18 днів тому +1

    bikeshedding alert - 4:30 I like then() over chain an isFinished() over poll()

    • @anon_y_mousse
      @anon_y_mousse 16 днів тому

      Maybe I'm weird, but I think ergonomics actually matter. To me, this isn't really bikeshedding.

  • @bravo90_
    @bravo90_ 17 днів тому

    Can you plz do genesis physics simulator next

  • @Daniel_Zhu_a6f
    @Daniel_Zhu_a6f 17 днів тому +1

    i feel like java-style interfaces result in a lot of code bloat. why not just use struct with pointers as an interface object and then embed it into other structs like this:
    ```C
    typedef struct Fut Fut;
    struct Fut {
    uint8_t (*poll)(void*data);
    void *result; char *err_msg; Fut*next;
    };
    // usage:
    typedef struct {Fut fut; uint8_t pos; uint8_t stop; } Counter;
    uint8_t Counter_poll(Counter *self) {...};
    int main(){
    Counter c= {{(void*) Counter_poll}, 0, 10};
    while (c.fut.poll(&c));
    }
    ```

  • @DriftJunkie
    @DriftJunkie 15 днів тому +1

    JS replacement incoming

  • @StevenMartinGuitar
    @StevenMartinGuitar 18 днів тому +2

    You don't need to clone a github repo just to view it... Just go to the root of the repo and press dot '.' and it will open in an online vscode instance.... I know I know 'brother ewwww' it's not emacs but you can click/scroll /search/expand the file tree etc

  • @alexey2044
    @alexey2044 18 днів тому +4

    C3 feels like Rust but without bullshit and cult stuff

    • @RustIsWinning
      @RustIsWinning 18 днів тому

      We are not a cult and there is no bs!! 😠

    • @aadilshabier
      @aadilshabier 18 днів тому +4

      Cult stuff is when you can't write UB code

    • @nel_tu_
      @nel_tu_ 18 днів тому

      love how simple the macros are in c3

    • @Archimedes.5000
      @Archimedes.5000 18 днів тому

      Erm but is it safe??

    • @inertia_dagger
      @inertia_dagger 17 днів тому

      ​@@aadilshabierliterally 1984 (and you still can)

  • @fleaspoon
    @fleaspoon 16 днів тому

    pollable doesn't sounds very good in spanish 😂

  • @Odod4000
    @Odod4000 18 днів тому

    First

  • @centralintelligenceagency6825
    @centralintelligenceagency6825 16 днів тому

    Losing what have you done with your life?