What's the best language to use for OS Dev?
-
Tim
Re:What's the best language to use for OS Dev?
I don't think you can come up with one 'best' language, but C has proven itself most often with current operating systems.
-
pskyboy
Re:What's the best language to use for OS Dev?
Yep, this is a question that seems to rear its head every so often. Its not a matter of what is the best in the sense that do i get a 3Ghz processor or 2.5Ghz processor. Its more about what tool is right for the job. I know this point gets laboured but im labouring it again. Anyway to give you an idea heres a quick breakdown.
ASM (only) - this is good for smallish kernels where size or execution speed are important. Some people will probably argue you can write a large comprehensive kernel in it but lets see them go back and add to it a month after they have finished a bit.
C - This is the standard at the moment and as Tim said has provens its self for OS development. Linux's kernel is written in C along with some of windows. Generally speaking this is the easiest language to get up and start developing in.
C++ - Once the primary disadvantages of disabling libraries creating new delete functions etc have been got over there is very little left to stop C++ being the main winner. I say this because the slight speed decrease over C is becoming much less of an issue with modern processors and C++ gives you the advantage of being able to structure your kernel better and make it easier to maintain (at least in my opinon). This is obviously being taken into account by microsoft as some parts of teh newer OS's are written in C++.
Pascal - As for pascal i have only ever done a limited amount of pascal and definately no low level stuff so can't really comment. Personally i am not so keen on pascals syntax and think it is harder to read then C but thats only my opinion.
Hope this helps
Peter
ASM (only) - this is good for smallish kernels where size or execution speed are important. Some people will probably argue you can write a large comprehensive kernel in it but lets see them go back and add to it a month after they have finished a bit.
C - This is the standard at the moment and as Tim said has provens its self for OS development. Linux's kernel is written in C along with some of windows. Generally speaking this is the easiest language to get up and start developing in.
C++ - Once the primary disadvantages of disabling libraries creating new delete functions etc have been got over there is very little left to stop C++ being the main winner. I say this because the slight speed decrease over C is becoming much less of an issue with modern processors and C++ gives you the advantage of being able to structure your kernel better and make it easier to maintain (at least in my opinon). This is obviously being taken into account by microsoft as some parts of teh newer OS's are written in C++.
Pascal - As for pascal i have only ever done a limited amount of pascal and definately no low level stuff so can't really comment. Personally i am not so keen on pascals syntax and think it is harder to read then C but thats only my opinion.
Hope this helps
Peter
-
Tim
Re:What's the best language to use for OS Dev?
I think the idea that code written in C++ is slower than that written is C is a myth. Object-orientated C uses the same techniques and mechanisms as object-orientated C++, so there's no apparent slowdown factor there. And procedural C++ is more-or-less the same as C anyway.
-
_mark
Re:What's the best language to use for OS Dev?
Heavy inheritance will slow things down a bit because of the vtable. By like many have said, on a modern processor it is less of an issue. There is a portability issue with C++, as the ansii standard only says what it has to do, now how - so many compilers do things very different and you cannot trust the format of the vtable.
I have worked with object oriented design and analysis for a very long time. It is how I put bread on the table. But for some time now, I have ALMOST started to favor traditional library development as it seems to lead to less problems in large engineering designs. But don't tell my clients I said that....
anyway - most of what I am doing is C (with an pseudo OO design aprouch). This is what works for me.
_mark()
I have worked with object oriented design and analysis for a very long time. It is how I put bread on the table. But for some time now, I have ALMOST started to favor traditional library development as it seems to lead to less problems in large engineering designs. But don't tell my clients I said that....
anyway - most of what I am doing is C (with an pseudo OO design aprouch). This is what works for me.
_mark()
-
Tim
Re:What's the best language to use for OS Dev?
That's the point I'm getting at -- object-orientated C will (should) have some kind of vtable contruct as well, albeit built by the author and not the compiler -- so it's almost the same thing.
Remember that object orientation is just another way of designing software, and not something you get from some language keywords.
Remember that object orientation is just another way of designing software, and not something you get from some language keywords.
-
_mark
Re:What's the best language to use for OS Dev?
What I was getting at, and I guess I did not say it outright was, there are more oppertunities for a programmer to abuse features of a C++ compiler leading to inefficant exe code. Most of the time the abuse would not even be noticed. And - Granted, the same abuse can be done with just about any C compiler. But the difference is that most C programmers that abuse language features know what they are doing. It is a chioce, not something the compiler whipped up for him - like a copy constructor. With C++ many things lurk waiting to nab you in the butt. With C it is straight forward and simple, any abuse is usually intentional.
But I have to agree (once again); with todays computers it really does not matter. This is like the old unix vs, windows religious war. "Unix is better - it is fater." Well sure it might be. But I cannot tell and I really don't care much. Both Windows and Linux scream on my P4. In fact even running linux is VMWARE ontop of Windows is a plesant experience.
Where these things do make a difference though is when writting a bootloader....
<_mark() is ducking to avoid whatever Tim throws at him...>
But I have to agree (once again); with todays computers it really does not matter. This is like the old unix vs, windows religious war. "Unix is better - it is fater." Well sure it might be. But I cannot tell and I really don't care much. Both Windows and Linux scream on my P4. In fact even running linux is VMWARE ontop of Windows is a plesant experience.
Where these things do make a difference though is when writting a bootloader....
<_mark() is ducking to avoid whatever Tim throws at him...>
-
distantvoices
- Member

- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:What's the best language to use for OS Dev?
*is dribbling something to throw ... *
of course c is cool, once you got used to all those tricky niftynesses that come along with this language, like pointers, structures, pointers to structures et cetera...
as for c++: yo, there are many pitfalls: inheritance, multiple inheritance ... function over riding (does this make sense in an operating system?) ... and all the tables of pointer to functions (vtables?) that are needed to keep a c++ kernel running.
I'll stay with c and asm for os development.
of course c is cool, once you got used to all those tricky niftynesses that come along with this language, like pointers, structures, pointers to structures et cetera...
as for c++: yo, there are many pitfalls: inheritance, multiple inheritance ... function over riding (does this make sense in an operating system?) ... and all the tables of pointer to functions (vtables?) that are needed to keep a c++ kernel running.
I'll stay with c and asm for os development.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
-
pskyboy
Re:What's the best language to use for OS Dev?
It's all a matter of coding pratice at the end of the day. I am currently using C++ for my kernel (as you might of guessed
) . Because of the performance reasons and general messiness of Multiple inheritance i am keeping well away from it. I am purely using C++ because i prefer the readability and structuring over C. I know i coudl use OO based C but having never used OO c i decided to go straight for C++ as i was used to it.
Also when the day comes (if ever) i plan to port my code to Pegasus which will be similar to C++ in structure so will make it easier for me to convert it.
Peter
Also when the day comes (if ever) i plan to port my code to Pegasus which will be similar to C++ in structure so will make it easier for me to convert it.
Peter
-
Tim
Re:What's the best language to use for OS Dev?
_mark(), you have a good point there. With C++, it's easy to accidentally add a lot of bloat with the stuff the compiler gives for you. At least with C you'd have to manually add that stuff for yourself. It's possible to write C++ code that minimizes the bloat, but you have to pay special attention to it.