5 ms·
Personally, unfortunately the more exposure I've had to the "Modern C++" community, the more I feel like it's dogmatic, cargo-cult, and obsessed with "best prac
by userbinator 10y ago
Personally, unfortunately the more exposure I've had to the "Modern C++" community, the more I feel like it's dogmatic, cargo-cult, and obsessed with "best practices", which really puts me off. It looks like a manifestation of the second-system effect compared to C, which I'd characterise as a simple, pragmatic, and humble language. Then again, I've always thought OOP was oversold and that may have something to do with it.
That is not to say I fundamentally dislike the language itself; C++ certainly has some very useful features compared to C, and I sometimes wish I could make use of them when I'm writing C too, but the "C++ is so much better than C, C is bad" and all-too-common "some bloke named Herb says X, so you must follow him" sort of attitude coming from self-proclaimed "Modern C++" developers I find rather distasteful. I don't care about purity or adherence to any perceived "expert opinion", I just want to use the features of the language that make it easier and simpler to solve a problem more efficiently (and likewise, not use the features which don't help)... which is what programming languages ultimately are for, and yet I feel much of the "Modern C++" community has missed that point.
- kccqzy 10y ago> I've always thought OOP was oversold and that may have something to do with it. Almost all of the recent innovations in C++ focus on aspects other than OOP. I can't think very many new OOP languages features in C++11/14/17, except for `override` and `final`. All the new hotness is about functional programming and in some sense, generic programming, which, IMO, is the right direction. > I just want to use the features of the language that make it easier and simpler to solve a problem more efficiently (and likewise, not use the features which don't help)... which is what programming languages ultimately are for, and yet I feel much of the "Modern C++" community has missed that point. I feel that you are exactly the kind of person the author has described in the beginning of the article: a C++ sceptic, especially a "Modern C++" sceptic. The article even quotes Douglas Crockford in saying "some of those features were more trouble than they were worth." The article also quotes Bjarne Stroustrup saying "[w]ithin C++, there is a smaller and cleaner language struggling to get out." The "Modern C++" community that you have derided is exactly the community that knows not every feature in C++ is good, a community that tries to enshrine the tried and tested "good features" into "expert opinion" and "best practices" and then spread them through talks like this one.
- wfunction 10y agoHonest question: given you're saying this, do you know modern C++ in the first place? In other words, are you speaking with knowledge? Or without?
- stinos 10y agothe "Modern C++" community Could you describe what/who you think this is, because I don't really see a community as a whole for who the points you make are valid. Sure there's some crazy purists everywhere, but in general I don't think it's as bad as you mention. Then again might be biased because I write way more C++ than C. I know cherry-picking isn't usually the most fair way to discuss, but some things really strike me as unfair so I can't help it. obsessed with "best practices" not sure if this is really bad? When pushed to the extreme it is, but that goes for anything extreme, but I don't really feel the C++ community is like that. At least I've read many times things in the spirit of 'best practices ar good, follwing them blindly is not'. Also anecdotally from all colleagues I ever worked with those with some healthy amount of (as in, still being able to think critically) obsession with trying to Do The Right Thing, always wrote better code than those who lacked that OOP was oversold it surely was, but imo one of the things modern C++ teaches us is exactly that: OOP overuse is bad and you don't have to use OOP at all in C++ if you don't want to "some bloke named Herb says X, so you must follow him" sort of attitude which is in turn countered by an attitude of questioning everything, no matter if the author is called Herb or Bjarne, and I don't think I'm dreaming that (at least I've seen many questions on SO starting with 'in xxx Herb says y, wtf is that all bout?'). On the other hand, those guys' advice is usually golden so following it won't hurt much, as long as you don't blindly follow it. I just want to use the features of the language that make it easier and simpler to solve a problem more efficiently in the end everybody wants this I guess, and I do have the feeling that when searching for questions to typical problems I usually do get an answer telling me exactly what to use. Also take https://github.com/isocpp/CppCoreGuidelines https://github.com/isocpp/CppCoreGuidelines for example: sure theres a whole lot of info but it does give a ton of good/bad examples, plus reasoning behind it
- petters 10y agoI suppose that you could just use C with std::vector and std::unique_ptr from C++, and you’d be much better off. The you could still write "C" code but not worry about memory leaks. Of course, you also need std::sort because it is much faster than qsort. Thinking about it, you probably want to implement all time-critical algorithms with generics. ... never mind, this quickly becomes a stone soup.
- bluecalm 10y agoI keep hearing that std::sort is faster than qsort yet when I benchmarked it with GCC it was the exact same performance which makes sense as modern compiles are either to optimize function calls through pointers. Anyway, both are significantly slower than macro based library based on removing function calls altogether (not the one in comparator but the recursive qsort calls). For things I would like to use C for std::vector is not very useful either as it grows in some generic way which is likely wasteful for specific applications. If an algorithm is time-critical then almost by definition the generic implementation in standard library won't be enough.
- userbinator 10y agoOn the other hand, "inline" too much code which is faster when benchmarked in isolation, and thanks to cache effects you may end up with worse performance as now less code fits in the cache.
- gpderetta 10y agoOn the gripping hand, dead code elimination after constant and range propagation, might make the dynamic cache footprint the inline ed code smaller.
- pjmlp 10y agoThe thing is, there isn't one std::sort, neither one C++ implementation. Try that with ICC instead, for example.
- rleigh 10y ago
- rleigh 10y agoI think this misses the point of what "Modern C++" is about. It's absolutely about best practices, and that's a good thing. Go back to the mid '90s. There was a lot of awful C++ code out there, and a large part of that was the language was dangerous for many people who didn't know how to use it safely or effectively. Some of that legacy persists today in old codebases. The STL and the C++98 standard library improved upon that, but there were still dozens of interesting ways of shooting yourself in the foot. Then we had people like Meyers who wrote whole books explaining the dangers and how to write code to avoid them. These were the best practices, and they are hugely helpful. I use them daily in my work, preventing subtle bugs, leaks, undefined behaviour and random crashes. These turned C++ into something which could be safe and effective to work with, provided you didn't ignore the guidelines and do anything irresponsible. C++11 and 14 improved upon them, and again Meyers brought out a book to explain a whole new set of pitfalls to be aware of. I agree with your assertion that it's to some extent dogmatic. But I don't agree that it's cargo culting (though some people may be). Over the last 25 years, we've collectively learned that there are some things which you must never do (e.g. throwing exceptions in destructors), and some things which you should or must do. Like the rule of three or rule of five, RAII, or how to implement Java-style interfaces with virtual inheritance and various deleted operators and constructors. Experience has shown that this is the right way to do things, and you'd better have a good reason for deviating from that. Languages like Java benefit from being restrictive and only have one safe way to do things. That's not true for C++, where you can do what you like even if it will explode in your face, and having a set of best practices we all agree on make things safe and efficient to work with. Certainly on the team I work on, being able to refer people to Meyers and say: "this is the way to do it, and this is the rationale" is beneficial and educational to the people concerned, as they get a better understanding and appreciation of the language subtleties, rather than their work making the code segfault or do the wrong thing. For the minority who are cargo culting, I'd rather that they followed the dogma and wrote safe code even if they don't fully understand the rationale for doing so, when the alternative is writing unsafe and buggy code. Unfortunately, there is a minority that doesn't care to understand, and for them a set of strictly enforced rules is required to avoid disaster.