| You are missing the main strength of C - the transparency and predictability of what machine code gets generated from the source code. When you write "a + b", you won't end up with kilobytes of machine code just because someone in some header overloaded the + operator. Ditto for template-style generics and overloaded functions. If you call a function and it doesn't exist, it won't get auto-generated for you on the fly. You get an error. You want a function, you define that function. That's not the flaw of the language. That's its strength. Ditto for switch-case constructs. Ditto for closures. All of these constructs, should they be added to the language, will result in a compiler generating heaps of code from a simple code snippet. But this will no longer be C, because in C what you see is what you get. |
This gets said a lot, but unless you're writing C code for a microcontroller (or a PDP11), that isn't even close to being true.
> When you write "a + b", you won't end up with kilobytes of machine code just because someone in some header overloaded the + operator.
You can't overload "+" for integers or floats. If you add two numbers together, you get what you expect, always. If they're not numbers, and somehow you expected `a + b` to work without an overloaded operator, then I don't know what to say.
> You want a function, you define that function.
Then you define it again for another type, then again, then again...
Then you write a macro and now your colleagues hate you.
> All of these constructs, should they be added to the language, will result in a compiler generating heaps of code from a simple code snippet
Not necessarily.