4 ms·
Ive always wondered something: comparing to languages like Swift, is Rust really better if it takes so much cognitive overhead and architectural backflips to wo
by moldavi 6y ago
Ive always wondered something: comparing to languages like Swift, is Rust really better if it takes so much cognitive overhead and architectural backflips to work around the borrow checker's limitations? Couldnt we be spending that time adding features, or optimizing the parts of the program that the profiler shows us are inefficient?
Using Rust seems like it would make sense for an extremely low-level performance-sensitive application, but do people use it for higher level things? If they do, why?
- nevi-me 6y agoI think after a while writing the language, you're able to reason about your object memory with little friction from the compiler. On the Rust-written projects that I work on, I rarely have significant compiler errors that impede on my efficiency in adding new features. After a while, you know that you're mutably borrowing something, or that you're crossing a thread boundary and are carrying something not thread-safe along. Maybe like other low-level languages there's a large learning cost, but it gets better after a while.
- fasterthanlime 6y agoPeople definitely use it for higher-level things, and it's nice there as well - not the same level of comfort as a garbage-collected language, but still very nice. When writing code that isn't that performance-sensitive, cloning is often an option (and gets you past a lot of grief with lifetimes), so is reference counting, etc. Rust's set of rules just means you can never, for example, accidentally hold a reference to a value that's been freed - it'll error out, and then you can pick whether you meant to borrow it, to share ownership with reference counting, or to clone it.
- heldrida 6y agoThat's a very good question and deserves its own thread. Personally, I remember an interview of Keith Haring just before he passed away; he wasn't sleeping much to put as much of his ideas out as quickly as he could, he was about to die. He said something like he'd rather spend the time creating then perfecting his art. I don't know exactly what his words were but what he said made a lot of sense to me. The popularity of C++ keeps growing for some reason and Swift offers a great dev experience! On top of that, the layoffs in the Servo team is quite telling about how profitable the work they've put was.
- Measter 6y agoI would pick Rust if I had the choice and libraries were available. Personally, I've found that the borrow checker for the most part doesn't get in the way. But part of the reason for that is because I've used Rust enough to know what the borrow checker expects, so I would just design things in a way that get accepted in the first place without having to think about it. Someone new to the language won't have that prior knowledge, and will be more likely to run into the borrow checker and get frustrated because of it. So with that in mind, I don't really find the cognitive overhead to be high when writing Rust. I also find that I like having the control over what can mutate what, and knowing that information by looking at the function signatures or variable definition. Also, Rust has all of the features I liked in Haskell when I tried it, while putting them into a package that is more familiar and comfortable to me.