Sign in to follow this  

Language(s) used to write operating sytems

This topic is 4663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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!

Share this post


Link to post
Share on other sites

This topic is 4663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this