Pinterest Stumbleupon Whatsapp

The C programming language is the mother of all modern programming languages 10 Programming Languages You Probably Never Heard Of 10 Programming Languages You Probably Never Heard Of There are some very strange and bizarre programming languages which have turned logic on its head and have still managed to stay true to the science of communication with a computer. You are going to... Read More . Almost every language in use today includes several features which first appeared in the C language. It has been extensively used to write software for the smallest embedded microcomputers to the largest mainframes and supercomputers.

Applications written in C range in a wide variety from system software, desktop software, enterprise software, databases, etc. You would do very well to start a programming career 10 Computer Programming Jobs That Are In Demand Right Now 10 Computer Programming Jobs That Are In Demand Right Now Since landing a programming job can be tough in the current landscape, consider focusing on one of the following concentrations to improve your chances of success. Read More with a knowledge of the basics of C.

A Brief History of C

The development of the C language is very closely associated with Unix. It was developed around 1972, with more additions made in later years.

Before C was developed, the Unix operating system was developed for the PDP-7 computer using its assembly language. Later a compiler for C was built on this platform, again using assembly language. At this time, C was designed to ease the development of Unix itself. Using this compiler, Unix was rewritten completely in C for the PDP-11 computer. And again, the C language compiler was rewritten in C (helped, of course, by the excellent lex and yacc tools), thus completing the C/Unix Bootstrapping process.

The main reason Unix was rewritten in C was for portability. Since assembly languages for different CPU architectures A Short Guide to the Fantastic AMD Threadripper CPU A Short Guide to the Fantastic AMD Threadripper CPU AMD was in the CPU wilderness for several years, but is back with a massive bang. The AMD Threadripper is one the most powerful consumer CPUs on the market, but is it right for you? Read More are different, porting the Unix OS to each would have been a significant effort. By developing a systems language such as C, and rewriting the Unix OS in C, this effort was reduced by several orders of magnitude.

Once the language was developed, it was recognized that it could be used to write much more than system software. And thus, C began to be used for writing software such as file servers, database servers, networking stacks, desktop software, (and later) web servers How to Turn an Android Device into a Web Server How to Turn an Android Device into a Web Server Host your very own web server simply and cheaply with an Android smartphone or tablet. Read More , etc.


c programming language first edition cover

In 1978, Brian Kernighan and Dennis Ritchie published the book The C Programming Language. This book served as an informal C Language Specification for many years until 1989 when C was formally standardized by ANSI. The latest version of C is C11, published in 2011.

Let us now look at some features of C that make it unique.

C vs C++: Are They Related?

As more complex software was developed in C, it was recognized that object-oriented concepts including encapsulation, polymorphism, etc would help manage the complexity. This lead to the development of C++ as a superset of C.

C++ was built by adding certain features for writing object oriented software, while maintaining compatibility with C. It was developed with the idea of progressive enhancement — making compatible changes to C language so C and C++ modules can be combined in the same program and compiled with the same compiler. This enabled older C-based modules to be re-used with minimal changes in a larger program written using object-oriented concepts.

A C program can, in theory, be compiled by a C++ compiler without requiring any changes. In practice, however, stricter type checking enforced by C++ results in errors, requiring some changes to the code.

Small Number of Keywords

The C language has been a small language in spite of its power. This is because it declares only 32 words as keywords with a specific meaning. By contrast, C++ declares 82 keywords, java has 50 reserved keywords and javascript has 63. And COBOL declares a whopping 357 keywords. Imagine the headache of having to remember and sidestep such a large number of keywords!

No Explicit String Type

Unlike most other modern languages To Build an Android App, You Need to Learn These 7 Programming Languages To Build an Android App, You Need to Learn These 7 Programming Languages Which programming language is right for creating Android apps? It comes down to your programming history and which languages you feel most comfortable using. Fortunately, you have options. Read More such as Java, C++ and JavaScript, C does not provide a separate type for strings. A string is considered an array of characters terminated by a 0 character (denoted “\0”). The length of the string is denoted by a convention: the number of characters until the 0 character. You are free to ignore it and count or store past the “\0”. This lack of a proper string type and the convention has resulted in countless bugs over the years, known as buffer overflow.

In fact, the first worm to ever hit the internet, the Morris Internet Worm, was the result of such a bug in a crucial piece of system software known as the finger daemon.

Here is an example of such a bug. It illustrates how easy it is to introduce such bugs in a program. The program compiles fine, but crashes due to the buffer overflow.

# include <stdio.h>

  char *buf = "hello world";
  buf[12] = 'a';
  printf("%s\n", buf);

In contrast, most modern languages provide an explicit string type which make such shenanigans impossible. Even C++, which compiles the above code fine, provides an explicit std::string type.

Pointer Manipulation

A pointer is a reference to a memory location. C is completely flexible when it comes to reading and writing arbitrary memory locations. This flexibility comes at a great cost, and has been the cause of many bugs across the software spectrum. Most notable and affecting the entire internet include such bugs in web servers, mail servers and ftp servers. Even today, there are occasionally news stories about bugs caused by referencing and updating invalid memory locations.


