3 ms·
> This person is not a very good C++ programmer. Am I a bad C++ programmer for agreeing with some of it? > 5. #pragma once: see modules. They are in fact tryi
by pcwalton 9y ago
> This person is not a very good C++ programmer.
Am I a bad C++ programmer for agreeing with some of it?
> 5. #pragma once: see modules. They are in fact trying to make something better. There are also some cases where you don't want/need it
The fact that modules have taken so long, and still have prominent members of the community saying they need to be sent back to the drawing board, is a legitimate criticism.
> 7. Binary file includes. Ugh this is just such a dumb idea I can't even.
It's a useful feature, much used in the language I work on, allowing you to distribute a program that needs just one or two static data files as a single executable. It's also good for packaging data as libraries: for instance, Unicode libraries need a lot of random tables and it can be convenient to store these in binary form. Having to embed binary in C/C++ syntax as, say, ICU does just adds parsing overhead at compile time for no reason.
> 9. do/while(0). What are you using macros for in 2016 (the time of writing)?
There are lots of use cases of macros, too many to list here. Templates don't always suffice.
> 11. Switch/case is stupid. No it's not. You want fall/through cases as well and if you can't see why, don't criticize. This is true in pretty much EVERY language that supports switch/case
I designed much of the pattern matching system in an industry language without fall through in switch case and I have never missed it. Nor has anyone else in the community I know of.
- metalliqaz 9y agoI think you can regard switch/case as syntax sugar for a series of if/else. So fallthrough may not be needed but more sugar is nice to have available.
- fwsgonzo 9y agoYep, I also think modules are still relatively far away. I also hope that the C++ community can embrace some package management system.. at some point in time. Hopefully before I die
- to3m 9y agoC# lets you do "goto case XXX" to go to another case, and empty cases fall through to the next. This is a bit inconsistent, but it at least retains the useful fall-through case, gets rid of the usually-undesirable case, and still accommodates the occasional exceptions.