C programming language was first developed in the 1970s. In 50 years of evolution, it has experienced many significant changes. In this article, you will get a chance to see how C language evolved. You will learn about specific mutations of various features, too. This will enrich your understanding of this intricate low-level language.
ISO committee has changed over the years function declarations in C programming language. Function declarations originally did not contain type declarations of parameters. Types of parameters needed to be declared after function declaration. You can see in the third example below.
Example 1: Main function declaration in legacy C
main()
intargc;
constchar** argv;
{
}
Example 2: Main function declaration in modern C language
intmain(intargc, const char** argv )
{
}
2. Mutated comments in C
Even comments experienced additions. A single-line comments looked verbose 50 years ago. Since C programming language only defined multi-line comments. Hence to write a single-line comment C programmers had to use multi-line comments.
Example 3: Original C comment syntax
/* a single-line of comment in legacy C */
Example 4: Added C comment syntax
// a single-line of comment in modern-day C
3. Mutated variable declaration in C
Positioning of variable declaration in functions changed, too, in C programming language. The legacy C programming language required to define variables at the top of every function. ISO committee changed this with newer version of C programming language.
Today, C programmers can declare variables anywhere within their functions. Keep in mind, that even variables inside for loops needed to be declared beforehand.
Example 5: A for loop in legacy C
intmain()
{
inti;
for(i= 0; i < 10; i++){}
return0;
}
4. Mutated structs in C
Some of the parts of the legacy C programming language are still used today. One example
of this could be the original struct, enum and union data
types. In the legacy C, struct type name needed to be decorated
with the struct keyword, since the keyword typedef was only introduced in later C language versions. This is still a common practice, for example, in Linux kernel.
Example 6: A struct in legacy C
struct node {};
voidmain()
{
struct node first;
}
Example 7: A struct in modern C
typedef struct node {} node;
voidmain()
{
node first;
}
5. Mutated primitive types in C
In the C99 version of C programming language, a new header stdint.h was introduced. This header defines more nuanced data types of specific sizes. It offers optimization possibilities for counters, too.
Example 8: Newly introduced size specific data types in C
In summary, C programming language has evolved over the course of 50 years. As of today, comments, data types, function, as well as, variable declarations are different. ISO committee is still active as of 2022. Thus, we can still expect positive mutations of this intricate programming language.
quizzes and articles!
Please fill out the form below to stay up-to-date to our newest interactive
articles with quizzes.