Follow

I've just realized that has eliminated defensive coding for me.

Defensive coding is "I know it's not supposed to be `null`, but I'll check just in case" or "I know the caller isn't supposed to mutate or free this object, but I'll make a copy just in case" or "I know that function should be thread-safe, but I'll avoid threads just in case"

In Rust nullability, mutability and thread-safety are encoded in types, so I never have to second-guess them.

@kornel
I currently have to code Python at work and yeah, I hate the uncertainty that its untypedness introduces. You just have to assume that the 'json' object, that you've declared to be shoved into your function, is a string.

If you don't write five lines of code to check its type yourself, you'll crash at a random position in your code and the error reporting will be atrocious.

And any libraries you use, also struggle with this, so you can't even assume that they work correctly.

@friend Yeah, dynamically typed languages are a completely different beast.
I do like gradual typing. It's not a 100% solution, but gets you to 80% quickly.

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!