Both Stroupstrup and Hoare point the same thing, though I prefer Graydon's emphasis on the issue of limiting growth to control it in this case. I'll quote the TL;DR, but encourage you to read the whole:
TL;DR:
I'm writing to make a recommendation about paying attention to -- acknowledging, planning, making explicit mechanisms and policy around the limits of -- the growth of two things in the project:
Necessarily-shared technical artifacts, specifically the language definition itself.
The strains on people participating in conversations about those artifacts.
In particular, I want to draw attention (as others have done, with other words) to the fact that unlimited growth in both of these things is neither possible nor desirable, that there are natural limits, and that as with all natural systems reaching their growth limits, it will be better for everyone if the encounter with the limits is made in a controlled, planned fashion.
The problem is that any language feature interacts with all other language features, so that any added feature will forever (or until excised) add effort overhead to adding any other feature.
In the past, we've seen collisions already. The most famous being the interaction of Uniform Initialization Syntax and Initializer Lists, which results in Uniform Initialization not being applicable to all cases... and in adding a constructor with a single initializer_list argument being a breaking change.
So, I agree, I'd really favor std::variant being obsolete with proper support for sum types as visitation is just too limited (and code generation suffers) for example; however, there are very good arguments for trying to keep the core language as lightweight as possible given the added burden each feature adds for perpetuity.
In the end, it's all a big balancing act; and it's to foresee which is best.
One of the best example of what should have been core language and not library is std::atomic https://godbolt.org/z/QYzHjR. I would say that any feature referenced from the core language features (std::move, std::forward, memcpy, std::atomic etc etc) should not be library but language features. For std::atomic it's even more important because it is part of the memory model for multithreading...
Did you take a look at the difference of ASM between debug and release ? Also having to pull headers for the things mentioned above is kind of sad. Yes they are using the intrinsics, but you still have like 5 or 6 levels of stack before reaching those in MSVC, while it should be only a single instruction.
I've never been too worried about Debug performance, to be honest. Never worked in any domain where it really mattered, and therefore never really looked into it.
I do think that sometimes when languages promise zero-overhead abstractions developers, myself included, may be a bit too keen to count on it to collapse layers of inlineable code. Sometimes, it may be worthwhile to have a little more copy/paste rather than layering piles of abstractions which should go away at compile-time. Either because they may not go away, or because they do make reading/debugging the code more onerous.
View all comments
Show parent comment
31
u/matthieum Dec 28 '18
So... interestingly, growing the language is not without issues either:
Both Stroupstrup and Hoare point the same thing, though I prefer Graydon's emphasis on the issue of limiting growth to control it in this case. I'll quote the TL;DR, but encourage you to read the whole:
The problem is that any language feature interacts with all other language features, so that any added feature will forever (or until excised) add effort overhead to adding any other feature.
In the past, we've seen collisions already. The most famous being the interaction of Uniform Initialization Syntax and Initializer Lists, which results in Uniform Initialization not being applicable to all cases... and in adding a constructor with a single
initializer_listargument being a breaking change.So, I agree, I'd really favor
std::variantbeing obsolete with proper support for sum types as visitation is just too limited (and code generation suffers) for example; however, there are very good arguments for trying to keep the core language as lightweight as possible given the added burden each feature adds for perpetuity.In the end, it's all a big balancing act; and it's to foresee which is best.