3 ms·
> Rust has a much stronger type system and the borrow checker. Both make bugs far less likely. I really prefer strong type systems over weak ones, but despite
by brabel 3y ago
> Rust has a much stronger type system and the borrow checker. Both make bugs far less likely.
I really prefer strong type systems over weak ones, but despite that, I always like to point out that there's no evidence that strong type systems cause "bugs to be far less likely". No study I've seen (quite a few) has ever shown that.
There's a few bugs that become impossible (in Rust, some kinds of data races for example) but the vast majority of bugs can still occur and in practice, do occur.
- orwin 3y agoThe main advantage to me is more that I don't have to write tests to test type integrity accross functions.
- lelanthran 3y agoI've never found myself doing that in Go.
- orwin 3y agoI was talking about strongly typed languages, which Go is. That's why I'd rather use go than python at my job (not an option though).
- IshKebab 3y agoRust is even more strongly typed than Go, so it reduces the chance of bugs even more. The borrow checker also reduces the chance of bugs. It was originally created just for memory safety, but it turns out that the ownership structures that it enforces are less bug prone. It's quite similar to how using immutable data structures leads to less bug prone code.
- IshKebab 3y ago> No study I've seen (quite a few) has ever shown that. There's a really great one that shows that Typescript or Flow prevents around 15% of Javascript bugs. It would be difficult for a study to show that Rust's strong typing or borrow checker prevents bugs, but anyone who has used Rust extensively knows it to be true. It's similar to Haskell's strong types and immutability preventing bugs. Google "if it compiles it works". I think you could do a study to prove this, but experiments aren't the only way to get knowledge. They are the best when possible but sometimes they are impractical. Programming language studies tend to focus on "get some students to spend a few hours writing code from scratch" tasks which can even lead to conclusions that are the opposite of reality for realistic programming. For example that static types hurt productivity. > the vast majority of bugs can still occur and in practice, do occur. Right, but they are much less likely to occur.
- brabel 3y agoCould you please link to the Typescript study? > anyone who has used Rust extensively knows it to be true. I have used Rust extensively and have no idea whatsoever is that's true, and if you think you do, be prepared to be wrong about that, as humans are incredibly "good" at being sure that something is true until formal studies show you were wrong. Haskellers have said "if it compiles it works" for a long time, but have never been able to prove that. Again: just saying/feeling something is true doesn't make it true. > Right, but they are much less likely to occur. No, there's just no evidence! Just go to any Rust project, they have as many bugs as anything else... I wish that were false, because then I would definitely just use Rust for everything myself... but that's not at all what I've seen so far.
- kreetx 3y agoAs having written a lot of Haskell, I can tell you that people do create bugs there as well, (IMO) to a similar degree as in other languages. The choice of languages seems to come down to personal preference, as does the propensity to create bugs (come down to the specific developer). ;)
- brabel 3y ago100%. Every single study always agrees on that: developer skills completely shadow any differences between programming languages - even between categories of programming languages, like dynamic VS static typed-languages.
- IshKebab 3y ago[dead]
- ssokolow 3y agoWhile it's not a study, https://blog.polybdenum.com/2023/03/05/fixing-the-next-10-000-aliasing-bugs.html https://blog.polybdenum.com/2023/03/05/fixing-the-next-10-00... gives a real-world example of a bug in Go Rust would have prevented. Also, bear in mind that it's not just Rust's type system directly that prevents bugs, but also the patterns it enables. For example, the typestate pattern and its use in things like turning misuse of the HTTP protocol into a compile-time error in Hyper. https://cliffle.com/blog/rust-typestate/ https://cliffle.com/blog/rust-typestate/