Tuesday, 12 August 2008

A bit about C

A great computer programmer will try and use the programming language best suited for the task in hand, and due to their years of experience they will either have experience in the language they choose for a project or enough general programming proficiency to pick up the language they choose fairly quickly.

However, the more we use a language the more proficient we become in it, which has meant that in programmers tend to stick to a few languages as their bread and butter. So that the skills they have in the languages they choose can be as useful as possible, ideally a programmer is looking for their main language to have some of the following traits:

1. Versatile/powerful.
2. Portable.
3. Easy to understand/debug.
4. Efficient.

In other words, there is a need for a general purpose programming language, and for many many programmers C is their general purpose language of choice. I should point out now that there are programming languages that do one of the general purpose programming language criteria listed above better than C, but it seems rare for a programming language to fulfill all the criteria in a way that C does.

There are other advantages bestowed upon C through its popularity. Due to its prominent position in the computer programming world there are many learning resources for C available, from beginner to advanced , so we always have more information to learn from. It's portability is also enhanced by its popularity, as one of the early building blocks of many operating systems is a C compiler. Finally, the popularity of the C programming language has meant that there are a number of newer languages which are C-based in design (most notably C++) so if you do look around for a new programming language to learn it doesn't have to be one that is completely alien to you.

So how did the C programming language start? Its story is linked to the early development of the Unix operating system in the 1970s. When UNIX was first developed in Bell Laboratories, by a small group of software engineers trying to start a new OS to replace the MULTICS OS that was dying out, it was written entirely in assembly language for the PDP-7 computer. One of the (maybe even the) earliest programming language to be ported to UNIX was TMG (a compiler that compiles compilers, work that one out! The name is a shortened form of the word 'transmogrification', but think of it more as a 'translator' of programming language syntax). With TMG now available, Ken Thompson (one of the key figures behind UNIX) decided that UNIX should be able to use the Fortran programming language (probably the first widely used high level language).

However, Ken Thompson ended up creating a new language instead, named B (the name was derived an early revision of the language called 'bon', after Ken's wife Bonnie). B was based on BCPL (Basic Combined Programming Language), though there were syntax differences (if you are unfamiliar with the word syntax think of the word 'grammar') and it was cut down in size.

The B programming language had its drawbacks though, one of which being the difficulty of the use of certain data types, such as the character data type (a data type literally refers to the type of data being stored/used: numbers, letters, etc...). The design of B evolved into the C programming language, written by Ken Thompson's colleague at Bell Laboratories, Dennis Ritchie.

The UNIX operating system kernel (if unfamiliar with the word 'kernel' think 'core') was rewritten in the C programming language, allowing it to be easier to maintain and also offering greater portability to new computer systems. Whilst the C language was originally intended for use in system programming (software designed to control computer hardware, e.g. operating systems, drivers), it started gaining fans for its application programming uses too, and that popularity continues to this day.

Whilst the C language structure was first finished in 1973, there have been a number of variations of the language through the years. The well known book 'The C Programming Language' by Brian Kernighan and Dennis Ritchie, was first published in 1978 and served as an informal standard for many years. Next, around 1989/1990 a formal C standard was released known as ANSI C (a.k.a. ISO C, C89, C90) which was drawn up to keep a universal base for C programmers to work from. Finally we have the C99 standard (released in 1999) which added new features to the language whilst still being mostly backward compatible with ANSI C. Talks are taking place about a new C standard, currently known as C1x, but this isn't likely to be finished in the next couple of years. In any case, I am only mentioning these standards so you are aware of them, the programs we will be writing initially should be unaffected by the changes made between standards.

I could go on, but I feel we've been suitably acquainted with the story behind C. Next blog will be about AROS, and the blog after that will be about getting our development environment ready, which means we will then be ready for the fun stuff, writing computer programs! : )

No comments: