| main | profile | gdynia | code

Let's Start - 28.12.2025

Updates Here and There

The new year has started and I was quite busy finishing up my little Fortran build tool fob.f90. Also, because it was raining 90% of days since the new year has started, I could not manage to take any photos worth uploading here. Hence, a bit of a delay in update. Having said that, January was quite productive and I have managed to get quite a lot of things done. It will become quite technical, programming stuff below, so if you are not into those things, feel free to skip this blog post. Here are some updates:

Update 1: fob.f90

fob.f90 is a modern Fortran answer to nob.h written by Tsoding. It is yet another program building tool like make, bmake, gmake, nmake, cmake, meson... But there is one key difference. The whole thing is written in the language that project is written, so in most situations, the only thing you will need to build a program is the compiler. By doing so, we are cutting the build tools completely and improving the portability of the program. In addition, with this solution we can reuse functions those functions defined in the build tool itself, so the build tool can become part of your project. The only down side is that you need to know how to program in given language.

In C, the most minimalistic way to achieve this is by creating header only library that contains all the functions required for build and writing project specific build recipe in the C file. This is how nob.h is done and if you are interested in development, you can go and watch Tsoding's streams on it. They are great.

In Fortran, we do not and we cannot have such thing like header only library. Instead, we have modules. Even better, these modules can live in the same file as the build program. Therefore, I have reduced 2 files to one file containing all the functions and build recipe itself. All the functions required are defined in the module fob and actual build recipe defined in program fob defined below. To run this, you just need to bootstrap it by compiling the file and running it.

Quite neat, right? Yes and no. The big trouble was around making it portable. nob.h was heavily dependent on C pre-processor and its rather impressive capabilities. Just the concept of header only library itself relies on pre-processor. Not to mention, all the platform specific switching and tweaking was done using pre-processor. So it might be natural to think that I have used pre-processor capabilities to do the heavy lifting.

Not exactly... The lack of officially documented pre-processor (unless you are one of those who would count CoCo as a preprocessor) is a long discussed, well known issue in Fortran. There are several implementations of pre-processors, some even coming with the compiler. However, none of them are standardised and there are inconsistencies between all these pre-processors. Therefore, it is hard to assume any of the pre-processor's functionality to be there and to be working in intended way. This makes really difficult to make code compile and get the same executable among different compilers.

Solution to this?

Create yet another Fortran pre-processor and bake it into the module.


Source: XKCD: Standards

At this point you might think that I am re-inventing the wheel. To some extent yes but judging how primitive I kept it, it is more like one big switch statement with some string slicing. I wanted to be small, portable predictable. Therefore, I have limited it's capabilities to whatever the Plan 9 C Compiler had available; only #include, #define, #undef, #ifdef, #ifndef, #else and #endif. This was enough for Rob Pike and his colleagues, so it should be enough for all of us.

With this pre-processor, I have managed to do all platform specific changes by self recompiling similar to NOB_REBUILD_URSELF.

Another little challenge was to allow creating fob.o that can be reused as module in other program without getting compiler error of having two main programs. This was solved in relatively dirty way by just saving the module bit to the separate file temporarily and compiling it separately. After all, this works but I am still slightly bitter about this ugliness.

I have been developing this for last 2 months or so. It taught me a lot around C interoperability, Fortran's limitations and pain finding/coding workarounds. However, judging how old Fortran is, it has been enjoyable experience and I hope somebody will benefit from this project. Potentially, it might be an idea to build one of the Fortran libs using this build tool. We will see, but for now I want to take a bit of rest from it.

Update 2: Slow, Painful but Rewarding Switch to FreeBSD

I have been thinking about shifting to FreeBSD for a while. FreeBSD is a decendend of BSD variant of UNIX that is open source and freely available. Since it based on UNIX, it has a lot of similarities to Linux as well. However, the key difference is that all the BSD varians are maintained and shipped as whole operating system. Therefore, both kernel and userland are developed as same project unlike Linux with GNU utils.

The reason of this shift is because I am tired of all the AI slop that microsoft and their friends are trying to force on us. It is mostly data collection practice with introduction of multiple of vurnelabilities with little to none good for user. Another reason is the independency. I just want to have a control of what I install on what hardware. Not some big tech company installing some doggy ones behind of my knowledge.

I have tried to install FreeBSD on my laptop before but back then, the wifi driver was still in early development stage, resulting in not the most useable desktop experience. Now, there are two different drivers available for intel AX201 cards which is looks much more promissing. So far, there were many things to configure here and there and I am still finding my way for nVidia GPU to work (no wonder nobody likes them in open source...) as intended but there is progress. I hope I will finally be able to complete transition by summer. I will keep you posted.


These are my updates. Sorry for long text but I had to share about these somewhere since my wife is already tired hearing any of these topics. I will try to make next post to be less technical. Promise...

All posts that hasn't disappeared yet