3 ms·
I have never seen better error messages than those coming from the Rust compiler, rustc. I have never seen worse error messages than those generated by GNU GCC
by jll29 5y ago
I have never seen better error messages than those coming from the Rust compiler, rustc.
I have never seen worse error messages than those generated by GNU GCC's C++ compiler, g++ (except if you count no error message, perhaps).
- GuB-42 5y agoI didn't try rustc, but g++ error messages have improved a lot in the last decade or two. I think clang made a point of having better error messages, and g++ followed suit. One reason C++ error messages are so terrible is because of metaprogramming. C++ has a very powerful template system that has been abused a lot, not only that, but it retained the C preprocessor. When you are just using an API (ex: boost), all the complexity is hidden away from you, you just have to use the convenient features, but to the compiler, it is a horrible mess of templates and when you do something wrong, the mess surfaces. A lot of what makes modern C++ is just cleaner ways of doing what was done using clever hacks before. It had a positive impact on error messages, but C++ is still a really complex, tricky language, with error messages to match.
- codeflo 5y agoThere are different kinds of error messages in C++, all of them terrible, but each for different reasons. Template error messages are often best understood as stack traces of the “metaprogramming language”, which isn’t C++, but a complicated type substitution system that beginners don’t understand when they first encounter these errors. So that’s confusing. But I found that the hardest errors for beginners are linker errors: They look like line noise and contain no easily readable information to point at the source of the problem. It shouldn’t be necessary to explain linker hacks from the 80s when teaching someone how to find out what they forgot to implement.
- GuB-42 5y ago> But I found that the hardest errors for beginners are linker errors I am with you on that one. I just didn't consider the linker as part of the compiler. I mean, wtf is a ctor and a vtable? Now, I know, but when I started programming, the linker was the scariest part for me, and it took me a while to be somewhat comfortable with it. Obviously, error messages didn't help. The good thing is that linkers (static and dynamic) don't change as much as compilers, so it is useful knowledge in the long run. Understanding ELF files really helped me on that one.
- delusional 5y agoI find Rusts error messages a little verbose for my taste. Sometimes it's hard for me to parse what's the actual error, and what's just "helpful hints" about where the real error is. That brings up and interesting point missed in the OP. The term "Good error messages" is also context dependent. Rust has to have verbose error messages, because those messages are doing a lot of the heavy lifting of teaching people the "high concept" of rust (lifetime analysis). So we see that good error messages (like all writing) also depends on the audience. Your log message that "config.yaml couldn't be parsed because key x has a wrong value" might be great for someone writing the config.yaml himself, but for someone using a configurator gui, that may be next to useless. By the same logic I'd also expect Rustc's error messages to become less verbose in the future, as people get more familiar with rust and don't need as much guidance.
- oweiler 5y agoPretty sure Rust took a lot of inspiration from Elm https://elm-lang.org/news/compiler-errors-for-humans https://elm-lang.org/news/compiler-errors-for-humans