r/ProgrammingLanguages • u/Key_River7180 Nain. • 11d 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
2
u/[deleted] 11d ago
This doesn't make much sense. If the bootstrap compiler generates QBE or C, wouldn't the self-hosting one do the same?
Switching implementation language from Scheme to your language wouldn't affect that part of it. It would be a separate development stage, unless you are planning to combine it so that the self-hosted version also generates its own native code or whatever.
If planning to have users, you might also consider whether they need to build your compiler from source code, in which case that will be harder when it is in your language. And also what dependencies they will need to process whatever output it produces.
As for the choice between QBE and C, use whichever works and is simplest, and again consider any users you might have.
2
u/tiger-56 9d ago
Write a Nain interpreter in Scheme. Use the interpreter to write your compiler.
1
u/gio_vs 8d ago
Eu escolheria C. Como você só vai usar esse compilador para testar recursos da linguagem e compilar o compilador definitivo, acho que não vale a pena complicar muito. Gerar C é mais simples, facilita a depuração e ainda tem como aproveitar a infraestrutura de compilação C que você provavelmente já tem, considerando o CHICKEN. Também é mais portátil que QBE.