Michael Murphy

System76 engineer and Pop!_OS developer

  • 1 Post
  • 8 Comments
Joined 4 年前
cake
Cake day: 2020年10月16日

help-circle



  • There’s several things that make Rust more ideal for writing software that makes efficient use of resources than C or C++.

    One of these is how cumbersome it is to use tagged unions in C/C++. They’re integrated as a first class citizens in Rust in the form of enums, and both the standard library and all Rust projects as a whole utilize them extensively. An example would be the Cow<'a, T> type. The compiler also has some clever tricks like zero-sized types which can reduce the size of types which contain them.

    On the surface, the borrowing and ownership model is useful for guaranteeing memory safety. Yet if you take that a step further, it’s the perfect tool for finely optimizing resource usage with confidence. In comparison, defensive programming practices are the norm in C and C++ because resource management is risky.