Tech News
← Back to articles

Signals vs. Query-Based Compilers

read original related products more articles

📖 tl;dr: With the rise of LSPs, query-based compilers have emerged as a new architecture. That architecture is much more similar and also different to Signals than I initial assumed them to be.

Over the winter holidays curiosity got the better of me and I spent a lot of time reading up on how modern compilers achieve interactivity in the days of LSPs and tight editor integrations. And it turns out that modern compilers are built around the same concept as Signals in UI rendering, with some interesting different design choices.

Old Days: The Pipeline Architecture

The classic teachings about compilers present them as a linear sequence of phases that code runs through until you end up with the final binary. Writing a compiler this way is pretty straight forward, assuming that the language is reasonably simple (JavaScript is ridiculously complex and the opposite of simple).

Source Text -> AST -> IR -> Assembly -> Linker -> Binary

First, source code is transformed into an Abstract Syntax Tree (=AST) which transforms the input text into structured objects/structs. It's the place where syntax errors, grammar errors and those kinds of things are caught.

For example: This JavaScript source code...

const a = 42 ;

...is transformed into something similar to this AST:

{

... continue reading