Geri wrote:
so basically it depends on the platform, how hard is to write an operating system and a compiler for it, but i would say that writing the c compiler is harder in every case. in some cases, extremely harder.
If we don't try to make a great optimizing compiler and are OK with gcc -O0 level of performance, then I'd say a non optimizing ANSI C (or near ANSI C) compiler is easier and faster to implement than an OS. In the case of C, the language is standardized and quite compact. Something simpler than C or a smaller subset of C could be constructed as well in a fraction of time. I haven't yet implemented my OS and I'm not sure if I ever will. I have many parts laying around (MM, FAT FS, windowing manager, drivers, loaders, etc) and with some work a simple OS could be made out of these. But I expect that my Smaller C compiler is going to be smaller (source-wise) than the kind of simple OS I could build from the OS parts that I have. Right now the compiler appears to be at ~15 KLOC and the library is at ~8 KLOC. But there's no assembler or better preprocessor, which I estimate to take another 6-8 KLOC. So, ~30 KLOCs for a basic toolchain. At the same time the abridged version of MINIX 1.0 (printed in the book) had ~12 KLOC of code. There was no graphics or audio, no UI of any kind besides the simple text console, there was no network, no virtual memory, etc etc. Also, the abridged source didn't include tools. If you add up all those other things, which are essential part of an OS today, plus tools, you'll get more than double than those 12 KLOCs of the abridged MINIX 1.0 version. And it could be improved and extended indefinitely.
Only a very tiny OS, likely an almost unusable one, would be smaller than a basic toolchain (C compiler, assembler, linker).