I love this sort of miniaturization in virtualization. In college, I did an independent study where I created a stack-based VM in C -- designed the ISA, wrote an assembler, etc. It wasn't very good, but I was able to write simple programs and run them. It felt like magic to me. I wrote a Sudoku solver in MIPS assembly [1] a while before that, and I wanted to port it over but I was missing some features. And now that's gone. #LikeTearsInRain
I haven't really revisited virtualization. Sad thing about my career is that I don't really get to spend half my time working on indendependent study.[2] All of my side projects tend to just be spurts of inspiration that fizzle out quickly.
Anyway, I'm gonna dig into this. It looks awesome!
There's a very interesting C interpreter/compiler there [1]. From the header:
"c is the c compiler. It takes a single source file and creates an executable file or else executes the compiled code immediately. The compiler does not reach full standards compliance, so some programs need minor adjustment.
There is no preprocessor, although the #include keyword is allowed supporting a single level of file inclusion."
You know what I find amusing about the C compiler? It's about the same size as the kernel in terms of LOC. I don't know why, but that amuses me.
This whole project just really makes me happy. I think it's because it's obviously a labor of love, it's very UNIX-y, yet at the same time, utterly comprehensible. I think this is a nicer environment for just general screwing around than a PDP-11 emulator running real V6. The core looks to be all here, without having to bear the weight of complexity implied by a real implementation.
This C compiler, at ~2297 LOC (this number includes empty lines, actual LOC is less) -- is certainly worthy of being included in the group of small C compilers for study!
9.5/10 for me (could still be smaller and could still be better documented -- as could all other small OS'es/compilers -- so not a criticism -- a global group observation!)... but that being said, kudos to the author for what was no doubt a lot of hard work!
I haven't looked closely, but this appears to be the C4 compiler (or an update to it), which has been around for a while and is worthy of attention in itself.
The C4 compiler is certainly fascinating and worth studying but don't believe that swieros's C compiler is based on that judging by their code [1][2]. There are similarities of course but well they are compiling the same language after all using some similar standard techniques like recursive descent parser [3].
Anyways, C4 is also very cool and focused on minimalism. Swieros's compiler seems much more extensive and even includes #define as the other comment mentioned and va_args.
Reminds me of one of my project ideas that will probably never happen: Build a mini bare-metal Minecraft clone and then build a CPU inside it capable of self-hosting the whole thing.
I love this sort of miniaturization in virtualization. In college, I did an independent study where I created a stack-based VM in C -- designed the ISA, wrote an assembler, etc. It wasn't very good, but I was able to write simple programs and run them. It felt like magic to me. I wrote a Sudoku solver in MIPS assembly [1] a while before that, and I wanted to port it over but I was missing some features. And now that's gone. #LikeTearsInRain
I haven't really revisited virtualization. Sad thing about my career is that I don't really get to spend half my time working on indendependent study.[2] All of my side projects tend to just be spurts of inspiration that fizzle out quickly.
Anyway, I'm gonna dig into this. It looks awesome!
[1] https://github.com/ndouglas/MIPS-Sudoku-Solver/blob/main/mip...
[2] "I've been in the private sector. They expect results." – Dr. Raymond Stantz