Why do I have to specify data type each time in C?

后端 未结 11 2756
温柔的废话
温柔的废话 2020-12-12 18:17

As you can see from the code snippet below, I have declared one char variable and one int variable. When the code gets compiled, it must identify t

11条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-12 18:25

    Isn't the compiler matured enough to identify that when I declared my variable?

    No.

    You're using a language specified decades ago. Don't expect modern design aesthetics from C, because it's not a modern language. Modern languages will tend to trade a small amount of efficiency in compilation, interpretation or execution for an improvement in usability or clarity. C hails from a time when computer processing time was expensive and in highly limited supply, and its design reflects this.

    It's also why C and C++ remain the languages of choice when you really, really care about being fast, efficient or close to the metal.

提交回复
热议问题