YouTube Summaries

← All summaries

Building a Nix-Inspired Style Language in Jai

2026-06-11 Thu ⏱ 3 hr 54 min @TsodingDaily

A ~4-hour live recreation-programming stream where Tsoding starts designing a Nix-inspired configuration language to replace the INI-based styling system of his custom Jai+raylib stream-overlay app. The motivation: he reinvented CSS with a flat INI file and now needs variables and cross-references.

The existing system (the problem)

His stream timer/music-player overlay is a native Jai app using raylib (not Electron/web). Layout is driven by a hot-reloaded `style.ini` file parsed with his own 129-line INI parser. Elements (timer, thumbnail, title, link/QR, logo) read fields like left/top/width/height; a `place_texture_element` helper auto-pulls common fields, plus features like `frame true` debug borders and `hide`. Effectively he reinvented HTML+CSS: code places elements, the runtime style file determines position/style.

Why INI no longer cuts it

  • No variables: three center-aligned elements share the same `left` value but must be edited in three places. He wants `style.thumbnail.left` references.
  • No expressions/conditions: wants e.g. title offset by thumbnail.left + 10, and a single flag that swaps the normal timer for a "wiggle" timer and adjusts the whole composition (currently a separate duplicated style file).

The Nix-inspired design

  • Goal: "JSON if it were a programming language" — object-like sections, no string-literal keys, cross-referencing fields, expressions.
  • Values can reference other values (`style.thumbnail.left`) and form a graph, not just a tree, since references can cycle.
  • This implies lazy evaluation (confirmed Nix is lazy) — incomputable/cyclic expressions are fine if never accessed. Access pattern: query a typed path (e.g. `style.title.left` as float), evaluate on demand, cache, return.
  • Implemented as a separate Jai module; may open-source it. He embraces Jai's limited availability as "bullying viewers into education" — they must reimplement rather than copy-paste.

Session arc

Per the chapter list: problem framing → Nix-inspired language design → API design → using stb_c_lexer for tokenizing → parsing → dumping the tree → querying the tree → planning next day. Roughly an hour of intro before coding. Ends with a long off-topic Q&A (competitive programming, Belarus, retro consoles, drawing).