• 0 Posts
  • 60 Comments
Joined 2 years ago
cake
Cake day: July 24th, 2023

help-circle




  • You could save 0.64 bit per char more if you actually treated you output as a binary number (using 6 bits per char) and didn’t go through the intermediary string (implicitly using base 100 at 6.64 bits per char).
    This would also make your life easier by allowing bit manipulation to slice/move parts and reducing work for the processor because base 100 means integer divisions, and base 64 means bit shifts. If you want to go down the road of a “complicated” base use base 38 and get similar drawbacks as now, except only 5.25 bits per char.







  • I think you should make the overwhelmingly likely case crash in a controlled way, but provide a way to handle it for people who truly want to keep going in such strange conditions.

    In rust I would panic in now(), but also provide a alternative call that returns a result named something like try_now(), similar to Vec::with_capacity and Vec::try_with_capacity.
    In languages that provide them, you could also throw a runtime exception that can be ignored and just bubbles up to main unless explicitly caught.





  • Rust has monomorphisation like C++ and every function has the aliasing guarantees of restrict, a keyword rarely seen in C code bases use and C++ doesn’t even support.
    This means you can get more optimisations while writing in an intuitive style, where C/C++ requires some changes to the code.

    On the other hand rustc has some hiccups with argument passing and rvo. One could argue that that’s just the compiler while the aliasing problems are part of the language in the C/C++ case, but while there is only one rust compiler its performance is the languages performance.

    For most use cases they are about equally fast.