3 ms·
What, precisely, are the warts that folks want to get rid of in C++ but cannot?
by chris_wot 8y ago
What, precisely, are the warts that folks want to get rid of in C++ but cannot?
- hellofunk 8y agoDepends who you talk to. Here’s one take by the great Scott Meyers: http://scottmeyers.blogspot.com/2015/11/breaking-all-eggs-in-c.html http://scottmeyers.blogspot.com/2015/11/breaking-all-eggs-in...
- slavik81 8y agoJust off the top of my head, it would be nice to remove std::initializer_list from the standard to make uniform initialization truly uniform, and to remove to the 'explicit' keyword to make it the default behaviour. There's also stuff from C that can be surprisingly complicated, like integer promotion rules, but if you change that sort of thing you might as well design a new language from scratch.
- Ace17 8y agoThe preprocessor: Bjarne Stroustrup has been willing to get rid of it for a long time. C++20 modules are a step in this direction. However - as pointed out by John Lakos - you still need macros to build zero-cost logging facilities.
- Ace17 8y agoCorresponding citation from John Lakos about why macros could be necessary: https://www.youtube.com/watch?v=K_fTl_hIEGY&t=3140 https://www.youtube.com/watch?v=K_fTl_hIEGY&t=3140
- frabert 8y agoI don't think that's necessarily true, using constexpr facilities you could make a function do nothing according to a compile-time variable value
- Ace17 8y agoI agree ; however, the tricky part - I believe - is not computing the message string in case you're not going to print/record it.
- xamolxix 8y agoIs IO allowed in constexpr functions?
- justbuchanan 8y agoI don't think so, but for zero-cost logging you just need the conditional for your branch to be constexpr. If the branch is known not to be taken at compile time, the compiler can just throw it away. Something like: void MyDebugLog(text) { if (<constepxr check if logging enabled>) { // actually log... } }
- pjmlp 8y agoFrom my tiny spot on the metaverse, copy-paste compatibility with C's security flaws.
- will4274 8y agoThe biggest one for me is the preprocessor. The preprocessor is THE reason C++ has such horrendous compilation times compared to basically any other language. Others have mentioned uniform initialization, which I definitely agree with.