TinyCompiler: A Weekend Compiler Project

2025-02-20

This project details the creation of TinyCompiler, a minimalist compiler built in a weekend. It translates the esoteric Wend programming language (created by the author) into GNU assembly. Wend is a simple language, omitting pointers, arrays, and other complexities, focusing on core compiler concepts. The entire project is under 500 lines of Python and includes test programs like fixed-point square root calculation, Mandelbrot set rendering, and simple games. It's a great resource for learning about compiler theory.

Read more
Development

C Code with Only `#define` Directives: Black Magic Fire Animation

2025-02-20

This article details how the author created a fire animation program using only the `#define` directive in C. This seemingly impossible task was accomplished by cleverly using the text replacement capabilities of macro definitions, token concatenation, and recursive call techniques. The result is a simulation of fire burning and spreading, demonstrating the power of the C preprocessor and its 'Turing completeness'. The article also highlights the potential risks and problems of improper macro use.

Read more
Development preprocessor