How long before the borrow checker stops feeling like an argument every day Learning
Six weeks in, coming from ten years of Python and some C. I can write code that works but I spend maybe half my time restructuring things to make the compiler happy, and I never predict in advance which design will be fine. People who got past this: roughly how long did it take, and was there a specific concept that flipped it, or is it just volume of hours?
@borrowck_ben · 10mo ago · 2 replies
Around three months for me before I stopped being surprised, and the thing that flipped it was learning to decide ownership before writing the struct rather than after. Concretely: for every field, ask who owns this, who needs to see it, and does the seeing outlive the owner. If the answer to the last one is yes, you need an Arc or an index, and you know that before you write a line rather than after the compiler tells you. Once the design carries the answer, the errors mostly stop.
Reply
Report
@flux_and_solder · 10mo ago
Deciding it up front rather than discovering it is a completely different mental habit from what I've been doing. Going to try that on the next module.
Reply
Report