View Full Version : best language for an OS?

11-04-2004, 09:37 PM
Hello, I don't have much to do, and I want to know what would be the best language to use to make an OS?

Roy Sinclair
11-04-2004, 10:12 PM

11-04-2004, 10:24 PM
Well, some things related to the OS (the OS loader, for instance) must be either written in assembly or machine code (which may be generated by a program written in any language, though). Almost all operative system kernels are written in C. Not assembly (too long development procedure), not C++ (too bad performance) and certainly not Java, Pascal, Objective C, D, LISP, ML, Visual Basic, SmallTalk or whichever - they are written in C. However, the kernel itself can be very basic, only handling security, access rights, processes and threads, and I/O at the lowest. You can of course move much more into the kernel if you wish. On top of the kernel you build an application level system. Here you have all various kinds of interfaces and core facilities (UI, GUI, memory handling, application handling, networking, I/O interfacing etc.), and here a memory managed language might be better.

11-04-2004, 10:34 PM
So C would be the best?

11-04-2004, 10:37 PM
yes C would be the best, but do you have time to write a OS?
Windows XP is written in combination of C and C++ (I think)

11-04-2004, 10:42 PM
Thanks every one!
btw, I have too much time on my hands...

11-04-2004, 10:48 PM
glad you have, i'm bogged down with GCSE Coursework!

11-04-2004, 11:08 PM
I just have one last question, how would I make it bootable?

11-09-2004, 04:49 PM
that im not sure about, but you would need some implementation of boot.ini or something like that. Anyhow, it would have to be a pile of code to make it bootable....

11-09-2004, 05:03 PM
you would need to write instructions to load your os in the boot sector, may be worth seeing how to setup a duel boot the way linux does
Try this

11-10-2004, 01:30 AM
You must realise this won't be a walk in the park. I made my own, extremely basic, OS.. Well, you can probably take the operating part out of it's name lol, it was just a black screen really. and getting that to work required much bashing of my head on the desk for a few months.

I would suggest reading, reading, and lots more reading before you decide to implement your idea. And don't think you'll be writing the next windows within 20 years, you'll find that out pretty quickly..

I think the best advice I've seen given out to people who ask this question is- "If you don't know already."

A bit cryptic, but you can see the point it makes. An OS is a massive task, if you knew what you were doing you wouldn't be asking the question.. If you are ready to move onto this sorta thing you'd already know much of what you need to do, or at the very least where to find the information yourself.

I'm not saying don't try, just saying, don't get your hopes up too high and be pleased with whatever ground you make on a project like this.

11-10-2004, 02:06 AM
I think the best advice I've seen given out to people who ask this question is- "If you don't know already."

would you say this applies to 3d graphics engines aswell, cause i want to get into game programming nd ive done a fair but but im not sure if its best to concentrate on coding an engine or coding for an already existing engine such as renderware, crystal space etc

11-10-2004, 02:23 AM
Well I would not say that myself. An OS can be as simple or as complex as you want but it's always going to be more complex than a game engine as I see it.

You can write a functioning game engine in less than 100 lines of code. It won't do much. Maybe just display a texture on the screen if that. But it can be done.

I think writing a game engine, especially a 3d one, is a great project (having been working on my first good one for most of this year). The key to a good start with a game engine is a plan, and sticking to that plan. Avoid feature creep when you are just starting out, and don't expect to be making anything spectacular very soon. I find that with a game engine, you have more fun because you always see results on the screen after the main kernel is done. And you can knock a kernel out in a few days if you know what you're doing, from then on it's just adding features like you would plugins.. I suggest C++ for this very reason, classes. If you go for an object oriented design on an engine you can just add and remove different features in a snap. Generally I do all my feature design in a new project with a console window printing out the data that it's handling untill I am satisfied it's working and then I just clean up the code and copy and paste it into my engine.

You do get headaches, but they aren't nearly as bad as if you are doing low level stuff as you would for an OS. I would recommend starting with a game engine, if you have already beaten Hello World.

