I have this idea that I want to write an operating system. I've started to learn C++, but I have a few questions...One is, obviously, am I using the right programming language? I have looked at a few forums on this site, and it seems to be half of the people saying that C++ is good for OS writing, and the other half saying that it's bad. (if whoever answers that question could give a reason, that would be nice) If C++ isn't a good programming language for this project, then what is?
The next question I have is where to start. Clearly, I have to become an expert at programming in whatever language I need first, but then where do I go? I kind of know what a kernel is, but if someone could explain more, that would be nice.
I'll probably come up with more questions later, but that's it for now.

Recommended Answers

All 7 Replies

C is probably a better language than C++. Lots of operating systems have been written using C.

>>The next question I have is where to start.
Here are some google links you should read

So what makes C better than C++ in this case?

I'm not saying you can't do it in c++, but it will bring a lot of baggage (such as stl classes) that you may not want or need. C will be tighter code, smaller code, and often faster code.

You can use minix and modify source code here and there , you will never be able to write a new OS code yourself.

Will I be able to write the whole OS in C or C++, or will there be parts I won't be able to do?

depends. If the file system is going to be all new then you will have to write a cross compiler first that will target the file system.

If you plan to use one of the existing file systems such as that used in *nix or MS-Windows then you can use one of the existing compilers.

I have not written an os, but I would imagine parts of it may need to be in assembly because there are some assembly instructions that have no c counterpart.

Both C and C++ provide for (implementation defined) asm declaration (builtin assembler code) so the formal answer is "Yes, you might do that". Can you - that's a question.

It is better to bootstrap a new system from the scratch in C because the C runtime support is much more simpler than for C++ one (for example, imagine proper stack unwind after C++ exception code). That's why sometimes C called a very high level assembler...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.