4 ms·
"Minimal" being almost 5KLOC, sheesh. Actually, I'm surprised that a C compiler fits in that space. Also: --- Goal This is a set of manually created hex pro
by chomp 4y ago
"Minimal" being almost 5KLOC, sheesh. Actually, I'm surprised that a C compiler fits in that space.
Also:
---
Goal
This is a set of manually created hex programs in a Cthulhu Path to madness fashion. Which only have the goal of creating a bootstrapping path to a C compiler capable of compiling GCC, with only the explicit requirement of a single 1 KByte binary or less.
- adastra22 4y agoI would think that making a minimal forth or lisp would be the better path towards that goal, then use that to bootstrap a c compiler.
- pabs3 4y agoA recent comment from LWN on that note: https://lwn.net/Articles/893608/ https://lwn.net/Articles/893608/ I asked about this on their IRC channel and got this response from oriansj: Well we did bootstrap a FORTH from hex: https://github.com/oriansj/stage0/blob/master/stage2/forth.s https://github.com/oriansj/stage0/blob/master/stage2/forth.s and we did bootstrap a garbage collecting Lisp from hex: https://github.com/oriansj/stage0/blob/master/stage2/lisp.s https://github.com/oriansj/stage0/blob/master/stage2/lisp.s but if you notice: https://github.com/oriansj/stage0/blob/master/stage2/cc_x86.s https://github.com/oriansj/stage0/blob/master/stage2/cc_x86.... writing a C compiler in assembly that supports structs, unions, arrays, inline assembly and a bunch more was done in less than 24 hours by an inexperienced C programmer. Who then after started doing bootstrapping speed runs to demonstrate how trivial of a problem it is to implement that level of functionality in a C compiler. In the decades for which Lisp and FORTH existed, why didn't they solve such a trivial problem? Or better yet, now that you can see how it is done. Could anyone actually produce a C compiler with the same level of functionality in Lisp or FORTH in the same amount of time (or less?). It is easy to talk a big game and words are cheap, we have the entire cc_* family of C compilers written in assembly for multiple architectures and in even cross-platform arrangements. If your language was any good at bootstrapping you'd be able to beat that. Then show your language written in less lines of assembly than cc_x86 to prove the point. Please prove me wrong with working code. Assembly and C have working code good enough to bootstrap GCC+Guile+Linux for more than a year now. https://github.com/fosslinux/live-bootstrap https://github.com/fosslinux/live-bootstrap https://github.com/oriansj/stage0-posix https://github.com/oriansj/stage0-posix It is time for Lisp and FORTH to either deliver or learn to stop talking about something they never were good at in the first place and learn to admit Assembly and C won not because "worse is better" but because objectively they are better languages for bootstrapping new and better tools.
- ducktective 4y agoI miss these technical provocative challenges. Nowadays, everyone tries to "not offend" people.
- samhw 4y ago'Nowadays' as opposed to ... 7 hours ago?
- adastra22 4y agoI mean there are Forths that fit inside a boot sector (<512 bytes). My reading of the goal was a minimal kernel of code from which the larger system can be bootstrapped. Here’s a C minimal compiler in forth for the next stage: https://groups.google.com/g/comp.lang.forth/c/lBYFfVJ1qhc/m/BxvaTHCX_JgJ?pli=1 https://groups.google.com/g/comp.lang.forth/c/lBYFfVJ1qhc/m/...
- mypalmike 4y agoThat an inexperienced C programmer wrote what appears to be 5000 lines of assembly in 24 hours implementing a fully working C compiler seems... a rather extraordinary claim. The file size of around 130K would indicate typing non-stop for 24 hours at something like 100 characters per minute.
- a9h74j 4y agoMaybe GitHub Copilot is that good already.
- Taniwha 4y agoI think they are talking about the later stages of boot strapping 'stage2' where they are writing a more functional, but still small, C compiler in a C subset that can be compiled by this one
- tralarpa 4y ago> typing non-stop for 24 hours at something like 100 characters per minute Not only that. It would be typing at that speed without testing anything. In assembly. Haha. In reality what would happen is that you would type 24 hours (not in one day, I assume) and then spend the next days finding the places where you wrote R5 instead of R4. And, of course, without losing any time on refactoring already written code (changing order of parameters, finding a better name for a function, etc.)
- arinlen 4y ago> "Minimal" being almost 5KLOC, sheesh. 5kloc of assembly code, which roughly correspond to opcodes. That's quite small. It's actually 4399 loc, including blank lines and a significant number of comment lines. Quite impressive. There are JSON parsers that require way more code just to handle the basics of parsing.
- flohofwoe 4y ago5kloc isn't really all that much code, especially in assembly.
- jbverschoor 4y agoIt's a compiler wth. 5k is nothing. If you strip out the comments, the constants, the labels and some other cruft, you're left with 2450 instructions. That should be well under 1000 lines in other languages.