• 0 Posts
  • 20 Comments
Joined 1 year ago
cake
Cake day: September 2nd, 2023

help-circle



  • I don’t have the data, but I don’t think it’s wild to assume that most rust programs have 0-1 unsafe blocks, in total. Except for special cases like ffi.

    Even if your rust project has 1000s of unsafe blocks, it is still safer than C++, which is 100% an unsafe block. You only have to carefully review the parts marked “unsafe”, in C++ you have to carefully review the whole code.

    Also, because unsafe blocks are explicitly declared, you know which parts of the code require extra carefulness, and if you encounter a memory bug, doing Ctrl+F “unsafe” will soon show the root cause.


  • At least one drawback I can see is that apparently the user has to manually opt-out some macros (the ones that aren’t pure) of the caching. Which would require everyone using the rust compiler to know which macros of which crates are pure and which ones not. I guess that the ones writing the macros could do that, but then you rely on library maintainers to know about this specific optimization.

    It really should be opt-in so the maintainers of libraries that know about the optimization and know that their macro is pure can annotate them as so.












  • I’m doing mostly hobby graphics stuff with wgpu

    My latest project is a live visualizer of wgsl shaders.

    I chose rust because it’s the only language that meets all these points:

    • Compiled (which implies it will be fast and native)
    • no GCC (which means it will be faster if used correctly)
    • it’s not a pain to work with (unlike C and C++). The IDE is great and simple, the build tools (cargo) are great and simple, static linking by default (no missing .dll/.so errors)
    • Fast development times. Runtime errors are very limited, so you go slow (addressing the very common compiler errors) so you can go fast (very little debugging in comparison with other languages).
    • enums. Rust’s type system is great, specially the enums and pattern matching.
    • static and explicit typing: no surprises, everything is in the function header.
    • inmutable values by default: mutable values are explicitly stated as so.