1. 23
  1. 4

    Memory management is a distraction: Actually, no. I don’t use that many lexical lifetimes and use instead smart pointers. So yes, I have to understand the differences between a Box, an Rc and an Arc, but my productivity is not impacted compared to Node.JS or Go.

    then you are simply using reference-counted pointers right? like C++. with the built-in problem that cycles in reference-counted pointers will leak memory, so you have to manually break cycles with weak-references.

    1. 14

      On the surface it’s similar, but:

      • You can’t have cycles with Box.

      • Rc/Arc make their content immutable, so if you don’t add interior mutability yourself (via Mutex, etc.) then they are free of cycles too! They’re not always used for shared-mutable state. In async code you often just need to make data safely sendable to a thread that may outlive your scope.

      • Content of Rc/Arc can be safely borrowed, so even if you need them in some places, you can still write a decent chunk of code without touching these types directly. This reduces refcounting overhead and the amount of code that needs to be mindful about cycles.