3 ms·
> The huge advantage that Rust has over languages like JavaScript is that if it compiles, it's almost guaranteed to run (unless you have logic errors somewhere)
by pimeys 10y ago
> The huge advantage that Rust has over languages like JavaScript is that if it compiles, it's almost guaranteed to run (unless you have logic errors somewhere). I think that fact is greatly under-appreciated.
This. In my company, our Rust apps have a very small amount of tests, mostly integration tests written with Python. You need to test certain business logic, but mostly if it compiles, deploy all the things :)
- vog 10y ago"If it compiles, it works." You don't hear this often, but when you hear this, people a usually talking about either OCaml or Haskell. Nice to see Rust joining this club, too. I often rephrase this as: "When switching from Python(/Ruby/PHP) to OCaml(/Haskell/Rust) you notice how many of your unit tests were really just type checks."
- pimeys 10y agoBut then again, there are some gotchas. Runtime errors can happen when using unwrap like in every example around the Internet. I too used the unwrap everywhere when I started writing Rust, but soon realized that one must handle the results and everything can be an Err or None, even if you think it is not possible. I'd say beginner tutorials should UNDERLINE that the use of unwrap() is just for the first prototype and you must refactor them out to proper error handling.