Live data from Hacker News

The Rust borrow checker from a different perspective

blog.systems.ethz.ch

1–10 of 51 posts

Re: The Rust borrow checker from a different perspective

#3

As someone who is not familiar with Rust at all, wow—what refreshingly helpful error messages!

Yes, the compiler's error messages are extremely good. They often give correct and useful suggestions on how to change code to make it compile. This can be invaluable when dealing with trickier corners of the language such as explicit lifetimes.

Re: The Rust borrow checker from a different perspective

#6

As someone who is not familiar with Rust at all, wow—what refreshingly helpful error messages!

Can someone chime in as to why C++ compilers in particular are notorious for extremely verbose yet unhelpful error messages? Is it something endemic to parsing the language that there can't be errors as helpful as Rust's?

Re: The Rust borrow checker from a different perspective

#7
post #6

As someone who is not familiar with Rust at all, wow—what refreshingly helpful error messages!

Can someone chime in as to why C++ compilers in particular are notorious for extremely verbose yet unhelpful error messages? Is it something endemic to parsing the language that there can't be errors as helpful as Rust's?

The short answer, devoid of some interesting nuance, is that C++’s template system is similar to an untyped functional programming language, so the errors you get are the compiler’s attempt to make sense of the large tree of nonsense it couldn’t reduce.

C++ also suffers from years of backwards-compatibility twister creating abundant cases of ambiguity if you do something wrong. The compiler will do it’s best, but if your code suddenly parses wildly differently because your semicolon is missing, oh well. Rust is far simpler in that regard, so there are fewer instances where your code might accidentally make sense to the compiler if you have an error.

Re: The Rust borrow checker from a different perspective

#8
post #6

As someone who is not familiar with Rust at all, wow—what refreshingly helpful error messages!

Can someone chime in as to why C++ compilers in particular are notorious for extremely verbose yet unhelpful error messages? Is it something endemic to parsing the language that there can't be errors as helpful as Rust's?

As well as templates, C++ has function overloading, so when a function is named in an error message it has to show all the arguments as well. And if it can't find a function variant that matches a call, it'll print out a "did you mean this one?" message for all of them.
Post reply on HN