About this blog
Daniel Andersson 2022-06-02
In the last couple of years I have been trying to reduce the complexity, and to some extent the lines of code(LOC) I use and create. As an example we can take this blog, how many lines of code does it take to provide you this text? We will have to simplify a little bit since how many lines of code Windows or MacOS have is not public. We will instead assume the reader uses Linux.
The reader uses a browser, which talks to some form of window manager and the kernel. The kernel asks the network card to send data to some form of home router. The home router then sends the data to another router, which then passes it on to another router and so forth, until the data reaches the computer with the webserver on it. The kernel then sends the data to the webserver. The webserver can then send the requested data back to the client. The data then goes back to the reader’s web browser in the reverse order.
Source | Lines of Code |
---|---|
Chromium | ~35 MLOC |
Gnome | ~19 MLOC |
Xorg | ~410 kLOC |
Linux | ~22 MLOC |
OpenWRT | ~800 kLOC |
Cisco | ~500 kLOC |
OpenBSD | ~19 MLOC |
That sums up to about 100 million lines of code. I could have used a nginx webserver(150 kLOC), instead of httpd(10 kLOC), which is 15 times less code. I could have used Hugo(180 kLOC) or Wordpress(900 kLOC) for this blog. I instead write the blog entries in Markdown. The markdown is output in HTML5, using lowdown(24 kLOC). A 600 LOC python script generates all the webpages with correct <headers>
etc. Additionally, the python script also outputs a RSS feed. The only thing that I would like to have, that I currently don’t have, is syntax highlighting for source code.
Nginx + hugo is approximately 330k LOC, and my custom blog is approximately 35k LOC, using httpd, lowdown and the python script. That is almost 100 times less code used, but in the scale of 100 million lines of code, saving 300 000 lines is only 0.3%. My point is that it is impossible to escape the complexities of software today. It would take a lot of effort from a lot of people.
Other blog entries may be how to implement some features, like how to recompile GPU-, or regular C code, and run it without having to restart your application. Another is why it might be worth it to implement your own assert().
There will likely also be retrospectives. For example if I learned something new, how and what resources would I use if I could do it again? One blog post will be how I would relearn OpenGL, or if I should just have used an engine or library instead.