The infamous SSL HeartBleed security bug discovered in 2014 was the result of improper management of pointer locations and illustrates the crucial importance of proper pointer management in C.

Even the occasional BSOD (“blue screen of death”) errors that are seen on Windows systems are also probably caused by improper pointer handling.

Languages other than C++ do not permit pointer manipulation and thus are not vulnerable to these class of bugs.

Arrays and Pointers Are Interchangeable

In C array references and pointers are interchangeable. The language permits usage of an array reference How to Use a Java ArrayList How to Use a Java ArrayList A Java arraylist is a general-purpose resizeable array. It provides most of the facilities generally expected of arrays in other languages. In this article you'll learn to set up and use an arraylist. Read More where a pointer is required, and vice versa. While this allows for powerful manipulation, it has also resulted in many infamous bugs.

Wide Use of “define” Macros

Macros are used to substitute a name for a different expansion. They may be used to change the definition of a name at compile time, or to substitute a longer expansion for a simple name. The C macro system supports ifdef conditionals which allow conditional compilation. This is one way software is ported to different architectures and operating systems. Generic names are defined and substituted at compile time with different expansions for different conditions.

It is also possible to include or eliminate entire sections of code from being compiled using these macros Have A Razer Keyboard? Recording Macros Is Easy With Synapse Have A Razer Keyboard? Recording Macros Is Easy With Synapse If you use Razer peripherals but don't take advantage the Synapse software, you're missing out. Here's how to use macros effectively and how they can supercharge your gaming. Read More .

They are deprecated but available in C++. Other languages such as Java, JavaScript, python, etc do not provide a similar facility.

Modules Encapsulated in Files

C does not have the concept of a class, and hence does not support the notion of separate public, private and protected visibility. The only encapsulation provided by C is that of files. Functions, global variables and types defined within a source file are visible within that file only unless the names are exported. The keywords static and extern are provided for the purpose of controlling visibility of variable and function names.

By contrast, other languages such as C++, Java and Python generally support classes, and the encapsulation that goes with classes.

External Libraries

Other than basic language constructs, more complex functionality in C is delegated to external libraries. String manipulation, math, input-output, networking, etc are all provided by external libraries. In contrast, other languages usually come with a well-stocked library of modules with the language itself.

And that covers some basic characteristics of the C language, especially those that set it apart from other languages.

Have you worked with C? Did you like it or would you have preferred to work with some other language? Please explain in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. ACG
    September 9, 2017 at 3:54 pm

    A string is considered an array of characters terminated by a 0 character (denoted “\0”).

    This is incorrect. C-strings are not terminated by 0 characters, they are terminated by the 0-byte, an actual byte of data that is zero, aka NULL. These are called C-strings, as I just mentioned, or NTBS, Null-terminated byte strings.

    And yes, they are quite dangerous in many ways and quite possibly the worst mistake of the C language.

  2. Atakan
    September 9, 2017 at 11:39 am

    I want to learn C and C++. What are your recommendations for intro books, advanced books and compilers on windows 7 and windows 10?

  3. Link
    September 9, 2017 at 6:19 am

    If that example C code is meant to get rid of the null termination of the string, then array index should be 11 and not 12, since 12 will not affect the null termination of the string.

    • Link
      September 9, 2017 at 6:26 am

      Oops my bad. Pay no mind to the comment. ?

      • Jay Sridhar
        September 9, 2017 at 10:28 am

        The array index 12 was used to illustrate that you can refer to memory addresses outside of what was allocated in C. However, you are correct that to blow away the null terminator, the index at 11 must be set.

  4. billdehaan
    September 8, 2017 at 7:41 pm

    C has been referred to as a "portable assembler", and that's not too far from the truth.

    For embedded systems, C is still preferable to object-oriented languages, both because of its' much lighter footprint, and because of its' traceability. For application programming, it's no longer popular, but it still serves as a great teaching language.

    I can't imagine my current project's 2+ million line C++ code base being implemented in C; we simply use too many OO features that don't exist in C. And likewise, I cannot imagine trying to implement the the motor controller running on an 8 bit CPU with 64KB of memory in C++.

    They each have their uses.

    • Jay Sridhar
      September 9, 2017 at 1:42 am

      Thanks for your comment.

      Absolutely each have their uses. That is the point I was trying to make in the article.

    • Doc
      September 10, 2017 at 8:42 pm

      There is no such word as "its'". The proper forms are "its", which is a possessive (like "his," "hers," and "theirs", "its" does NOT have an apostrophe), and "it's," which is a contraction of "it is" or "it has."

  5. dragonmouth
    September 8, 2017 at 7:27 pm

    "And COBOL declares a whopping 357 keywords. Imagine the headache of having to remember and sidestep such a large number of keywords!"
    You compile. The compiler tells you that you used a reserved word. You fix the error. No headache. :-)

    • Jay Sridhar
      September 9, 2017 at 1:43 am

      Well, except that you are more like to face this issue with COBOL than with other languages just from the fact that it has so many keywords.