ζeta

by Luka Napotnik

Programming Language Rant

Maybe this document will help someone from shooting his own foot using C

I’m using C as my main programming language for about 4 years now and I still learn something new every once in a while. It’s a barebone structured systems programming language, supported by almost any computer architecture. Therefore, if programming in standard C, your program will run on every machine. But the thruth is you’ll end up using a bunch of not-so-portable libraries that will limit your program to the architectures that are supported by these libraries. When I said the language is bareboned, I meant there’s no network support, 2D/3D graphics support, multithreading support, etc. If you look at standard C99 language specifications, you’ll get a very basic language. But as with libraries, in reality many operating systems (UNIX and UNIX-like) come with a programming interface called POSIX where you’ll get a lot of other functionality for C (e.g. networking support, interaction with the operating system, threading). One thing you should keep in mind that a language is a specification, written down on a paper (C98/C99), and the compilers are the implementations of the specifications. So it depends on an implementation how well the language is supported and many implementations include additional non-standard extensions to the language (like the unofficial GNU99 standard for GCC). Using the language extensions can cause that your source will compile in one compiler, but fail with errors in another one that doesn’t support the extensions

If comparing C with C# and Java and using the specification number of pages and the number of reserved words:
Programming Language
Number of Pages in Specifications
Number of keywords
C99
552
32
C# 3.0
519
77
Java
684
50

So the specifications for the langauge are roughly the same size, but differ greatly with the number of keywords. I just wanted to show even if a language seems simple, learning to use it correctly can be a long process.

And here are some of my tips for programming with C:

And lastly, the compilers. There are other compilers besides the GNC C compiler, if you’re searching for a GCC alternative, there’s clang which is a fast industry-ready C compiler with nicer output, for a very fast C compiler look at tcc.

But at the end, C is a language like any other. An old language that should really be avoided if possible. There are a lot of great languages (like Go or functional languages) and if possible choose one of them.