I ported h2spec to Rust (also: codegen!)

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

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

  • @fasterthanlime
    @fasterthanlime  5 หลายเดือนก่อน +14

    To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/fasterthanlime - You’ll also get 20% off an annual premium subscription.
    Early access: fasterthanli.me/videos/h2spec-to-rust
    Errata: (nothing yet!)

  • @snipsnap9995
    @snipsnap9995 5 หลายเดือนก่อน +125

    Gotta say, I really expected a betterhelp sponsorship just how, I'm happy it was Brilliant instead but unless that misdirect was on purpose to make fun of Better help sponsorships this was a pretty strange way to promote Brilliant?

    • @BertPdeboy
      @BertPdeboy 5 หลายเดือนก่อน +6

      There is an old rule for creating engaging stories; You are allowed one lie. You can make up butt-faced aliens climbing up from the earths core on jetski's, one lie is forgiven by your audience. Every other event must have a logical reason, an objective "yes, how else would you suggest to do this" causality. Your audience will not forgive more lies, and boo at the cinema screen and popcorn will fly around the room!
      Amos wrote, acted in, and edited, a moving story with **zero** lies. 💪

  • @danminshew2778
    @danminshew2778 5 หลายเดือนก่อน +86

    Guys will literally do anything to avoid writing a unit test.

  • @basix250
    @basix250 5 หลายเดือนก่อน +47

    Cool, another HTTP implementation in Rust!

  • @nometutentegiapreso
    @nometutentegiapreso 5 หลายเดือนก่อน +85

    It's not a fasterthanlime video if I don't need to watch it twice in a row to understand what's going on 😎

    • @FlanPoirot
      @FlanPoirot 5 หลายเดือนก่อน +6

      still faster than reading his bible long articles lol

  • @efferington
    @efferington 5 หลายเดือนก่อน +41

    ahh if only ThePHD could have done their talk. goddamnit rust!!

  • @gfasterOS
    @gfasterOS 5 หลายเดือนก่อน +23

    Even Rust cannot escape TableGen
    cranelift has its own DSL for generating machine instructions that does a whole ton of code generation. GCC does the same and so does LLVM (where TableGen is from). Maybe one day proc macros can replace this code generation case but that day is not today.

  • @Cmanorange
    @Cmanorange 5 หลายเดือนก่อน +12

    i've done some ungodly things with proc macros to the point where i tried to come back to it 2 days later and i had no idea how to follow the flow of my own macros. rust foundation please finish introspection!

  • @aleksandermirowsky7988
    @aleksandermirowsky7988 5 หลายเดือนก่อน +24

    The production value gets better with every new video! Even the sponsorship section was done really well.

  • @emcell2
    @emcell2 5 หลายเดือนก่อน +5

    wow... what an insane good skill to articulate your tree of thought. Impressive!

  • @dminik9196
    @dminik9196 5 หลายเดือนก่อน +1

    The purity of proc macros is a bit unfortunate even if understandable. A while ago I wanted to do some code injection into an asmjs app. I wanted to do this semi-automatically by annotating the rust library with proc macros and then parsing both my lib as well as the asmjs source and patching it based on metadata generated from the proc macros.
    In the end I ended up using a feature flag in the proc macro that would either modify the injected function and pass in some extra values or generate calls to the inventory crate. This would then be collected into a json by using the example(?) binary type in cargo.

  • @qwfp
    @qwfp 5 หลายเดือนก่อน +2

    re: git hooks @ 14:11, aren't git hooks "disabled" by default? I thought that they are not committed to the repo and you have to copy them over manually (or use something like the `pre-commit` tool). Which makes sense, because they can run code without you knowing.

    • @qwfp
      @qwfp 5 หลายเดือนก่อน

      Now I see that you're using cargo-husky, so I guess you're actually referring to naughty contributors who don't run tests 😅

  • @johnlewis794
    @johnlewis794 4 หลายเดือนก่อน

    @fasterthanlime couldn't you have made a proc macro at that you call at the crate level on `httpwg` that iterates through each module looking for tests matching your criteria and writes an impl block for some type that builds up your test suite? that way it recurses properly without being stateful and you only have to write one proc macro. I know it would still have to parse a lot of syntax but you could probably internally just feed syn individual modules instead of the whole crate

  • @2khz
    @2khz 5 หลายเดือนก่อน +4

    Awesome video, super interesting as always! Can't wait for another fasterthanlime 40-minute-video-saga-classic when you have the funding and time! Put it on the backburner and there'll be an opportunity eventually :) I appreciated the mouth trumpet (tuba?) at the end with the cloth as a pop-filter. Got a sock on my microphone and it works just fine.

  • @koutheir22
    @koutheir22 5 หลายเดือนก่อน +2

    There is, at least, one reason to regenerate Rust bindings from C header files, every time a *-sys crate is built: the generated Rust bindings are platform-specific.
    C types will be translated to different Rust types, depending on which platform is being targeted by the build. Also, the C preprocessor might define constants and types in different ways depending on platform-specific macros. For example, (1) the C type "long" will be translated sometimes to Rust i32, and other times to Rust i64.
    The only way I can think of avoiding this regeneration is by caching the bindings for every single supported OS/Architecture/ABI (i.e., target triple), and that doesn't seem like a sustainable idea, even if it would avoid the need for build dependencies and a C compiler tool chain.

    • @SimonBuchanNz
      @SimonBuchanNz 5 หลายเดือนก่อน

      The windows crate at least can know exactly what all the possible ABIs are, so it uses a macro that generates the correct extern decl for the current target.
      For other platforms, in theory you could do the same thing that bindgen does to figure out the in a proc macro, but... I'm pretty sure it actually just uses clang as a library to mostly compile the header down to the ABI that clang proper would use. Don't think we want to do that in a proc macro ...

    • @koutheir22
      @koutheir22 5 หลายเดือนก่อน

      @@SimonBuchanNz Windows is the easier case, because of how few ABIs it supports (5 or so). The *-sys crates I was talking about target more platforms than the x86_64-pc-windows-msvc ABI, including Linux, FreeBSD, MacOS, bare metal, etc.

  • @spicybaguette7706
    @spicybaguette7706 5 หลายเดือนก่อน +1

    Cool project, I have been trying to figure out using io_uring with hyper. But its IO model doesn't really map that well to zerocopy. You really need to let the io runtime/glue take over the buffers for maximum performance with zero copy, I believe. Because you can register pages with io_uring, so that they can stay memory-mapped by the kernel. Maybe this could be solved by an allocator interface (like the unstable `Alloc` trait) that hyper can use? This way you can allocate from the registered pool of memory. Also, when sending buffers you should hand over ownership to the kernel until it yields control of the buffer to the application again (TCP ACK? Or maybe the NIC copies it into it's own internal buffer, idk). And then I gave up😅
    And is there even an async runtime that implements io_uring networking? I looked at glommio but it only seems to use io_uring for filesystem access

  • @flyingsquirrel3271
    @flyingsquirrel3271 5 หลายเดือนก่อน +2

    That little pink ear at 6:56 made me happy. I once had a lovely white cat that ALWAYS wanted to sit on top of people :)

  • @somoscode4151
    @somoscode4151 5 หลายเดือนก่อน +14

    cat hair flying around while he throws his hands around... there are only two kinds of people in this world I suppose. Cat vs Dogs. :)

    • @Xeros08
      @Xeros08 5 หลายเดือนก่อน +1

      No VS. Cats & Dogs. I love both 😊

  • @duality4y
    @duality4y หลายเดือนก่อน

    have you ever thought about writing compilers or interpreters?

  • @shadamethyst1258
    @shadamethyst1258 5 หลายเดือนก่อน +3

    rustdoc's json output has saved me once before. Such a lovely feature to have :)

  • @edgedlt
    @edgedlt 5 หลายเดือนก่อน +9

    You have an amazing ability to de-mystify 100 things at a time for me and I love you for it

  • @TheAnkanOfficial
    @TheAnkanOfficial 4 หลายเดือนก่อน

    how do you learn about this concepts

  •  5 หลายเดือนก่อน +1

    When working on the plane. How do you deal with cargo dependencies on a new project?
    One can use cargo fetch or cargo vendor for established projects, but how do you deal with that when experimenting on new projects?
    Local crates mirror?

  • @somebody_on_the_internetz
    @somebody_on_the_internetz 5 หลายเดือนก่อน +1

    The outro really caught me by surprise, really informative and interesting video

  • @LibreGlider
    @LibreGlider 5 หลายเดือนก่อน +3

    I understand the words individually, but I need to rewatch at least twice to understand them all together...

  • @QuietMisdreavus
    @QuietMisdreavus 5 หลายเดือนก่อน +2

    Big fan of using intermediate data formats for crimes. Beautiful work!

  • @narigoncs
    @narigoncs 5 หลายเดือนก่อน

    This is awesome. I absolutely love it.

  • @dcnick3
    @dcnick3 5 หลายเดือนก่อน

    You could also use libtest-mimic or similar to build a custom test harness that has test cases generated in runtime (from the central test registry you could have collected)

  • @thegioveZ
    @thegioveZ 5 หลายเดือนก่อน +1

    What monospace font are you using in the video?

  • @xurtis
    @xurtis 5 หลายเดือนก่อน +2

    “A series of unfortunate events” is such an understatement

  • @EngineerNick
    @EngineerNick 5 หลายเดือนก่อน

    Due that outro was first class!

  • @joseepifanio8515
    @joseepifanio8515 5 หลายเดือนก่อน

    Where did you get your shirt?

  • @recklessroges
    @recklessroges 5 หลายเดือนก่อน +1

    The bear necessities, the simple bear necessities...."

  • @hikingpete
    @hikingpete 5 หลายเดือนก่อน

    I don't usually sub before I check out a back catalogue, but with a description section that comprehensive I'm sold.

  • @morglod
    @morglod 5 หลายเดือนก่อน +1

    "I decided port it to rust" then "don't repeat yourself"
    Okey okey

  • @piraka_mistika
    @piraka_mistika 5 หลายเดือนก่อน

    That was a great ad

  • @dantenotavailable
    @dantenotavailable 5 หลายเดือนก่อน

    I swear that "Life is too short for long builds" was a slogan for some product but for the life of me I can't find it.

  • @bowarc
    @bowarc 5 หลายเดือนก่อน

    wow

  • @JoeJoeTater
    @JoeJoeTater 5 หลายเดือนก่อน

    People also might not want to run "trust me bro" binaries on their dev environment...

  • @spicybaguette7706
    @spicybaguette7706 5 หลายเดือนก่อน

    Rust BTW😎

  • @Lena-qg8bd
    @Lena-qg8bd 5 หลายเดือนก่อน +1

    second

  • @MechMK1
    @MechMK1 5 หลายเดือนก่อน +5

    The constant over-gesturing is really difficult for me to deal with. I can basically only listen to the video and not watch it.

    • @yarden-zamir
      @yarden-zamir 5 หลายเดือนก่อน +1

      I'm the other way around 😂

    • @LunarLaker
      @LunarLaker 5 หลายเดือนก่อน +1

      autism is a spectrum my friend

    • @sandworm9528
      @sandworm9528 5 หลายเดือนก่อน

      Haha you would hate talking to me 😂

  • @korigamik
    @korigamik 5 หลายเดือนก่อน

    Interesting

  • @qbasic16
    @qbasic16 5 หลายเดือนก่อน

    third

  • @joranmulderij
    @joranmulderij 5 หลายเดือนก่อน +1

    first

  • @benjins
    @benjins 5 หลายเดือนก่อน +8

    Always impressive how much information you're able to fit into a (relatively speaking) short video, and still have a decent flow