Hacker News new | ask | show | jobs
by mehrdadn 2116 days ago
Yeah it's all subjective. On my end concepts kind of seemed unnecessary to me (albeit useful) given you could just write unconstrained templates. In fact I still expect most people to do that a large fraction of the time just due to the diminishing returns. Ranges seemed more necessary but not particularly sophisticated machinery to live without (and I'm curious how much performance impact the templates have too). Whereas coroutines and modules are not only incredibly useful but also quite sophisticated underneath and also quite difficult (or I guess impossible, in the case of modules) to simulate by hand.
5 comments

Concepts are great because we can get rid of all tag dispatching/partial ordering/SFINAE hacks with a more principled (and understandable) approach.
with concepts you also get

    void f(auto x) { } 
or

    void f(Sortable auto x) { } 
as a bonus, which is super neat imho and will reduce the amount of template<> syntax verbosity by a good margin
Concepts will stop people in HN complaining they cannot understand templates. It significantly reduces the template magic in C++ libraries.
Depends on your perspective. Concepts are great if you’re writing libraries and you need to give your user better errors.
Yeah I do expect some very well-written libraries (including standard libraries) to pick it up and use it well, which will benefit a lot of people as these will be widely used libraries, but my guess is most other C++ programmers will not use concepts in nearly as many cases as they hypothetically could/should. Maybe they'll write a few concepts to document the occasional clean interface, but that's about it. The reason being that I expect concepts will have underestimated costs: duplicated logic will not only be frustrating but also get out of sync easily, templates will slow down compilation (it's not like we don't have enough of that already), precise constraints end up being difficult to write, and approximations end up being overly strict/loose and result in headaches for users of a library.

They do seem quite beautiful and useful in theory, but I will be very curious to see how much they're adopted.

> They do seem quite beautiful and useful in theory, but I will be very curious to see how much they're adopted.

For sure! I expect some marquee libraries like ITK to adopt them as soon as it’s prudent (meaning when they can sunset support for older compilers), but most people won’t be using them.

I mean, most people don’t have to even really write templates code...

Oh right, but I meant even by people who do write templates haha. I'm wondering in what fraction of cases they'll actually use concepts when they potentially could.
Concepts are a huge improvement to help new users learn the language. Large, unclear errors are a big put-off.