How does Rust help prevent logic bugs? I thought tests helped prevent logic bugs. Or does the author mean "works" in that it runs where an interpreted language would not (i.e, syntax error)?
How does Rust help prevent logic bugs? I thought tests helped prevent logic bugs. Or does the author mean "works" in that it runs where an interpreted language would not (i.e, syntax error)?
Rust excels here, in my mind, because of its expressive type system which can allow you to encode logical building-blocks as types and hoist the logic into the type system, eliminating even more specs in favor of compiler errors.
Ultimately, with a sprinkling of logic tests, you can feel confident that compilation means success.
Enums help prevent a lot of logic errors.
> Or does the author mean "works" in that it runs where an interpreted language would not (i.e, syntax error)?
More than that, but close. i.e. you won't get NPE from java. Syntax error or type mismatch from interpreted language.
In addition, NewType pattern will stop you from passing seconds into a function that takes ms and vice versa. You won't get data races. You also won't get an `undefined is not an object`.
Long story short, due to language verbosity it's hard to make logical mistakes.