Impressive Source Codes That Every Developer Should See
Sometimes, developers write codes that impress the entire world and the hardware both
I usually browse Github repositories when I get free time. Also, when I start using new computer software, tools, or utilities, I like to see how the particular software works. Most of the time, I take a look at its codebase to understand how things are exactly working with internal modules and external dependencies.
A few years ago, I was checking about Python language implementation’s source code. Thereafter, I noticed several C source files and suddenly checked the GNU C compiler collection’s implementation. I found that this modern C compiler was written in C itself. Learning the internals of something and going back further in-depth give amazing feeling and great knowledge for us. Past developers have done great work to give a peaceful world for modern developers. However, as modern developers, we should appreciate their impressive work.
I noticed the following impressive works that have been done by developers around the world while I was browsing Github repositories.
Apollo 11 Guidance Program
Apollo 11 was the first successful mission that sent humans to the moon. Apollo Guidance Computer (AGC) which had only 4 kilobytes of physical memory provided support for controlling the spacecraft. Software for the AGC was written in AGC assembly language and was stored into a special read-only memory called rope memory. There were scanned copies of the source code uploaded to the internet some time ago. Thereafter, someone converted several modules into text files and uploaded them into a Github repository.
The Apollo engineering team put a huge effort to reach such an amazing achievement by writing a lot of code lines in assembly language. In 1960s programming was harder than nowadays. Because, at that time, programming languages had a lesser level of abstraction. Besides, programmers had to write super-optimized codes to efficiently use hardware.
Quake III Arena
Quake III Arena is a first-person shooter game developed by id Software. It was developed in the 90s when the 3D gaming industry just started its journey using the id Tech 3 game engine. At that time the hardware resources were very limited unlike nowadays. Therefore, game developers had to write carefully optimized code for rendering graphical elements. Many game programming calculations require the vector normalization concept that brings up the requirement of inverse square root calculation. As mentioned, developers had to choose the most efficient algorithms for these computer graphics related works. Therefore, the Quake III Arena team used a very clever approach for fast inverse square root calculation like below using bit-level computations.
The level of optimization used in this piece of code and the entire code written to achieve such a nice computer game in the 90s is obviously amazing. Nowadays, game development usually doesn’t deal with this level of calculations because the physics functions are already implemented by game engines.
GNU Compiler Collection
The C programming language is like the father of modern computing because it resides very closer to the hardware also by offering a good human-readable abstraction level. Indeed, the GNU C compiler is bootstrapped. In other words, It is written in the C programming language itself by using the compiler bootstrapping concept. I noticed the longest C source file I ever saw (There can be longer C source files than this one out there, but this is the one I saw) from the codebase of GNU Compiler Collection on Github.
Moreover, this codebase consists of source codes of Chromium Android and iOS apps as well. Structuring a large-scale cross-platform application can be a bit complex. However, Chromium has an impressive separation of platform-specific code for Linux, Windows, and Mac.
Nowadays, Git helps almost every software development team to manage the coding history and versions. Git was initially made by the founder of the Linux kernel, Linus Torvalds. Indeed, Git's codebase consists of a magical piece of work which is Gitk’s source file. Gitk is a GUI application that helps us to visually navigate through commits. We can use the following CLI command to check the difference between two commits.
$ git diff <commit hash> <commit hash>
But, Gitk allows us to see modifications so fast because it is a visual tool. Gitk’s whole source code is just one file. It is written in Tcl scripting language using Tk UI-toolkit which is an extension of Tcl. They have done great work by implementing an entire GUI app with just a single source file also by selecting a dynamic programming language for quicker GUI application development.