What Language is Linux Written In? A Follow-Up: Page 1
“What language is Linux written in” is a very difficult subject to tackle. (A colleague of mine recently covered this topic in this article.) This is due to the fact that many users think that Linux is actually a full-fledged operating system, but this is not the case. In order to understand the subject completely and the right way, we have to understand the difference between “Linux” and “Distributions.”
- Linux is the operating system kernel, which is the core component of the operating system that is responsible for managing system resources. The management of system resources is the communication between the software and the hardware components. Basically, when you execute a program, it goes to the kernel and asks for some processor, memory and, depending on the program, disk space.
- Linux distributions are the operating systems that are built on top of the Linux kernel. All of the distributions use the same kernel, but applications may be quite different from one another. For example, Ubuntu is a user friendly distribution, oriented towards newcomers and includes programs such as OpenOffice.org (office suite), GIMP (image manipulation), etc., which a standard user requires. However, there is another distribution, BackTrack, which uses the same Linux kernel but has programs for security auditing, forensic investigation and penetration testing. So, the program AirSnort, used for wireless network security auditing is available in the Backtrack default installation but not in the default Ubuntu installation. That’s just one example of how a single Linux distribution can differ from another.
If we give an example with Windows and Linux Distributions; Windows’ kernel is kernel32.dll but the operating system has Control Panel, Notepad, Wordpad, Disk Defragmenter, Internet Explorer, Outlook Express (or Windows Live Mail), Windows Media Player, etc.. So, “I am using Linux” is the more or less the same, in Windows speak, as “I am using kernel32.dll.” We are not using Linux, we are using a “Linux distribution”. We are not using kernel32.dll, we are using Windows (more about this in the second page, under the “Libraries and Utilities” section).
Of course, it is not only the kernel and the operating system; there are device drivers, standard files and folder structures, and libraries, which together form the baseline of the operating system. You can see the abstraction layers on the image to the right (Image credit: Wikimedia Commons/Miko3k and Tene).
One cannot expect the whole operating system to be written in just one programming language; not because it is technically impossible but because different programmers use different programming languages. But of course there are some technical limitations, other than experimentation purposes. You will not write a graphical user interface program with Assembly, and Visual Basic will not permit you to write hardware device drivers. There are some projects on the Internet like Jnode, which is an attempt to develop a complete operating system in Java. But the kernel is in Assembly.
Now, let’s see which language is used in what part of the operating system.
Kernel and Device Drivers
Kernel and device drivers operate at the lower level of computer operations. To write an operating system kernel and to access the hardware’s properties - such as memory cycles, input/output buses, etc. - you need a program that can “communicate” with the hardware. For this purpose, you need to use a low-level programming language where the language requires a very small or no interaction with the computer’s instruction set.
In Linux, the kernel and the device drivers are written in C with a small amount of Assembly code. We will not go into the details of the loadable kernel modules here since it is not in the scope of our article.
Libraries and Utilities
We have just scratched the surface of the kernel and Linux issue when we compared it to kernel32.dll. In fact, kernel, libraries and the common *NIX utilities are what make “Linux” the core of the operating system. Nobody can imagine a Linux distribution without stlibc, gcc etc.. And, also, nobody can imagine a working system without core utilities such as mkdir, chmod, chown, head, tail, chroot, uptime, users, etc.. These utilities are also written in C.
Package Managers and Configuration Programs
Package managers are the programs that control the application’s install and uninstall processes, taking the dependencies into account. For example, in openSuSE and Fedora yum is the package manager and apt or dpkg fills that role in Debian based systems such as Ubuntu. Many of the package managers and configuration programs are written in C.
The graphical front-ends to the package managers and the configuration programs are completely different issues. As the baseline, we can consider them to be written in Python (GTK, QT, Tcl/Tk to follow in Graphical User Applications).
Window Managers and Desktop Environments
Considering that the majority of standard users use a desktop environment, we have to look at what that is first. A desktop environment is a graphical interface that is designed to assist the user with routine computer use. For example, a user can issue the command mv file_a /dir/file_a to move the file named file_a from the present working directory to another directory named /dir, or he can open up a file manager and then drag the file from the present directory to /dir and drop there. This is one of the functions of a desktop environment.
A desktop environment includes icons, windows, toolbars, folder views, wallpaper, etc.. Typically, a desktop environment is based on specific libraries and the libraries make the desktop environment consistent in look and feel. In the case of the top two desktop environments, Gnome uses Metacity and KDE uses KWin window managers. Both Metacity and KWin are developed in C, and thus require GCC to compile.
Graphical User Applications
This is where many programming languages come into play. You can write any application using any language you want including the graphical user interface. This includes C, Python, Java, Perl, and others. For that program to run in a graphical user interface, you can use the libraries for the desktop environment that you plan your program to run. Let’s give an example: you have written a program to watch user-defined tweets from Twitter. You can design a user interface that uses GTK libraries to make the program look native to the Gnome Dekstop Environment, but you may write the underlying code in Perl. Then you can go on further and define a user interface by using QT libraries if you want your program to look native to KDE. Or, if you want, you can write the interface by using Tcl/Tk libraries. Synaptic and Kynaptic can be good examples; both use the same underlying code but Synaptic uses GTK and Kynaptic uses QT.
Or if you want full control, you can go with the Java development environment and use the Java graphical libraries. There are many programs available – one of them is Datacrow, which I use to catalog my media and book collection.
In the answer to the question “what language is Linux written in” one must know that technically he is referring to the kernel, utilities and libraries. This is simple: C and Assembly (to some extent). But if one is referring to the whole Linux distribution, then the answer is “it depends” because we do not know if the user is referring to a particular application or any other system component.