3 ms·
I'm not a big fan of the huge complexity of C++ (and much prefer C in general, although for some things C++ is more convenient) but I don't really think it's fa
by simias 9y ago
I'm not a big fan of the huge complexity of C++ (and much prefer C in general, although for some things C++ is more convenient) but I don't really think it's fair to dismiss a language based on a small snippet. You can basically mock any language that way:
- In C "getchar" returns... an int.
- Pointers and array are kinda the same thing, but not exactly. The rules for when an array decays into a pointer are sometimes unintuitive and surprising.
- Same thing for the implicit integer types promotions.
- `char *s = "foo"` is not at all the same thing as `char s[] = "foo"`. Arguably the former should be considered erroneous, but compiles just fine in C. G++ gives a warning for the same code however.
- There's also the ridiculous "gets" function that's so poorly designed it could be part of PHP. This one finally got officially deprecated though.
Of course many of these issues are also part of C++ since it's mostly a superset of C but in general it's stricter and more strongly typed.