HeadlinesBriefing favicon HeadlinesBriefing.com

Ray Tracer Written in Brainfuck Language

Hacker News •
×

The author relearned CMake while preparing for a C++ systems programming competition and encountered claims about writing tools in general-purpose languages. Intrigued by the suggestion to write a raytracer in CMake, the author instead chose Brainfuck (BF), a minimalist language with only 8 operations and a one-sided infinite tape of cells storing u8 values. BF's simplicity seemed ideal for creating a straightforward codebase.

The implementation used a signed Q16.16 fixed-point format for numeric representation, providing sufficient resolution and range for rendering a scene with a sphere of radius 1000. The project aimed to render the exact image from RIW's Metal section, avoiding complex C parsing. Code was converted to an SSA-like format using an LLM, with recursive code made iterative and variables prefixed to prevent naming collisions.