Compile Time Crimes

Поделиться
HTML-код
  • Опубликовано: 14 ноя 2024

Комментарии • 19

  • @ChlorieHCl
    @ChlorieHCl День назад +10

    Wow this is just like C++ constexpr but more painful. I thought C++ is already too restrictive for when you use vectors in constexpr code but not being able to even use for loops seems annoying as hell to me. Props to you for getting it working.

    • @Jplaysterraria
      @Jplaysterraria День назад +3

      It is helpfully getting better

    • @oserodal2702
      @oserodal2702 День назад

      C++ 🤮

    • @stefanalecu9532
      @stefanalecu9532 День назад +5

      ​@@oserodal2702 such insightful critique, you clown

    • @oserodal2702
      @oserodal2702 День назад

      @@stefanalecu9532 C++ 🥰

    • @KabukiStarship
      @KabukiStarship 19 часов назад

      I don't have this problem. For my C++ API Script2 I replaced the C++ std lib and unicode engine with modern data driven design and I found that it was easiest for me to remember and avoid abstract argument collisions if I prefix the function with T if it's a template, and C if it's constexpr. constexpr actually works on non-const data too, it's an optional compile implementation. Search for constexpr in Script2 and you'll see where it comes in useful. For my API I don't define the print code until the top layer using operator overloads, which allows me to print to any destination like ring buffers, blocks of RAM, streams, etc. It might not be the nicest to look at but it doesn't take much thought.

  • @SoapSoapCrayon
    @SoapSoapCrayon 3 часа назад

    23:59 this is exactly what happened to me when i started trying to use compile time rust. I really like the language, i like a lot of the features, and I think learning it has made be better, but I switched back to C++ for my day-to-day because of garbage like this. It felt like the Rust STL and compile time stuff is extremely not-fit for production quite yet, and I'll be following the changes, but I'm still not switching over to it for large projects just yet.

  • @rez188
    @rez188 7 часов назад

    Important clarification: zig currently does not allow allocations in comptime

    • @sdr_pod
      @sdr_pod  Час назад

      Oh, good to know! Neither of us are Zig programmers, so we were definitely guessing.

  • @KabukiStarship
    @KabukiStarship 19 часов назад +1

    Interesting. I made the Serial Chinese Room, Interproces, and Telemetry Script, AKA Script2 and the SCRIPT Protocol for RPC, which is hybrid byte encoded and human readable based on contiguous data types.

  • @MarekKnapek
    @MarekKnapek 8 часов назад

    Why using the O(n^2) loop if you could use sort instead. Implementing merge sort is easy. After you sorted your array, it is easy to extract unique values into result array. Easy in C++14 constexpr.

  • @duvallj
    @duvallj День назад +3

    20:32 oh no typo on the slides, second loop needs an increment...
    very good episode tho! I'm in the midst of some compile-time crimes myself, w/ a proc_macro tho, neat to see const fn crimes too :)

  • @beyondcatastrophe_
    @beyondcatastrophe_ 22 часа назад +1

    16:25 I know this is not very rust-like, but do you even need the maybe-uninit? Just initialize everything with zero, you already unwrap everything that is below the current output index, so you don't even use the fact that it's an Option (you also return the number of `Some` values, so it doesn't even help on the consumer side)

    • @sdr_pod
      @sdr_pod  16 часов назад +1

      For this example, no! For the slightly more complex data types in the real code (or for the general case), it would be nice to have!

    • @RichardPringle9
      @RichardPringle9 14 часов назад

      ​@@sdr_pod can we get a link to the real code put in the show notes?

    • @sdr_pod
      @sdr_pod  10 часов назад

      Sure! We'll add it there soon. For now, this is most of the code that inspired this episode: github.com/jamesmunns/postcard-rpc/blob/main/source/postcard-rpc/src/uniques.rs

  • @Bobbias
    @Bobbias День назад +1

    "It's O(n^2) but that's the compiler's problem" its not even a problem if your n is small anyway.