The C programming language

After many years of programming in Modula-2 I have been looking at several other languages. The last one was Pyffon and it was aweful. Pyffon is a travesty, or perhaps a parody, of the major programming languages of the late 80's but some geeks chose it for their work. "Go" is a bad language but Pyffon beats them all, hands down.

So I browsed my bookshelf and found 'The C programming language' and it ain't that bad after all. OK, you have to be very careful with compound statements but given that, it ain't half bad.

The book

When I refer to "the Book" I refer to the bible/quoran/tora (you choose) of C programming: 'The C Programming Language' By Kernighan and Ritchie. It's a step by step introduction to, well, just what the cover says. It cannot tip the level of Wirth/Reiser's 'Programming in Oberon' but that is due to the syntax of C, which was, is and will always be, rather clumsy for a high level language. It is designed to be a portable assembler. And asembly programming has always been a black art. And I used to be quite good in 80x86 asm.

I've been reading upto chapter 7 now. The first 4 chapters were OK. They explain the basics of the language with plenty of examples. The basis is nice. You can do a lot of things with it. Yet, the books keeps on telling to be careful. Different compilers invoke different actions with identical sources. In the second half of chapter 4, header files are mentioned. Not 'explained', mentioned and an attempt to clarify is made. But header files are just black magic. The lack of qualified imports makes extending the language terribly difficult. At that moment I realized why the GTK library has such terse naming convention.
Chapter 5 was about pointers and arrays. 40 pages blah blah about how to use pointers, arrays, multidimensional arrays, pointers to functions, the lot. Judging by the amount of text used to explain such trivial parts of a programming language, already shows there isn't much structure in the language, apart from the 'struct' structure.
Chapter 6 is about structures and unions. Another 20 pages down the drain to explain what a record is. 'C' is for 'Chaos', apparently.

More and more I miss the simplicity of Modula-2 and Oberon.

Examples and exercises

In this section I elaborate on the exercises which occur in 'The Book'. Exercises covered are:

Porting software between languages

To get familiar with C, I port some of my older Modula-2 and Oberon sources towards C. This makes me see the differences between a programming language and a portable assembler. Modula-2 and Oberon sources are like poems, whereas C sources are more like a Tom Clancy novel: there's always a double bottom, always an edge you did not foresee.
So far, I learned that C is the preferred language for software developers: it is not intended for multi programmer teams and it is not suited for delicate tasks. But if you persist, you can make endless hours (and huge profits) by trying to do it anyway.


More to come

Page created on April 29, 2015 and