by kitkat_new · 5y ago · 0 comments
Rust is ideal for that if you have the opportunity to use it
I would argue the opposite. It's easier to understand what's happening when you know at a glance what datatypes are involved, whether they're used by value or reference and how each case is handled. When I last worked with Python it was rather time consuming to fix bugs that crashed a script at some point after 10 minutes of processing, caused by code that would have thrown a clear compiler error in some languages and would have been fixed in seconds.
And when I look at e.g. a Rust function signature I immediately see what kind of data is used as arguments and what's passed back in the result. Meanwhile in JavaScript you just need to forget a symbol in a check and suddenly it won't know the difference between "false", "null" and "undefined".
You are right about integrating third-party systems, but I still prefer the approach where possible issues are discovered as early as possible.
If I know how the external system will behave then yes Rust is better, obviously. However I was talking on the case of figuring out, as the article says. Sometimes you are not even there, you integrate with an external (legacy? undocumented? buggy?) system and you need to understand what's going on. In these cases a dynamic language is so much more productive than Rust and any Rust-like language.
Or even better, if both is the same. That's the reason why, as much as I like Rust, I would never use it for a project where performance is not critical.
That makes it just less transparent. You still have to be careful and know the difference or one day you unintentionally create a shallow copy of an object and now you've got a bug the runtime won't warn about. Yes, Rust is more complicated and harder to get into in those areas, but in return it's not as ambiguous. I know that calling `clone()` will always do just that, no edge cases, and even if I were wrong the compiler would immediately tell me because of a type mismatch.
Realistically I don't think any of the two approaches is significantly faster. But I know what I find more consistent and less frustrating to debug.
I can only hope for Rust 202X edition that can introduce new syntax / deprecate another and make certain things clearer (even if that means explicit with a little writing here and there). Lifetimes and traits in particular need a lot of upfront investment to grok intuitively, and the fact that some core aspects of the language are implied can later hit your assumptions really hard and confuse you for a while. At least that's happened to me, maybe I am just dumb and mediocre though.
In fact, I argue that people should always choose a technology by how easy it is to figure a problem out two years into development.
If you find Pry useful, I'd be curious what you think about Glamorous Toolkit.
A lot of time spent maintaining / understanding the codebase is time spent thinking about edge cases and about what can go wrong.
I had a similar experience with Haskell, but in Haskell you also have to think about laziness and what the computer will actually try to do, which complicates things a bit.
The amount of brain wankery you initially put in your architecture is inversely proportional to onboarding time for new staff. This problem is no stranger to Java (and Rust, it seems) projects.