Page 8 of 8
Re: CompilerDev?
Posted: Sun Jan 18, 2015 10:48 am
by Geri
now i am support the theory that calim that its much harder to write a compiler. (i am in the middle of both problem for my platform)
maybe an os seems to be harder to write, especially on x86/arm, when there is a lot of special nonsense memory map locations, braindead interrupt vectors, dma, multiple cpu modes, but this things must be only written once, and after a few days of pain, they are working, and done.
on more simplyer systems, these problems arent even exist, only the functionality must be implemented.
for example, when somebody implementing malloc/free, it maybe seems a little complex, but after a few hours, he is basically alreday done, and after a little debugging, it works well, and thats it.
a compiler (c compiler) is much harder, however, its simplyer, if the people write it on a platform with registers, hardware stack, or at least some kind of segmentation. if not, then it becomes a very horroristic saga, becouse very special design needed to make the output binary work with normal speeds.
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.
Re: CompilerDev?
Posted: Sun Jan 18, 2015 1:42 pm
by alexfru
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).
Re: CompilerDev?
Posted: Sun Jan 18, 2015 2:47 pm
by Geri
number of lines are not necessary define the complexity. my game engine is 35k line (not counting loaders).
however, it was easyer than the compiler. my c compiler is now almost 14k line. i think it will be around 20k, when i finish it (~c99 +/- a few thing).
i cant give such precise numbers about my os, becouse its just throwed apart to separate files, its not a cohesive software now, but i would say it will beethwen 5-10k line, if i dont count the font rendering (which has ascii/utf8 fonts hardcoded inside).
Re: CompilerDev?
Posted: Sun Jan 18, 2015 5:00 pm
by iansjack
A compiler is a much easier task than an OS. You only have to work at the machine level to generate the instructions themselves and don't have to worry about all the hardware details of the system other than the processor itself. An OS has to do a huge amount of work to determine what hardware is present, configure that hardware, and then manage it for the user programs. It also performs a far wider range of duties than a compiler, which is focussed on doing one very specific task.
There is no contest as far as I am concerned - both are difficult, but one is a project that will occupy months, the other one that will take years and, in truth, never be finished.
Re: CompilerDev?
Posted: Sun Jan 18, 2015 11:46 pm
by Muazzam
iansjack wrote:A compiler is a much easier task than an OS. You only have to work at the machine level to generate the instructions themselves and don't have to worry about all the hardware details of the system other than the processor itself. An OS has to do a huge amount of work to determine what hardware is present, configure that hardware, and then manage it for the user programs. It also performs a far wider range of duties than a compiler, which is focussed on doing one very specific task.
There is no contest as far as I am concerned - both are difficult, but one is a project that will occupy months, the other one that will take years and, in truth, never be finished.
I agreed that OS Development is more time consuming task with much more lines of code. But, I think little theory is required for OS Development. For me, writing an OS is much easier than compiler. Writing a compiler is nearly impossible for me at this stage.
Re: CompilerDev?
Posted: Mon Jan 19, 2015 12:43 am
by Brendan
Hi,
muazzam wrote:iansjack wrote:A compiler is a much easier task than an OS. You only have to work at the machine level to generate the instructions themselves and don't have to worry about all the hardware details of the system other than the processor itself. An OS has to do a huge amount of work to determine what hardware is present, configure that hardware, and then manage it for the user programs. It also performs a far wider range of duties than a compiler, which is focussed on doing one very specific task.
There is no contest as far as I am concerned - both are difficult, but one is a project that will occupy months, the other one that will take years and, in truth, never be finished.
I agreed that OS Development is more time consuming task with much more lines of code. But, I think little theory is required for OS Development. For me, writing an OS is much easier than compiler. Writing a compiler is nearly impossible for me at this stage.
OSs range in complexity from "extremely simple" all the way up to "extremely complicated"; and compilers range in complexity from "extremely simple" all the way up to "extremely complicated".
The simplest possible compiler I can think of is something that takes pre-tokenised input for a stack machine and emits unoptimised output for a similar stack machine (e.g. where "compiling" is pure translation). The simplest OS I can think of is something like DOS but without a file system (where the OS does almost nothing and applications use the BIOS for almost everything). I don't know which of these would be easier.
The hardest compiler may include one or more OSs in its run-time, and the hardest OS may include one or more compilers. I don't know which of these would be easier.
Basically what I'm saying is that I doubt there's a proven method of accurately comparing subjective ranges.
Cheers,
Brendan
Re: CompilerDev?
Posted: Mon Jan 19, 2015 2:58 am
by seuti
Geri wrote:number of lines are not necessary define the complexity. my game engine is 35k line (not counting loaders).
however, it was easyer than the compiler. my c compiler is now almost 14k line. i think it will be around 20k, when i finish it (~c99 +/- a few thing).
i cant give such precise numbers about my os, becouse its just throwed apart to separate files, its not a cohesive software now, but i would say it will beethwen 5-10k line, if i dont count the font rendering (which has ascii/utf8 fonts hardcoded inside).
Maybe the best measurement of difficulty is how often you have to Google a question.
I've been working on automation tools for an online game, it's currently around 25,000 lines of code and it has been pretty simple while my OS is only around 2000 lines of code and has been quite tough.
Re: CompilerDev?
Posted: Mon Jan 19, 2015 5:39 am
by Muazzam
Brendan wrote:
The hardest compiler may include one or more OSs in its run-time, and the hardest OS may include one or more compilers.
Right
Re: CompilerDev?
Posted: Mon Jan 19, 2015 5:53 am
by no92
muazzam wrote:I agreed that OS Development is more time consuming task with much more lines of code. But, I think little theory is required for OS Development. For me, writing an OS is much easier than compiler. Writing a compiler is nearly impossible for me at this stage.
That's
very subjective. For me, it's the other way around. Wrinting a compiler feels so easy for me, while actual OSdeving a hard task.
Re: CompilerDev?
Posted: Mon Jan 19, 2015 6:24 am
by iansjack
I certainly find the idea that "little theory is required for OS development" a rather surprising one.
Re: CompilerDev?
Posted: Mon Jan 19, 2015 7:15 am
by Muazzam
iansjack wrote:I certainly find the idea that "little theory is required for OS development" a rather surprising one.
I said that little theory is required "as compared to" compiler. Also, little theory is required to develop OS like DOS.
Re: CompilerDev?
Posted: Mon Jan 19, 2015 9:17 am
by iansjack
I said that little theory is required "as compared to" compiler.
Clearly I need to brush up on my reading skills as I failed to notice the words "as compared to" in your comment. Worse still, I still can't see them.
Re: CompilerDev?
Posted: Mon Jan 19, 2015 10:07 am
by Muazzam
iansjack wrote:Clearly I need to brush up on my reading skills as I failed to notice the words "as compared to" in your comment. Worse still, I still can't see them.
It was my mistake that I did not wrote "as compared to".