Home The Holy C language review (for TempleOS) ✝️
Post
Cancel

The Holy C language review (for TempleOS) ✝️

TempleOS is an operating system that Terry Davis had been developing for many years alone. The development began after a psychiatric hospitalization, during which Terry was diagnosed with schizophrenia. According to him, God ordered him to develop an operating system that should become the “Third Temple”.

Almost all his life, Terry was unemployed, so he was developing his operating system all day long. In his spare time he was flooding various forums with his ideas related to the CIA, conspiracies, and blasphemers.

This guy is popular. Fans wrote his biography, made videos on YouTube. He wrote his own loader, kernel, window manager, graphics library, games - all in his own Holy C language with his compiler.

The design of C† is described here, and also here you can see simple programs. It is similar to C with the addition of many features.

Compiler’s source code is hard to read, but something is understandable.

The lexer, which parses the source code into tokens, does this with making changes of the current state in CCmpCtrl *cc, because the parsing of tokens occurs simultaneously with the parsing of expressions.

The parser which parses expressions is made in the form of a simple recursive descent. For example, this is what parsing of an if-expression looks like. The parser creates blocks of “intermediate code”.

The “intermediate code” is optimized in many ways, for example, there is constant folding (wiki description) and optimized register allocation (wiki description). Then the intermediate code is translated into assembler.

One of the disadvantages of the compiler is that it uses a single pass (because of this, the language is closer to C than to C++), as well as support for only one architecture.

The compiler is really not bad, it is clear that its author was an extraordinary programmer to write all programs of this level alone (including the operating system)!

This post is licensed under CC BY 4.0 by the author.

std::unreachable - safe shooting yourself in the foot 🔫

Thin client for C++ developers (with screenshots!)