Language(s) used to write operating sytems

Started by
6 comments, last by load_bitmap_file 19 years, 1 month ago
Couple quick questions that hopefully somebody knows about. If this should be in the lounge, please move it! This concerns the kernel of the OS mainly. Essentially, what languages are the major modern and 'ancient' OSs written in? Is it ASM and C/C++, or just ASM? What language(s) are used to write the kernels of the followingg operating systems: 1) Windows (2000,XP,Longhorn) 2) Windows (DOS,95,98,ME) 3) Linux (mainly new) 4) Mac OS (mainly new) On a less important note, I am assuming that most of the non-kernel and non-hardware-oriented components are writtin in C/C++/C#/etc... Is this correct? Thanks for the help!
Advertisement
As far as I know, all of the OS's you listed are written in C (not C++) with a little assmbly code.
Even the older operating systems, like all the DOS versions?
Windows is written in C and ASM. OS's are usually written, in large part, in C rather than C++. Sometimes you'll see some hobby OS's written in C++ (google NachOS); however, I've yet to see a big time OS written in the language. I've also seen some hobby OS's written in PASCAL, though I'm not sure why anyone would be so masochistic as to do such a thing :-p (just kidding).

Any OS you write will not be void of ASM. If nothing else but for the bootstrapping (loading the OS and switching to protected mode at minimum) and memory management stuff (I've yet to see one written in C, but that doesn't mean no one's done it).

Some of the OS's use tons of ASM whereas others use very little. It kinda depends on the developers and how time-sensitive the application is I guess.

I'm not necessarily an expert on the topic - I've written a couple of kernels that said "Hello World" and one got so far as to actually accept text input. Suffice it to say, though, that it took me 6 months of developmental work during College to get to that point.
Quote:Original post by Nietsnie
Even the older operating systems, like all the DOS versions?
I don't know for sure, but I'd be surprised if it was anything other than C and assembly.
You only really need assembly for doing really low level stuff. Its more tourble than it's worth to do anything else with assembly.

You can actually download the linux kernel source if you're interested.
I'd be very suprised if DOS were written in anything higher than macro assembly.

Newer OS's are written primarily in C. It's also not unusual to see C++ being used but usually in a very minimal "extended C" fashion rather than a true C++ design.

A real C++ design is certainly doable but has a couple problems. There's more bootstrapping required to be able to handle things like constructors in global variables, handling exceptions is trickier, etc. It's also a lot easier to shoot yourself in the foot with an innocent-seeming expression that compiles out to a massive routine with lots of unnecessary allocation, copying, etc. Basically if you're in the kernel you need to be much more aware of what sort of code the compiler is going to generate.

Actually David Cutler (the primary architect of Windows NT) has said that the one of the biggest technical mistakes they made when writing VMS (an older OS from Digital) was that it wasn't written in a high-level language.
-Mike
Even a most of the grub bootstrap is written in C (and if you needed low-level anywhere...).

Although generally C is used, there is nothing to stop you using most [sensible] languages - you could write a hardware interface layer in asm/C and then use another language on top of that (FORTRAN, COBOL, BASIC - anything that compiles to a native image). Basically the interface layer would be responsible for the bare minimum (twiddling low-level bits, possibly setting up dma etc).

There are in fact few reasons why you couldn't bootstrap something like the mono runtime and have 99.99% of an OS in a .NET language; there would be a few issues to resolve, but nothing unsurmountable. You'd have to be careful what you called until you were fully setup too. However the world is your oyster!
This list seems to suggest Windows is written in C++

This topic is closed to new replies.

Advertisement