On Invocations

2006-10-04 (permalink tags: , , )

There is no doubt that all programming language have problems and that a new one is needed as soon as possible. Once someone has an idea of what he want his language to be, he need to write either a compiler, an interpreter or both. You don't see pure interpreters that much these days, most language implementations at least compile to byte code. Though the principle of a compiler is simple, we see them as obscure forgotten charms carefully crafter by wizards with powerful incantations.

A compiler just translates the text of a program in language A into a program in language B. Technically, the lexer split the program into tokens. The parser then build a tree with the tokens and give this tree some meaning, that's the abstract syntax tree (AST). Finally the code generator walk the tree and print all the nodes in language B.

For a really simple language a compiler will fit in a few hundred lines. It gets tricky when you want to make an interesting language. For the language to be fast you need to transform the AST to eliminate slow operations. Such optimizations include loop unrolling, function call inlining and tail call eliminations. Interesting languages will also include a runtime environment: closures bindings, garbage collectors, type system, etc. The target audience for those topics being limited, there are no general resources where one could learn them. But if you ask in the right place, you might get a list of grimoires with many spells related to those dark arts.

Even though thaumaturgy will never be easy to learn, it is comforting to see that one can learn to conjure without going through apprenticeship. As the task of making a new programming language becomes surmountable, the question "What feature should a new language have?" becomes fixation, a puzzle that the warlock must solve to achieve wizardry.

Leave a comment