r/cpp • • Dec 28 '18

"Modern" C++ Lamentations

http://aras-p.info/blog/2018/12/28/Modern-C-Lamentations/
307 Upvotes

162 comments sorted by

View all comments

75

u/[deleted] Dec 28 '18

I’m in a similar line of work as the author, and I must say the game dev twittersphere is all up in arms about this massive groupthink about all sorts of nonsense. I would feel better about this sort of blog post if the Unity product wasn’t absolutely terrible with about the least data oriented design available (Unreal your object graph is no better). The problem with all these rants is even if there is an element of truth to them, I don’t think they are particularly effective. I’m sure if I thought for a bit I would be able to come up with plenty of cases where ranges offer better composability in a less contrived example. Is it always the first thing I would reach for? No, but I’m glad it’s going to be there for when it makes sense.

Now the part about compile times which is also the subject of another recent post from the same author... This is absolutely not the right conclusion to draw. Compile times are important, yes, but writing worse code to improve compile times seems incredibly backwards. We have things like the pimpl pattern and such for a reason. Furthermore, for those cases where we operate in massive codebases, we have other tricks up our sleeves, like defining good module boundaries and library sandboxes for testing or iterating on individual components.

If the Tim Sweeneys, John Carmacks, etc read this, please stop fueling this unproductive and heavily biased ranty holy war. I guarantee if you weighed in earlier to the committee in literally any capacity, at least a more productive dialogue may have ensued. In my case, I’ve voiced concerns to the committee before over a number of things, but within this industry I’m just one person. As for the people on the committee, I think you are better served by making the process and yourselves more approachable. Understand that for us in the trenches, it’s really tough to stomach the rigamarole needed to provide feedback on things. I remember being pretty discouraged when trying to dissuade the committee’s efforts to pursue a 2D drawing api, and I shudder to think of my industry’s backlash had it come to fruition.

The C++ community is ill and there is a large degree of separation between some of its hardcore users and its creators. The way things are, it’s tough to see things improving much, and I wish I could be more optimistic but in the worst case scenario, in the eyes of the games industry, we get an unusable form of reflection without user defined attributes, we get a networking api that isn’t performant enough to work with, a bunch of features we don’t care about because the STL is still abysmally slow (containers and IO mainly), and get alienated even further. This results in everyone being even less inclined to be cooperative on the next cycle. I know with better direction, we could be C++’s staunchest allies and supporters; I was in this camp as despite it’s flaws, it was the workhorse that could get the job done. But increasingly, my support of C++ has become more of an apologia and I am definitely looking past C++ more opportunistically.

27

u/Wh00ster Dec 28 '18

I think a big motivation for all the new C++ features is staying competitive among beginners. I.e. have the STL loaded with enough to get people started on interesting projects, so that C++ is more approachable. That way people begin with C++ earlier, and have a longer time to ramp up. Teachability and approachability are important components of any language.

Being all things to all people is definitely the issue at hand.

9

u/ShakaUVM i+++ ++i+i[arr] Dec 28 '18

What new features do you see as appealing to beginners?

22

u/Wh00ster Dec 28 '18 edited Dec 28 '18

Filesystem and networking TS's, concepts, type inference (though debatable), better support for sum-types, and the declarative syntax of ranges. In general, higher abstractions and less verbosity.

The example in Eric Niebler's original ranges post is purposefully more in depth than a beginner would need, but something like view::filter is going to be more to-the-point than manually looping through iterators and mutating a container defined outside the scope of the loop, then iterating through that container.

Of course, there's always the conflicting viewpoints between teaching beginners the "fundamentals" vs getting them started with something interesting.

EDIT: To be clear, I also think it's important that a C++ coder is aware of performance/resource costs, but I also think/assume coders should understand C well first and then build on top of that with C++.

13

u/ShakaUVM i+++ ++i+i[arr] Dec 28 '18

I've long argued that we ought to be able to just call sort on a vector without needing to use vec.begin() and end(). I'm excited to see this finally happen.

I think that 14 and 17 didn't add much for new programmers, but 20 looks like a really nice boost for them.

-6

u/lithium Dec 29 '18
template <typename Container>
void Sort ( Container& container )
{
    std::sort ( container.begin(), container.end() );
}

This doesn't need to be in the standard library.

8

u/ShakaUVM i+++ ++i+i[arr] Dec 29 '18

It should be. The standard library should make simple things simple.