Why are some identifiers in the C ++ standard library short?

Why are some C ++ names short and sometimes hard to understand, like strcmp , cout , cin , etc. But other languages, such as the Java name, are not short. Does it save time, memory or what?

+6
source share
3 answers

This primarily refers to parts of the C ++ standard library that were "inherited" from C. In standards prior to C89, C, a significant part of external identifiers is limited to 6 characters; linkers were allowed to ignore other characters. This is why the C standard library is limited to an identifier of up to 6 characters. C ++ included this library in bulk, along with somewhat cryptic identifiers.

+11
source

There are parts of the standard C ++ libraries that come from the older C standard library. The older standard C library, in turn, was obtained from the older K & R library, which provided some basic functions through functions that, in other languages, are built into the language, such as Input / Output.

This section of the Rationale for the ANSI C4 Programming Language describes naming conventions for C identifiers.

The C programming language is compiled, and the output of the machine code of the compiler is connected with real applications. The software that performs the binding is usually part of the standard tools offered by the operating system vendor. A review of the available linker applications offered by various vendors showed that the most basic provided six characters for external identifiers that could be handled by linkers. However, some linkers allowed more by specifying a six-character limit; the list of available target computers for C compilers was much larger.

Remaining with the limitations of linkers, he allowed C programmers to write C programs and libraries of functions that could be used with software written in other languages, and also allowed libraries written in other languages ​​that C programmers would use.

+1
source

C ++ inherits from C, which was long built by programmers who are used to working in assembler.

But I think that he delves into the mathematical background of programmers. Early attempts to simplify language understanding using English terms are probably the only survivors of COBOL and SQL. But since words in programming languages ​​have a very precise meaning, using "SELECT" rather than a colon helps only a small amount, you still need to know all the details of SQL to write the rest of the query.

A short identifier makes the code more understandable for experienced programmers, you can see and parse more structure at a glance. If you ever need to read scientific articles C17-C18, where they use the prose page to describe what we will write in one equation, you will understand.

0
source

Source: https://habr.com/ru/post/948410/


All Articles