10 Reasons Why C is Still the Best Programming Language

Programming has changed a lot since the 1960’s, and more so since the 1970’s, but one language has managed to stay the same through thick and thin: C.

When C compilers had gotten into the hands of the common man, things really exploded. At a glance, you may see nothing special about C (you might even say it sucks compared to something like Ruby or Python nowadays), but C is way more powerful than you think. Compared to the current languages of the time like COBOLFORTRAN, or processor-specific Assembly language, C was like programming heaven. Where confusing, system-specific Assembly language once stood, C replaced with a toolkit no programming language today has ever truly remade.

Since C was such an amazing language, here are my top ten reasons C is still the best programming language!

10. C is portable

Before C, programmers had to rely on Assembly. Assembly is no doubt a great language (the creator of Rdio went as far as to say C is like a DSL for Assembly code), but there was one drawback–it was based on system instructions differing between CPUs. This meant that Assembly written for an Apple II didn’t work with assembly for a Commodore 64. When C came along, software meant for an Amiga could be run on a MS-DOS with no, or very little modification!

9. C has a nice syntax

It sounds like an odd thing to say, but C’s syntax is beautiful. C has often been portrayed as the ugly duckling of programming linguistics, but it is a very definitive way to write a language that interacts with the machine at such a low level. Compare it to its predecessor, Assembly, and I’m sure you will find it very clear (this example uses x86-64 Linux Assembly with AT&T syntax):

	.section	.rodata
string:
	.ascii "Hello, world!\n"
length:
	.quad . -string		# Dot = 'here'

	.section	.text
	.globl _start		# Make entry point visible to linker
_start:
	movq $4, %rax		# 4=write
	movq $1, %rbx		# 1=stdout
	movq $string, %rcx
	movq length, %rdx
	int $0x80 		# Call Operating System
	movq %rax, %rbx		# Make program return syscall exit status
	movq $1, %rax		# 1=exit
	int $0x80		# Call System Again

Or in C:

#include <stdio.h>

int main()
{
    printf("Hello, world!\n");
    return 0;
}

Yeah…

8. C has macros

Aside from the occasional LISP, it’s hard to find many programming languages that fully utilize the power of macros nowadays. Languages like RubyPython, or Perl just don’t use them.

This makes me sad. With the flexibility of macros, one can design the language from the language! C macros run through the C preprocessor, which replaces all keywords matching the name of the macro with the specified macro text. This lets you do some crazy things, like creating custom keywords for if-statements:

#include <stdio.h>

// The '#define' preprocessor flag creates a macro.
#define IF_EQ(a, b) (if (a == b))

int main()
{
    char a = 'A';
    char b = 'B';
    IF_EQ(a, b)
    {
        printf("Yay!\n");
    } else
    {
        printf("Boo!\n");
    }

    return 0;
}

In the above program, we define a macro called IF_EQ, taking the two macro arguments (yes, there are function-like macros) a and b. When we use the IF_EQ function in the main C function, the IF_EQ text gets replaced with the if statement text in the macro definition. Thus, our IF_EQ(a, b) becomes replaced with if (a == b) by the time our source is compiled.

7. C has no pre-defined style

Despite its reputation of chat-channel flame wars, the fact that C has no style guide can actually be quite good. In a sense, C teaches you to accept the fact that you’re not the only one coding in the world. Macro naming, function naming, and data structure naming all depends on your preference of style.

6. C is small

Since C is fully based on variables, macros, functions, and structures, there isn’t all that much to it. Due to this, C has been embedded on almost any modern microprocessor, from fridges to alarm clocks. With a bit of hacking, you can embed some C on your Arduino right from home!

5. C never really changes

Ever since Dennis Ritchie invented C over the 70’s, C’s fundamentals have never really changed. It still has functions, structures, and variables exactly how it had them in the original book on C. C code that’s written in these books can still be run perfectly with modern compilers like the GNU C Compiler (GCC) or the LLVM C Compiler (Clang).

4. If you know C, you know C++ and Objective-C

It’s true to say that C is very different from C++ and Objective-C, but from a learning standpoint they all aren’t that far apart. C++ and Objective-C are are simply subsets, or dialects, of the same C language we all know. If you can run C in your C compiler, you can likely run it with little language-specific modification in your C++ or Objective-C compiler. In fact, I highly recommend you learn C (others do too) before you learn Objective-C or C++, since it will introduce you to their core concepts.

3. Know C? You know everything else, too!

Since almost all programming languages nowadays are themselves implemented in C, knowing C basically gives you a free ticket to knowing all programming languages. Of course, C is a procedural language, which means classes and objects are non-existent compared to languages like Python, but Python’s class model itself is written in C. This means that understanding C may not teach you object-oriented programming, but it will teach you how it was conceived, designed, and implemented.

2. C interacts with the computer near the lowest level

Sure, it’s not garbage-collected, memory-leak-free, or simple, but C’s ability to interact with the computer at a level near the memory itself is certainly useful. Before C, you had to use a language like Assembly to control the computer at its heart. Though this was ok for the time, it still meant thousands of complex instructions and routines for programmers to try and understand through a mess of memory management. In the post-C era, you can interact with all the bits and bytes in a safer, more understandable manner.

1. C powers the world

The number one reason C is the best programming language today is still the fact that it simply powers everything. From your phone to your Wii, no other language provides the level of hardware interaction with the practicality of a concise and expressive syntax. Unless you’re still using an early IBM (please switch soon, if so), the screen you’re reading this article on is probably powered by C.

With C, we can forget writing thousands of complex Assembly routines, thousands of processor-specific instructions, and spaghetti like code. Because of C, the CPU, memory, and graphics cards have turned from their messy, low-level pasts into an easier, readable format.


The verdict

As processors advanced, so did the Assembly code running on them. If it wasn’t for good ol’ C, programming a 3GHz processor would be a much greater task than it is today. Because we have C, we can talk to computers easily and effectively. Due to this, I think we should all accept that C is the best programming language possibly ever created.

RIP Dennis Ritchie, creator of C, September 9 1941-October 12 2011.

Leave a Reply