History of C Programming Language

Side note: This blog is probably written in 2008. I created a website c-programming-guide.com with some amateur articles. Well, you cannot expect a student with 2-year experience to come out with something great. Smile But anyway, I wrote these articles, and some of them are actually fun.

Everything on earth has history, How about the history of C programming language?

It is boring to read technical article about history of C programming (I suffered a lot though I learned a lot), I don’t want you to struggle with the same sort of article. I will write it in an informal way and keep it short (without lose of essential information hopefully). But don’t expect it could be as interesting as romance.

If you think you prefer to read those technical articles, some useful links are provided at the end of this page.

C’s Ancestors

C programming language is a piece of art, so it takes time for it to come to the world. Before C, there is a computer language called CPL, which is abbreviation of Combined Programming Language. It’s designed to deal with both high-level, machine-independent programming, while still allow the user to control the individual bits of information.

Well, it sounds very powerful. It is, indeed. However, everything has its drawbacks. CPL is too large to use in many applications.

So here came BCPL by Martin Richard in 1967, which is Basic CPL. It’s mainly designed to scaled down CPL, while keep most of its features.

It seems this strategy works, and some one did it further. In 1970, Ken Thompson, a Bell Lab engineer, developed B programming language by scaling down BCPL further.

C’s birth and ANSI C

Finally, C programming language came to birth in 1972. Another Bell Lab engineer, Dennis Ritchie created C based on B language.

It inherited B’s concise syntax, and had a powerful mix of high-level functionality. Originally, UNIX operating system is written in assembly language. Because of C’s power and flexibility, it was re-written in C programming language right after the creation of C except the “bootstrap” part.

Because of the “marriage” with UNIX, C spread throughout the computing world. It soon became the most popular computer language.

Soon, many organizations met compatibility problems because they use their own version of C. Thanks to ANSI (American National Standards Institute). In 1983, they formed a committee to come up with a standard for C, known as ANSI C.

C’s Descendants and Future

While C is descendant of B, it does have descendants too.

Obj-C is a descendant of C. It’s the main development language for Apple’s next generation operating system, codenamed Rhapsody.

Another descendant is Concurrent C. It is specially designed for concurrent programming.

The most important and well-known two descendants of C are C++ and C#. C++ is C plus some object-oriented features and plus some other functions. C# is invented by Microsoft to compete with Sun’s java programming language. It is fully object-oriented. So sometimes we don’t treat it as descendant of C.

Unlike B, C doesn’t step down the stage when its descendants came out. Today, C is still playing vital roles in many applications. Many UNIX/Linux applications are still written in C. C is used with assembly language to control hardware.

The history of C programming language will go on…

Useful Links

The development of the C Language. By Dennis M. Ritchie
The History of C Programming Language

Words about C and C++ Programming from Brian Kernighan

Side Note: This article is again from my previous c-programming-guide.com website. It was written around 2008.

This is part of An interview with Brian Kernighan by Mihai Budiu. These words are mainly about C and C++ programming language. Hopefully, it will help you to understand C programming language better.

If you wish to view the full text of the interview, click the link at the end of this page.
C is the best balance I’ve ever seen between power and expressiveness. You can do almost anything you want to do by programming fairly straightforwardly and you will have a very good mental model of what’s going to happen on the machine; you can predict reasonably well how quickly it’s going to run, you understand what’s going on and it gives you complete freedom to do whatever you want.

C doesn’t put constraints in your way, it doesn’t force you into using a particular programming style; on the other hand, it doesn’t provide lots and lots of facilities, it doesn’t have an enormous library, but in terms of getting something done with not too much effort, I haven’t seen anything to this day that I like better.

There are other languages that are nice for certain kinds of applications, but if I were stuck on a desert island with only one compiler I’d want a C compiler.
I think that the real problem with C is that it doesn’t give you enough mechanisms for structuring really big programs, for creating “firewalls” within programs so you can keep the various pieces apart.

