logoalt Hacker News

112233yesterday at 6:45 AM3 repliesview on HN

I see this argument often. It is valid right until you get first multipage error message from a code that uses stl (which is all c++ code, because it is impossible to use c++ without standard library).


Replies

OneDeuxTriSeiGoyesterday at 12:19 PM

Those aren't the ugly part of C++ and to be entirely honest reading those messages is not actually hard, it's just a lot of information.

Those errors are essentially the compiler telling you in order:

1. I tried to do this thing and I could not make it work.

2. Here's everything I tried in order and how each attempt failed.

If you read error messages from the top they make way more sense and if reading just the top line error doesn't tell you what's wrong, then reading through the list of resolution/type substitution failures will be insightful. In most cases the first few things it attempted will give you a pretty good idea of what the compiler was trying to do and why it failed.

If the resolution failures are a particularly long list, just ctrl-f/grep to the thing you expected to resolve/type-substitute and the compiler will tell you exactly why the thing you wanted it to use didn't work.

They aren't perfect error messages and the debugging experience of C++ metaprogramming leaves a lot to be desired but it is an order of magnitude better than it ever has been in the past and I'd still take C++ wall-o-error over the extremely over-reductive and limited errors that a lot of compilers in other languages emit (looking at you Java).

show 2 replies
wheybagsyesterday at 10:18 AM

And I see this argument often. People make too much fuss about the massive error messages. Just ignore everything but the first 10 lines and 99.9% of the time, the issue is obvious. People really exaggerate the amout of time and effort you spend dealing with these error messages. They look dramatic so they're very memeable, but it's really not a big deal. The percentage of hours I've spent deciphering difficult cpp error messages in my career is a rounding error.

show 1 reply
1718627440yesterday at 10:50 AM

> it is impossible to use c++ without standard library

Citation needed. This is common for embedded application, since why would anyone program a STL for that?

show 2 replies