Fun with Compiling Your Software
日本語はこちら。
I've recently started compiling a couple of my tools.
With the advent of package managers like Homebrew, it's becoming much easier to compile software that used to be really hard. You had to download the necessary libraries beforehand, know the necessary compiler flags, etc. If anything failed, you actually had to know how the development tools work for the technology stack that the software is using.
(Quick note: I am not referring to tools that "happen to get compiled" as part of your package manager's (e.g. Homebrew) installation process. I'm talking about tools that you have to run the compiler yourself.)
Let me give some examples of software I personally compile and state what I find useful about doing it.
Example 1: Vim
As most of you probably know, Vim is a text editor that has been around for more than 30 years and is being used by many, many engineers (and probably non-engineers too). As it's been around for so many years, it's pretty much available in almost all OS that we usually use.
You may ask why I download it and compile it myself.
The reason is actually simple. I have a cheap Windows laptop that I sometimes use for simple tasks. Just like anyone who loves shell environments would do, I run Ubuntu with Windows Subsytem for Linux (WSL).
Unfortunately the official Vim version packaged with Ubuntu is old (8.x) and the only major PPA (Personal Package Archive) for Vim seems to be not maintained anymore.
So what did I do? Compile it yourself 😀
I have a quick Zsh script that downloads the Vim source code from GitHub and runs the build script. This may sound a little complex but once you have the necessary dependencies installed, it's as simple as:
make install
It's surprisingly straight forward and have never had trouble with either the the compliation nor the artifacts.
Example 2: llama.cpp
The 2nd example I would like to introduce is llama.cpp.
llama.cpp is an open-source C++ library/binary that allows you to run LLMs in an efficient way that you can run it on your local machine. It started off as an implementation of Llama, an "open-source" LLM by Meta (I've put open-source in quotes because there are debates as to what "open-source" means for LLMs). It has rapidly grown that it has out-grown it's name and supports various LLM models.
Because it is growing so quickly, any cutting edge models are not available in any pre-built binaries.
So what did I do? Compile it yourself 😀
Whenever I come across a new model that I want to try out, I build llama.cpp from source and feed it the model. The code, I think, is well maintained that I've never had trouble with the compilation and the models tend to run fine.
Why?
You may ask why I compile software myself. It's obviously easier to just download the pre-built binaries, less error-prone, and quicker.
But I find it useful and gratifying in a couple of ways.
What I find useful
The first thing I think is useful is that, you can learn how other people structure their code. You can see how they organize their code, how they handle dependencies, how they handle the build process, etc. You can learn from just browsing the repository but actually trying to build it forces you to understand these aspects more deeply.
Another thing I find useful is that it gives you a better understanding of the software you are using. For example, the software may have a feature or option that is not well documented and unclear. Because you have the source code at hand, you can easily look up the code and see what it does.
Both of the above not only deepen your understanding of the software itself but also can be applied to your own development or be a reference for you which I find useful.
What I find gratifying
The first thing I find gratifying is that you can use the latest functionalities. As I mentioned in the examples above, you can use the latest features that are not available in the pre-built binaries. This is especially useful for software that is rapidly evolving (like llama.cpp).
Also there's a sense of "being in control" of what you use which is also gratifying. Though you may not tweak anything, you can feel the power of being able to tweak it if you want to.
I actually build my Vim with the latest features and fixes 1-2 times a week😄
Try it out, have fun
Ok, I think I've said enough about compiling software yourself. Just give it a try with a software you use and want to know about more deeply. I'm sure you'll discover new insights and have fun with it.