3 ms·
C has a large advantage: you can write a compiler in machine language (not assembly, raw machine language) in a week. Not a good compiler: it will produce horri
by bluGill 9y ago
C has a large advantage: you can write a compiler in machine language (not assembly, raw machine language) in a week. Not a good compiler: it will produce horrid, unoptimized code. You just need enough to build a good C compiler. From there you can build a c++ compiler, which in turn can build the C++ compiler you want.
Every time you add a new language feature you increase them time to write your bootstrapping compiler. Garbage collection means you will spend a few more months building a garbage collector. (remember we are writing in machine language so most of the abstractions you are used to dealing with - even in assembly - are missing. Thus complexity is growing exponentially)
- stepik777 9y ago> large advantage How is this a large advantage? When was the last time someone actually did this?
- qznc 9y agoIn my experience, a new toy c compiler pops up roughly once a year. https://github.com/Wilfred/babyc https://github.com/Wilfred/babyc http://www.sigbus.info/how-i-wrote-a-self-hosting-c-compiler-in-40-days.html http://www.sigbus.info/how-i-wrote-a-self-hosting-c-compiler... http://zserge.com/blog/cucu-part1.html http://zserge.com/blog/cucu-part1.html https://c9x.me/qcc/ https://c9x.me/qcc/ https://github.com/alexfru/SmallerC https://github.com/alexfru/SmallerC
- kelnos 9y agoSure, and most people do this as an exercise, whether it's to learn how to write a compiler, or to see how small they can make the compiler, or something like that. No one does it because they really have a strong practical need to.
- pjmlp 9y agoThat so called advantage is how Niklaus Wirth did all his compilers, and many other language designers, it is not unique to C.
- bluGill 9y agoI didn't mean to imply it was unique to C, though in hindsight I did. This can be done in many languages. I believe that Niklaus Wirth created his first self hosting implementation in a small subset of the language and expanded from there. Anyone thinking about doing this for a non-trivial language should consider following that example.