What’s so great about C?
C is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C’s features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, protocol stacks, though decreasingly for application software. C is commonly used on computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.
C is a very versatile and widely used programming language. It has been used to write pretty much everything, from low-level routines to control the hardware in embedded microcontrollers to complete operating systems like Linux with graphical user interfaces. In spite of this huge flexibility, it is also relatively simple – the language only has about 20 or so keywords, but there are huge libraries of additional functions that you can call on when you need them. In the first part of this book, we are going to concentrate on learning about the keywords, with a few of the more commonly used library functions; the second part of the book shows how to use the GTK library to make it easy to write graphical interfaces in C.
Many of the languages that you may have seen, such as Python, are what are called interpreted languages. This means that the code you write is run directly: each line of code is read in and interpreted as you run it. C is different: it’s a compiled language. This means that the code you write, known as the source code, is never run directly. The source code is passed through a program called a compiler, which converts it into a machine-readable version called an executable or a binary; you then run the resulting executable.
This may seem complex, but it has a few big advantages. First, it means that you don’t need to have a copy of C itself on every computer you want to run your program on; once compiled, the executable is standalone and self-contained. Second, the compilation process will find a lot of errors before you even run the program (but it won’t usually find all of them). Most importantly, the compilation process means that the time-consuming translation of humanreadable code into machine-readable instructions has already happened, which means that compiled code generally runs many times faster than interpreted code would.