Re:Bugs that the Rust compiler catches for you
by tylerhou on Thursday May 05, 2022 @06:34PM
(#31279120)
In addition, most of these checks are provided in other languages or linters for those languages. E.g. C++ has had RAII before Rust has existed. C++ (with -Werror), TypeScript and most FP languages have exhaustive switch checking. Clang can catch many (but not all) initialization errors. The places where Rust adds value (data races, memory safety, explicit unsafe) are not discussed in the article.
[ Parent
| on HN ]
Re:Bugs that the Rust compiler catches for you
by nicoburns on Thursday May 05, 2022 @08:23PM
(#31279758)
Rust also adds value in providing so many of th checks where most languages only have a subset, and being incredibly consistent in having safe defaults.
Re:Bugs that the Rust compiler catches for you
by tylerhou on Thursday May 05, 2022 @10:03PM
(#31280427)
Not untrue, but the post doesn’t mention prior work, so it’s implying that Rust is one of the only languages that has these features, whereas even C++ (notorious for being unsafe) as a majority of the features (in Clang). Clang can even catch many data race issues with the proper annotations. Maybe it’s ignorance, but given how posts proselytizing Rust tend to get popular on HN, it makes me suspicious that the omission was intentional.
> In addition, most of these checks are provided in other languages or linters for those languages.
Linters are inferior to things the compiler catches for the same reason test cases are inferior: They are not enforced. If the compiler doesn't allow something you can say with confidence you will never see it in the wild. With linters, compiler switches (-Werror) or test cases you'll have no idea.
Re:Bugs that the Rust compiler catches for you
by SemanticStrengh on Thursday May 05, 2022 @08:04PM
(#31279645)
I would like to see more about atypical language protections.
GCC has many underknown flags that protects against very specific things.
Kotlin is the first popular language to support structured concurrency, eliminating many classes of concurrency errors.
It's basically "RAII" for threads, coroutines.
Tailrecursive and deeprecursive allow for making any recursive function stack-overflow safe.
I guess C# isn't popular.
Re:Bugs that the Rust compiler catches for you
by SemanticStrengh on Friday May 06, 2022 @10:04AM
(#31285241)
It is of course but I doubt C# has structured concurrency?