6 ms·
Selfie – Tiny self-compiling C compiler, RISC-V emulator and hypervisor
- dang 7y agoA thread from 2017: https://news.ycombinator.com/item?id=13778353 https://news.ycombinator.com/item?id=13778353 (Such links are for the curious. Reposts are ok after about a year: https://news.ycombinator.com/newsfaq.html https://news.ycombinator.com/newsfaq.html)
- Koshkin 7y agoI think Oberon would be a better candidate for this than C. You could get a tiny and extremely fast compiler for a full-featured programming language.
- giancarlostoro 7y agoI'm looking into self-hosting compilers, is there a good link for Oberons code that achieves this? Or you just are mentioning that Oberon would probably be able to if one were implemented?
- kryptiskt 7y agoOberon is implemented in itself: http://www.projectoberon.com http://www.projectoberon.com The implementation includes the hardware too. Taken together, the system including single-tasking OS, windowing system and Oberon takes about 9000 lines of code.
- alexisread 7y agoEven better, A2/bluebottle is multithreaded with a ZUI and runs faster than Linux: https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/147091/eth-26082-02.pdf https://www.research-collection.ethz.ch/bitstream/handle/20.... Also, following on from A2, Composita introduces a component architecture to allow managed memory without GC, and contextless switches (IMHO better than Rust): http://concurrency.ch/Content/publications/Blaeser_Component_Operating_System_PLOS_2007.pdf http://concurrency.ch/Content/publications/Blaeser_Component...
- lboasso 7y agoYou might be interested in oberonc [0] an oberon-07 self-hosting compiler for the JVM. [0] https://github.com/lboasso/oberonc https://github.com/lboasso/oberonc
- southpawflo 7y agoat the bottom of the linked page the author explicitly references oberon as a source of inspiration for this project
- sitkack 7y agoFunny because Selfie reminds me of a maximally compact version of http://www.projectoberon.com/ http://www.projectoberon.com/
- z29LiTp5qUC30n 7y agoYou can get a proper C compiler in 2KLOC [or under 5Kloc of assembly https://github.com/oriansj/mescc-tools-seed/blob/master/x86/cc_x86.M1 https://github.com/oriansj/mescc-tools-seed/blob/master/x86/... | https://github.com/oriansj/mescc-tools-seed/blob/master/x86/NASM/cc_x86.S https://github.com/oriansj/mescc-tools-seed/blob/master/x86/...] Covering things like gotos, inline assembly, structs, unions, arrays and dozens of types and primitives. Oberon doesn't provide much advantage over that.
- deleted 7y ago[deleted]
- triptych 7y agoWish there was something like this for WebAssembly
- coliveira 7y agoIn particular, the code for this compiler doesn't use structs. It only works with offsets to memory blocks.
- msla 7y agoThe C subset it compiles is called C* but it appears unrelated to the language of the same name created for the Connection Machine hardware: https://en.wikipedia.org/wiki/C* https://en.wikipedia.org/wiki/C*
- topoyiyo 7y agoAt least it's not mosdef C =P
- microcolonel 7y agoStill doesn't shine a candle to Holy C.
- chrismcdonald 7y agoSuch a great post- https://www.completeconnection.ca/trending-mobile-phone-apps/ https://www.completeconnection.ca/trending-mobile-phone-apps...
- boomskats 7y agoSelfie, hypster, mipster, monster... these names are great.
- rcgorton 7y agoWhat drivel. Make an artificial language which nobody uses, with a target architecture=X. Post it pretending that it is relevant. I Call BS on OP
- klyrs 7y agoIt's a teaching aid for students. It's relevant.
- christophkirsch 7y agoThe language is a strict subset of C modulo some small semantical differences that are relevant for bootstrapping, see https://github.com/cksystemsteaching/selfie/blob/master/semantics.md https://github.com/cksystemsteaching/selfie/blob/master/sema...
- pulse7 7y agoIt's not artificial, it is a C subset.
- amasad 7y agoThis is such a cool educational tool! I got it to run on repl.it https://repl.it/@amasad/selfie https://repl.it/@amasad/selfie
- christophkirsch 7y agoThanks a lot, @amasad I pulled your PR and even plan to use repl.it in the upcoming compiler class.
- jng 7y agoBeautiful, beautiful project. Containing the deepest twists of computation in a single file, and not a single #include. I only missed it including a text editor. Love it!
- CodiePetersen 7y agoNo boolean operators?! That's an odd choice.
- christophkirsch 7y agoWe chose not to include support of Boolean operators and instead ask the students to implement that as part of an assignment. We use a self-grader for that. There is an assignment for bitwise Boolean operators. The assignment for logical Boolean operators with lazy evaluation is work in progress.
- Koshkin 7y agoIt’s a cute little exercise, to implement the three Boolean operations using operations on integers.
- lex0r 7y agoI just looked into the project and the slides are incredible. It would be nice if more professors would put so much effort into creating slides and not just take over the previous one and present them.
- christophkirsch 7y ago@all Thanks a lot for your awesome comments and feedback. Besides compiler, emulator, and hypervisor, there is a symbolic execution engine in selfie that we are working on and would love to get feedback from you. The goal is to teach, eventually, a more formal approach when reasoning about correctness already in undergraduate classes. But the engine is also a research vehicle, especially the bounded model checking part.
- SeekingMeaning 7y agoStudent here, with a question. How does one maintain a 10,000 line source file?
- rurban 7y agoI maintain several such files with emacs. Jump to definition or open it in two windows makes it trivial.