make clean

December 17, 2007


Filed under: Uncategorized — k2sings @ 2:16 pm
Tags: , , ,

C as popularly called, is a spartan language that requires a lot of self
discipline to master it and make use of it.

The obsolute freedom and the straight interaction with hardware demands lot of
care, insight and discipline. There are questions on whether a programmer
should be forced to adapt to the ways of a particular language and I personally
dont know whether one should or shouldnt. Nevertheless it is interesting to go
reflect back on C language as a C programmer.

The winning advantages for C are,

No better language to do system programming (kernel, drivers)
across a varied computing architecture. And if an attempt is made to
create a new language in this domain, it will more or less look like C.

Performance. I dont know whether it is to do with the syntax of the
language or to do with the semantics of the language. Or whether it is do
with the people who were chosen to write the compilers. C compiled
binaries are the fastest.

Popularity. I leave it to the reader, since he could be knowing better than

Ecosystem. The toolchain, debugger, IDE, editors are best available for C.
Probably Java programmer could also make that claim, but I dont know any
other language which could measure up in providing that sort of
developer/development ecosystem.

What sucks ?

Pointers. One thing that demands atmost discipline.

Lack of constructs. Programming languages have evolved a lot, to be more
expressive. But when C was made into C++, it increased as much frustration
as it increased fun. Okay, did it increase the fun part ?

Preprocessors. Today it has become an indespensable supplementary tool for
the C language itself, especially for large projects. Without it is very
hard to make the C code portable.
But when a programmer wants to maintain a code, he had to parse two
languages in his mind and very many architectures along with that. Atleast
I find that harmful for my brain.

Portability. A programmer in 1980s would have made portability as a
winning advantage for C language, but the wheel of history have turned the
table around. Faster processors, mature virtual machines, dynamic
translation have made languages like Java and Python as reasonable options
for programmers. There is a section which cover the “features” in C
language that makes it less portable

Undefined features. Compile and run the following code snippet on Irix,
GCC and sparc machines. You will know what “Undefine feature” means.

int i = 10;
printf(” %d %d %d %d %x “, i++, –i, ++i, ++i, i++ );

And, there are quite a few “features” like this.

Is C Portable ?

Not when you compare it with Java or python. Especially Java.

Endianess. There is a perinnial problem of big endian or little endian.

Size of datatypes. The program/programmer cannot make assumptions on the
size of the basic data types like int, shot, long, char, pointer etc…

Memory alignment. Some processors require that the half-word, word, dword
memory access are aligned. That is a half-word (2 byte) memory access
should be only through address which are multiples of 2, a word (4
byte) memory access should be only through address which are multiples of
4 and so on.

Structure packing. Based on mem alignments and packing directives, the way
in the structure members are packed and padded can vary.

Pointer arithmetic. Goddammit !!

Compiler extensions. Not all compilers play the same music. So a program
can be non-portable across compilers even on the same architecture.

Binary and binary files. Another spartan feature of C program is the
control the compiler/language can provide, on where to store sections of
data and code. A C programmer is not yet a complete C programmer without
learning linker scripts and the ELF file format. And beware, knowing them
can lead to as much pain as not knowing them.

Application Binary Interface. The problem is C language does not have one,
and it is left to the compiler to decide on that. So it is better to know
how function calls are made and return values passed back for specific
compiler tool chains that the programmer uses.

Non-exhausting list of portability problems. Well, some might disagree,
and I suggest them to complete this list.

All said, C cannot be replaced and the claims like C has outlived its need are
false. We can choose other languages if they suit better, but on any day, I
would want one language which gives enough power to the programmer. Like C.
Let us just make ourselves more spartan like.

Create a free website or blog at