I remember it like it was yesterday. It was a very calm and pleasant evening, when, all of a sudden, amos the fasterthanlime published an article entitled "A terminal case of Linux". With a title that makes you sigh when you get it, he explains his adventure of capturing colored terminal output of a Linux process. After a journey through the bowels of libc, the Land of Terrible Truths, and as is in Amos's style, many underlying details of the problem, we arrive at a program that does what we'...| compilercrim.es
A typical Forth system provides a simple exception handling mechanism, in which a single integer, that identifies the exception, is thrown. If we end up catching the exception, this scheme works reasonably well. However, if it bubbles up to the very top and gets printed to the user, we'd like to show a bit more context.| compilercrim.es
Considering Forth's low-level nature, some might consider it surprising how well-suited it is to handling exceptions. But indeed, ANS Forth does specify a simple exception handling mechanism. As Forth doesn't have a typesystem capable of supporting a mechanism like Rust's Result, exceptions are the preferred error handling strategy. Let's take a closer look at how they're used, and how they're implemented.| compilercrim.es
...though it's not the flagship borrow checking that's at fault. What I noticed, and would like to share with you today, is that the exhaustiveness checking performed by the Rust compiler on match patterns is a superset of the SAT problem.| compilercrim.es
Last time, we started from the barebones Miniforth kernel, and implemented branches by writing additional primitive words in assembly. For pragmatic reasons, that is the road I will be pursuing further, but I noticed that it is also possible to implement branches in pure Forth. I believe that this approach is quite interesting, so let's take a detour and get a closer look.| compilercrim.es
The set of words available after Miniforth boots is quite bare-bones. One reader even claimed that, since there's no branches, it is not Turing-complete, and therefore not worthy of being called a Forth! Today is the day we prove them wrong.| compilercrim.es
Software is full of circular dependencies if you look deep enough. Compilers written in the language they compile are the most obvious example, but not the only one. To compile a kernel, you need a running kernel. Linkers, build systems, shells. Even text editors, if you want to write the code instead of just downloading it. How do you break this cycle? Since the bootstrapping problem has first come to my attention, I've been drawn to this unique area of software engineering. Not out of fear ...| compilercrim.es