Click here to Skip to main content
15,886,805 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I want to be able to write a simple c compiler or a python interpreter by I have no clue how. I do this because one day i want to write my own OS and I hear that if i start writing my OS on another OS i will need to make a custom compiler so basically my OS can run without the other OS- something called a cross-compiler. Correct me if I've said anything wrong by the way.
I've also heard that writing an OS is the hardest of all programming tasks and since compiler creation is also quite difficult I know I'll have no chance of designing an os if i cna't write a compiler or interpreter.

I know this is very ambiguous but can someone point me in the right direction to actually learning HOW to make a C compiler of python interpreter and not necessarily point me in a direction that'll only teach me how compilers work.
Posted
Comments
Sergey Alexandrovich Kryukov 16-Sep-13 14:34pm    
What is that supposed to mean: "C compiler of python interpreter"?
—SA
Kenny_007 16-Sep-13 14:53pm    
meant to be an or
Sergey Alexandrovich Kryukov 16-Sep-13 15:31pm    
Got it. You may want to fix it by clicking at Improve question.
—SA

There are some comments to this post[^] that will point you in the right direction - specifically a couple of good books on compiler design.

Designing an Operating System and designing a Compiler are two very different things and not at all related in the way that you suggest ... it's not about being a "difficult task" but you do need to understand how each works
 
Share this answer
 
Comments
CPallini 16-Sep-13 15:56pm    
5.
ridoy 16-Sep-13 17:11pm    
5ed!
This doesn't do C, or Python - it works with a simple demo language it calls Kaleidoscope - but it is a tutorial on writing a compiler from scratch: http://llvm.org/docs/tutorial/[^]

Be aware - it's a lot of work, and there is no actual reason that you need to write a compiler in order to write an OS: you will need to write libraries that interface to your OS, but a cross compiler can compile the OS and then compile itself to run under the OS when you have the necessary interface libraries written. There is no point in writing a compiler if you don't provide libraries to do match, string handling and so forth - and your OS will determine how the library code interfaces with the user, not the language. Think about .NET and C#: the latter is a language, that is pretty small and compact - the massive part of the work is in .NET which is language independent.
 
Share this answer
 
Comments
CPallini 16-Sep-13 15:55pm    
5.
ridoy 16-Sep-13 17:11pm    
good explanation,5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900