11-10-2004, 02:30 AM
It's hard enough to code for an existing engine. To write one (at least if you want it to be competitive...), you really need to understand what you are doing. Those are severely optimised to take advantage of not only the APIs at hand (OpenGL, DirectX etc.) but also often fine tuned for certain GPUs and CPUs. You need as much of a realisation of how the hardware and physical interactions work as you need programming skills. An OS is different. In many areas, the OS does not have as many critical performance and optimisation issues. On the other hand, the OS can't make compromises. You can't reasonably sacrifice graphics handling to improve memory handling. Some programs will want to do one, some the other, some a little of both. You can't reasonably sacrifice a good process handling and multitasking for optimising I/O. An OS designer may have to make four areas small bottle necks to avoid a single huge bottle neck. Or sacrifice the single feature for the benfit of the four others, thus effectively making the OS unsuited for doing that type of tasks. OSes are typically optimised for being generic. That means that you have to weigh carefully what optimisations you do as to prevent being too unoptimised in other areas.

11-10-2004, 02:41 AM
Well it's only hard if you are going to be competetive like you said. I know that from experience. You are constantly optimizing for a platform of choice (in my case it's ATI because they give me heaps of resources and discounts on cards as a developer and Windows XP because that's my system so I know it works best on it. But really, as an API it'll work on any Win32 system). But I think that such an engine here isn't an issue, being realistic I don't think that Stowelly could produce or even comprehend an engine like that of Doom III, I doubt many of us here could, Carmack is a genius.. We are talking about a much smaller engine that has lots of memory leaks and runs the same on pretty much any card and of course, OpenGL... Like you'd use DirectX :rolleyes: lol.. I'm sure eventuall Stowelly would get into extensions and it'd become specific to a series of cards if he wanted to take it further and make a good little opensource engine out of it. But you'll have a few thousand builds of a couple of engines before you make something decent.

And as for GPUs and CPUs, the former is the real worry for the developers these days. Anything over 1Ghz generally is more than sufficient for a game engine. It's the GPU that does all the hard work really. But soon that'll be a thing of the past as well..

[OT] Did you know that in longhorn they're planning to sync redrawing of windows with the refresh rate of your screen? Flicker free drawing, yay! :D

11-10-2004, 05:16 AM
Well, it depends. On an system with a good SIMD enhancement, such as the AIM* AltiVec or the marvellous products out of SGI, not to speak of the Toshiba-IBM-Sony massively parallel systems, you'd actually want to move a lot of the computations to the CPU instead of letting the much less efficient GPU handle it. There is a reason why the G3 Mac lags so much behind lower speed G4 (not to speak of higher speed G5) in the gaming scene - the Mac games use the GPU less and the CPU more, since Altivec is really a much more efficient system, hand tweaked for performance in each CPU core.

* Apple-IBM-Motorola

As for Longhorn - it's going to be DirectDraw/Direct3D powered, instead of using the old 2D bitmapped rendering system of today. It'll use the graphics card, in difference from current Windows versions.

11-10-2004, 05:54 AM
Yeah, well it's a lot of work to reroute a lot of computation through the cpu instead of the gpu. I try to do a lot of my calculations without having to go into the gl api. Like I track all my projections and calculate them myself with my camera classes I've written. Instead of using your standard gl matrices and such and just tell it to use mine. It's a bit quicker I've found, if you are willing to put the work in.

But with things like shaders, frag apps and stuff coming into play, that is where the gpu will really fall over itself because they are in the card memory and executed there.. if those could be moved to the cpu and streamed into the gpu it'd be better.

I never knew they were using dd/d3d for longhorn. That's excellent. Even greater possibilities. Perhaps some decent 3d shells might be released. At the very least it'll be smoother aesthetically. But are they making a new api based on dd/d3d, sort of a gdi/dd/d3d hybrid?

11-10-2004, 12:47 PM
I never knew they were using dd/d3d for longhorn. That's excellent. Even greater possibilities. Perhaps some decent 3d shells might be released. At the very least it'll be smoother aesthetically. But are they making a new api based on dd/d3d, sort of a gdi/dd/d3d hybrid?Well, as I understand it they are running everything on top of DirectX just like Apple are running everything on top of or inside QuartzExtreme (Quartz3D is integral OpenGL support). Apple are running Quartz2D, Quartz3D, OpenGL and Quicktime on top of Quartz Compositor - Microsoft will similarly be running Win32 and WinFX on top of GDI+ and GDI32 rendering through DirectX.

11-10-2004, 10:47 PM
Very interesting. I'll have to go hunting down some docs on this once I clear my workload, if I can clear my workload lol.

Probably should stop here seeing as this thread has already gone OT a while ago.