by quincepie · 2y ago · 0 comments
I would say the #1 reason I stop learning a technology is because of frustrating or unclear errors.
EDIT: Getting a bit of topic, but I meant more because I love C and would love it more with rust level error messages.
In my opinion, the complexity of the interactions between C++'s {preprocessor, overload resolution, template resolution, operator overloading, and implicit casting} can make it really hard to know the meaning of a code snippet you're looking at.
If people use these features only in a very limited, disciplined manner it can be okay.
But on projects where they don't, by golly it's a mess.
(I suppose it's possible to write a horrible mess in any language, so maybe it's unfair for me to pick on C++.)
This is a veering off topic, but I do agree that Nix-the-language has a lot of issues.
(You might suggest Guix, but I don't want to faff about with non-supported repositories for table stakes like firmware and such. Maybe Nickel will eventually provide a more pleasant and principled way to define Nix configurations?)
infinite recursion encountered, at undefined positionPeople getting used to good errors and demanding more, is part of the virtuous circle that keeps them high quality.
Making good looking diagnostics requires UX work, but making good diagnostics requires a flexible compiler architecture and a lot of effort, nothing more, nothing less.
Go read the above.
Overly verbose error messages that obscure more than illuminate are chief complaint against C++.
Honestly, they can just sap all the energy out of a project.
It's why the Constraint system was important for C++.
Why would anyone use the resulting language over C? What you're describing is C with a slightly friendlier compiler.
(Signed overflow being a prime example where you really either just need to define what happens or accept that your compiler is basically never going to warn you about a possible signed overflow -- which is UB. The compromise here by Rust is to allow one to pick between some implementation defined behaviors. That seems pretty sensible.)
... but the question is really what you ship to production.
Btw, possible signed overflow was just an example of things people do not want warnings for. OOB is far more dangerous, obviously... and the cost for sanitizer in that case is HUGE... and it doesn't actually catch all cases AFAIUI.
Another is reproducibility and accuracy: LLMs have a tendency to confidently state things that are wrong, and to say different things to different people, the compiler has the advantage of being deterministic and generally have better understanding of what's going on to produce correct suggestions (although we still have cases of incorrect assumptions producing invalid suggestions, I believe we have a good track record there).
If those tools help you, more power to you, but I fear their use by inexperienced rustaceans being misled (an expert can identify when the bot is wrong, a novice might just end up questioning their sanity).
Side note: the more I write the more I realize that the same concerns I have with LLMs also apply to the compiler in some way and am trying to bridge that cognitive dissonance. I'm guessing that the reproducibility argument, ensuring the same good error triggers for everyone that makes the same mistake and the lack of human curation, are the thing that makes me uneasy about LLMs for teaching languages.
I was so impressed with gpt-4's ability to diagnose and correct errors that i made this app to catch python runtime errors, and automatically make gpt-4 code inject the correction: https://github.com/matthewkolbe/OpenAIError
> "Missing semicolon on line 32"
I looked at it, looked at them, and said "You're missing a semicolon on line 32". They looked at line 32 and, hey! look at that! Forgot a semicolon at the end. Added it and their program worked fine.
Even the best error messages can't help some people.
I tried to use GCC's analyser several times, but I couldn't find any good front ends to it that make the output readable. Clang has multiple (reasonably good HTML output, CodeChecker, Xcode integration, etc.). How do you read the output?
Furthermore, I find that GCC produces many more false positives than Clang.
I do find some false positives, but I haven't had many of them to be a deal breaker for me. Aside from what I mentioned about the errors being descriptive, I do like the defaults and that it's part of the compilation process.
for example, possible malloc null warning is on by default (which i don't think is on clang).