CompilerDev?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
User avatar
Geri
Member
Member
Posts: 442
Joined: Sun Jul 14, 2013 6:01 pm

Re: CompilerDev?

Post 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.
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: CompilerDev?

Post 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).
User avatar
Geri
Member
Member
Posts: 442
Joined: Sun Jul 14, 2013 6:01 pm

Re: CompilerDev?

Post 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).
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: CompilerDev?

Post 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.
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: CompilerDev?

Post 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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: CompilerDev?

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
seuti
Member
Member
Posts: 74
Joined: Tue Aug 19, 2014 1:20 pm

Re: CompilerDev?

Post 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.
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: CompilerDev?

Post 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
no92
Member
Member
Posts: 307
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: CompilerDev?

Post 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.
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: CompilerDev?

Post by iansjack »

I certainly find the idea that "little theory is required for OS development" a rather surprising one.
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: CompilerDev?

Post 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.
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: CompilerDev?

Post 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.
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: CompilerDev?

Post 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".
Post Reply