News for hackers. Stuff that matters.
Re:C++20 Concepts: The Definitive Guide by s-luv-j on Sunday August 22, 2021 @12:09PM (#28266636)
Is it just me, or have C++ errors gotten a lot better? Below example from guide seems a lot more ergonomic than in years past.

  test.cpp: In instantiation of ‘T add(T, T) [with T = std::basic_string<char>]’:
  test.cpp:17:21:   required from here
  test.cpp:11:22: error: static assertion failed
   11 |   static_assert(std::is_integral_v<T>);
      |                 ~~~~~^~~~~~~~~~~~~~~~
  test.cpp:11:22: note: ‘std::is_integral_v<std::basic_string<char> >’ evaluates to false
Build finished with error(s).
Re:C++20 Concepts: The Definitive Guide by Someone on Sunday August 22, 2021 @12:34PM (#28266880)
One of clang’s stated goals is “expressive diagnostics”

See https://clang.llvm.org/diagnostics.html ; that page is not dated, but compares to gcc 4.9, which is from April 22, 2014.

gcc also has worked on improving its error messages (most likely because of competition with clang), so that comparison probably isn’t accurate anymore.

Re:C++20 Concepts: The Definitive Guide by bool3max on Sunday August 22, 2021 @01:24PM (#28267489)
The link leads to a 404.
Re:C++20 Concepts: The Definitive Guide by mananaysiempre on Sunday August 22, 2021 @07:59PM (#28270906)
The comment markup parser mistakenly understood the link to include the following semicolon, but you couldn’t clearly see it because the semicolon’s descender hid the underline.
Re:C++20 Concepts: The Definitive Guide by Someone on Sunday August 22, 2021 @01:43PM (#28267675)
Thanks; HN thought the semicolon was part of the URL. Added a space.
Re:C++20 Concepts: The Definitive Guide by tialaramex on Sunday August 22, 2021 @12:23PM (#28266779)
There has been more interest from modern programming languages and modern compiler developers in good diagnostics in two ways: 1. The earlier you report the problem, the cheaper the fix and 2. The better the diagnostic the more likely the programmer's fix is appropriate to the actual problem they had.

I agree this is great news. I actually had to write MS SQL for the first time last week and it was disappointing but sadly expected to have it respond to a common but not technically-standard SQL syntax I'm used to with "Syntax error" as though somehow that's helpful. Such poor errors meant I spent more time reading the documentation than writing queries even though I've years of experience across several other SQL dialects.

Re:C++20 Concepts: The Definitive Guide by afranchuk on Sunday August 22, 2021 @12:24PM (#28266790)
Yeah, and besides the focus on error messages in past years, concepts will naturally allow template errors to be a _lot_ clearer, since they can serve as the specification of templated type requirements.
Re:C++20 Concepts: The Definitive Guide by laszlokorte on Sunday August 22, 2021 @12:23PM (#28266780)
One of the major motivations for concepts is to allow better error messages.
Re:C++20 Concepts: The Definitive Guide by google234123 on Sunday August 22, 2021 @12:28PM (#28266821)
And ironically it’s questionable if it helps. Worse error messages were one of the main reasons it got blocked from 17.
Re:C++20 Concepts: The Definitive Guide by leni536 on Sunday August 22, 2021 @12:19PM (#28266747)
It's not just you, dinostics continuously and noticably improve. A lot of effort is spent on this.
Re:C++20 Concepts: The Definitive Guide by secondcoming on Sunday August 22, 2021 @06:08PM (#28270139)
Yes. I had build failures related to LTO on our production code that uses gcc 7.5 (Ubuntu 18.04). I had to build it with gcc 9.1 (Ubuntu 20.04) in order to get a useful error message that saved me an hour or two of faffing about.
Re:C++20 Concepts: The Definitive Guide by agumonkey on Sunday August 22, 2021 @01:39PM (#28267635)
clang kinda started the race
Re:C++20 Concepts: The Definitive Guide by pjmlp on Sunday August 22, 2021 @03:49PM (#28268888)
And now lags behind in C++20 support, as apparently not everyone is keen to upstream whatever they are doing.

Clang concepts were implemented by one guy.

https://cppcast.com/saar-raz-clang-hacking/

Re:C++20 Concepts: The Definitive Guide by agumonkey on Monday August 23, 2021 @10:23AM (#28276201)
Strange
Re:C++20 Concepts: The Definitive Guide by pjmlp on Monday August 23, 2021 @04:12PM (#28281306)
Actually not that strange.

Apple doesn't really care about C++20. Their LLVM efforts are focused on Objective-C and Swift.

C++ as used on Apple platforms is mostly related to the Metal Shading Language (a C++14 subset) and IO/Driver Kit (an Embedded C++ variant).

Google has their style guide, only recently updated to C++, isn't a compiler vendor and apparently losing on the ABI vote has made several employees move away from their clang involvement.

Then the other vendors like Intel, Embarcadero, IBM, Codeplay, Sony, Nintendo, ARM, NVidia, AMS have their own agendas and do not upstream everything.

Re:C++20 Concepts: The Definitive Guide by lamp987 on Sunday August 22, 2021 @01:37PM (#28267615)
That has nothing to do with C++. Its entirely a compiler thing.
Re:C++20 Concepts: The Definitive Guide by wk_end on Sunday August 22, 2021 @01:58PM (#28267809)
Not entirely true - one of the motivations for new features and libraries C++ adds is to make better errors possible. In this case, `static_assert` was added in C++11, and `is_integral_v` was added in C++17. Concepts, the new feature this post is about, falls under that category as well.
Re:C++20 Concepts: The Definitive Guide by pharmakom on Sunday August 22, 2021 @01:54PM (#28267779)
True, although the distinction hardly matters to users.