Something's been nagging me for a while; I've developed in Scala for over 10 years. I'm okay at coding, typically following best practices in functional programming to a T, but sure I've written my fair share of code stink.
I remember when Scala first started making headlines people saying: it's so type-safe, once your code compiles you know it will work! The thinking is that, assuming you're literate enough to write code that does mostly what you intend, the compiler will ensure no bugs in your code - presuming most bugs can be caught with proper type enforcement at compile-time due to lazy human errors.
...but I wouldn't say that has always been my experience in Scala. Yet, having been using Rust for 3 years, it feels much more like a true statement but I can't explain why.
If I had to answer honestly, it's that I get this feeling like Scala is still inextricably tied to Java, and at the end of the day there's still weird runtime exceptions that can creep up. Plus I find myself wrapping things in
Try constructs (or forget to when it should be...) whereas in Rust I've never even read about them! Instead in Rust I feel like the
Result types are hermetically sealing my code from unforeseen runtime exceptions, but I can't really be certain of this though so far it proves to be true.
Am I close to a theoretical truth about Rust
Result types being more resilient to extraneous runtime exceptions? Or am I just blinded by the light of Rust's hype and the placebo effect is making me think a Rust program is more resilient to catastrophic failures (due to not relying on complex garbage collectors, as much heap memory, etc)?
I love both languages still - this is not arguing against Scala. I just struggle sometimes to articulate my preferences for one language over the other; a lot of probably superstition is biasing me and I'd like to hear from others who like read about or play with both languages.