4 ms·
>""If it compiles it works" happens often to me, which is why I'm such a fanboy." This completely ignores domain / logic /algorithmic errors which in my experi
by FpUser 4y ago
>""If it compiles it works" happens often to me, which is why I'm such a fanboy."
This completely ignores domain / logic /algorithmic errors which in my experience completely dwarf types of errors Rust is supposed to take care of.
- bryanlarsen 4y agoRust is fabulous at avoiding those types of errors. Use rich types to avoid domain errors, use Rust's enum's to hold state data and then use exhaustive match etc to avoid logic and algorithmic errors, use wrapping_add et al to avoid arithmetic errors.
- FpUser 4y agoThese features are helpful no doubt but would in no way guarantee "if it compiles it works" promise.
- pdw 4y agoNobody made a promise. The comment you're reacting to said "happens often to me".
- bryanlarsen 4y agoIt only has to help infrequently for it to be a win. And it helps more than infrequently.
- mcronce 4y agoIt's not a promise, it's an observation
- pdw 4y agoI think you underestimate memory errors. In large C and C++ projects, ~70% of discovered security vulnerabilities have memory errors as their cause. Source: https://alexgaynor.net/2020/may/27/science-on-memory-unsafety-and-security/ https://alexgaynor.net/2020/may/27/science-on-memory-unsafet... On the other hand, Google reports that "to date, there have been zero memory safety vulnerabilities discovered in Android’s Rust code." Source: https://security.googleblog.com/2022/12/memory-safe-languages-in-android-13.html https://security.googleblog.com/2022/12/memory-safe-language...
- jokethrowaway 4y agoIf you use the type system well you rarely get wiring issues you would normally get at runtime (wasting an entire "programming cycle" of writing code and trying it out). But overall I agree: you need tests for business logic. Another thing that Rust gets right is that you're incentivised to write some tests right in the same file where you're writing the implementation (it just works out of the box with cargo test), so even complex logic is easy to test out. You don't have to go through the "oh, let me setup mocha to add a test... never mind I won't bother right now"
- FpUser 4y ago>"If you use the type system well you rarely get wiring issues you would normally get at runtime (wasting an entire "programming cycle" of writing code and trying it out)." I assume this goes for scripting languages with weak / no typing. >"You don't have to go through the "oh, let me setup mocha to add a test... never mind I won't bother right now"" Same thing.