r/ProgrammingLanguages • Nain. • 20d ago

Help transpilation - Bootstrap compiler

So, I am making a compiler for my language, Nain, in CHICKEN Scheme. Should I output QBE IR or code for C or another language? This is a bootstrap compiler, I will use it only to test new language features and to compile the self hosting compiler so yeah.

1 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/[deleted] 20d ago

The intermediate stage sounds a much better idea. Then the first compiler written in Hain can be a simple port of the Scheme one that generates the same output.

Otherwise using a brand-new language to write a quite different compiler with a complex LLVM backend, sounds too ambitious to do in one go.

But also, if LLVM is on the cards anyway, why doesn't the scheme version generate that instead of C or QBE - what limitations does Scheme has that Nain will not have?

1

u/AustinVelonaut Admiran 20d ago

It depends on how LLVM is used. You can generate LLVM asm or LLVM bitcode as output, then run that separately through a standalone LLVM. Or you can directly use LLVM IR and link to an LLVM library. But the later requires that your host language have interop bindings with the LLVM library (C/C++ foreign-function interface). I don't know if Chicken scheme has that or not.

1

u/Key_River7180 Nain. 11d ago

QBE is easier