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.
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.
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.
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.
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.
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 :)
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)
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
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.
It is helpfully getting better
C++ 🤮
@@oserodal2702 such insightful critique, you clown
@@stefanalecu9532 C++ 🥰
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.
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.
Important clarification: zig currently does not allow allocations in comptime
Oh, good to know! Neither of us are Zig programmers, so we were definitely guessing.
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.
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.
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 :)
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)
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!
@@sdr_pod can we get a link to the real code put in the show notes?
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
"It's O(n^2) but that's the compiler's problem" its not even a problem if your n is small anyway.