It’s not that you can’t do all of these things, that you can’t simulate object-oriented programming or other methodology you want in C. You can simulate it, but the compiler, the language itself isn’t giving you any help.

But considering that this is a language which is almost 30 years old now and was created when machines were tiny compared to what they are today, it’s really an amazing piece of work and has stood the test of time extremely well. There’s not much in it that I would change.
Sometimes I do write C++ instead of C. C++ I think is basically too big a language, although there’s a reason for almost everything that’s in it.

When I write a C program of any size, I probably will wind-up using 75, 80, 90% of the language features. In other words, most of the language is useful in almost any kind of program. By contrast, if I write in C++ I probably don’t use even 10% of the language, and in fact the other 90% I don’t think I understand.

In that sense I would argue that C++ is too big, but C++ does give you may of the things that you need to write big programs: it does really make it possible for you to create objects, to protect the internal representation of information so that it presents a nice facade that you can’t look behind. C++ has an enormous amount of mechanism that I think is very useful, and that C doesn’t give you.
C++ is a great example of a language that in many ways has serious flaws. One of the flaws is that it tried very hard to be compatible with C: compatible at the object level, compatible very closely at the source level.

Because of this there are places where there’s something ugly in the language, weird syntactic problems, strange semantic behaviors. In one sense this is bad, and nobody should ever do that, but one of the reasons that C++ succeeded was precisely that it was compatible with C, it was able to use the C libraries, it was usable by the base of existing C programmers, and therefore people could back into it and use it fairly effectively without having to buy into a whole new way of doing business.
Click to view the full text of the interview.

Euclid’s algorithm

Side Note: This is first written on Oct 17 2007.

Euclid’s algorithm is used to find the greatest common divisor for two positive integers, let’s say m and n. It’s the first algorithm introduced in Knuth’s classic book, <<The Art of Computer Programming >> . The following text are retrieved from the book,


a. [Find remainder] Divide m by n and let r be the remainder. (0<=r and r< n). b. [Is it zero] If r = 0, terminates the program; n is the answer. c. [Reduce] Set m = n, n = r, and go back to step a.

A C/C++ implementation of the above algorithm is as follows,

//please ensure that variables passed to the function is positive 
int euclid(int m, int n) {
	int r = m%n;
	while(r!=0) {
	    m = n;
	    n = r;
	    r = m%n;
        }
	return n;
}

This algorithm/program can also be used to decide whether two positive integers are relative prime(no common divisor except one) or not. All we need to do is to check the return value is 1 or not.

Simple Note of Flood Fill

Side Note: This is a post from my previous blog on Oct 22 2007.

There are two ways to implement Flood Fill algorithm, depth-first, breadth-first, and breadth-first scanning.
Depth-first:
The algorithm looks at all neighbors of current node, and, for those have not been assigned to a component yet, assigns them to current component and recurses on them.
Breadth-first:
The algorithm examines the current node and adds all its neighbors into a queue. If the queue is empty, the algorithm finishes, otherwise, it repeats the above process.
Breadth-first scanning:
Every node has two values, component and visited. When calculating the component, the algorithm goes through all of the nodes that have been assigned to the component but not visited yet, and assigns their neighbors to the current component.


Performance comparison: (N is the number of vertex and M is the number of edges)
Depth-first Breadth-first Breadth-first Scanning
Running time N+M N+M N*N+M
Space Big Stack Big Queue Very little space

Pseudocode for Breadth-first scanning:

The code marks nodes to be visited as in component -2 and actually assigning them to the current component when they are actually visited.


#component (i) denotes the component that node i is in
function flood_fill(new_component)
do num_visited = 0 for all nodes i if component (i) = -2 num_visited = num_visited + 1 component (i) = new_component for all neighbors j of node i if component (j) = nil component (j) = -2 until num_visited = 0 function find_components num_components = 0 for all nodes i component (node i) = nil for all nodes i if component(node i) is nil num_components = num_components + 1 component (i ) = -2 flood_fill(component num_components)