-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to bootstrap it from scratch #2
Comments
I actually had a similar idea. I called it the "least fixed point of computing" (a slight abuse of the concept). Cool to see what it looks like in practice! However mini-c wasn't designed for that and wouldn't really help, I think. I used as little C as possible and only implemented enough to compile itself. If you made something complex enough to compile it, then you've already got as far as mini-c would take you. However, if there was another system with a slightly higher bar of language features, mini-c could make a good starting point to reach that. ... mini-os? |
Well so that's the other direction --- use However, to bootstrap I spent some time figuring out how best to do that, and it seems the easiest is to use Forth, or a subset of it, to be precise. Unlike BCC (see above) which is a custom made language, Forth is a well documented language, you can find tons of tutorials online, yet it seems to be very simple to implement directly in assembly, in a similar manner like BCC above. In fact, I think BCC is very close to a Forth subset, it's just that rather than inventing a new language, it's always better to target something that's already widely used. Here I found such a nice minimal self-hosting implementation of a Forth subset: https://github.com/kragen/stoneknifeforth, just like In other words, if it is possible to write a compiler that can compiler |
For anyone who is interested, I translated stoneknifeforth into C++, so it's even more portable! https://github.com/tekknolagi/stoneknifecpp |
Anybody who knows C can use your
mini-c
as the minimal self-hosting subset of C compiler and can implement the whole C compiler or other languages.What would also be interesting is to bootstrap
mini-c
from scratch. Currently you require some kind of a C compiler likegcc
to be present on the system.Here is an example of an approach that doesn't require any compiler at all, it starts from a small hand written machine code and then it goes from there to develop a structured programming language called BCC: http://rano.org/bcompiler.html (I made a mirror at github here: https://github.com/certik/bcompiler/blob/master/bcc.bc)
So the goal would be to write a compiler in BCC that can compile
mini-c
.The text was updated successfully, but these errors were encountered: