Page 1 of 1

Choosing the right language... pros and cons

Posted: Tue Jul 05, 2005 11:00 pm
by ezanahka
I'd like to hear about your experiences with different languages in OS implementation. I have working templates of asm, C and C++ (no runtime support yet) code and I could start building a kernel on top of any of them. However there are other languages... and I don't know which way to go.

Most write their kernel in C, right? But I don't like C.

C++ would maybe be worth the extra effort but then again building the runtime support... it ain't that much fun and its a distraction from the kernel itself. Although having C++ support in the kernel itself sounds nice enough.

Assembly is nice if I'd like to write a lot of code and spend time worrying about what is and what goes in the hardware registers. :( So its probably not the best choice... not enough abstraction.

Unununium seems to be using Python? Well, I don't like Python so much that I would try to write a kernel with it.

Forth OS? Yes it is simple enough but is it possible to not make "write and forget" code? The produced code has to be maintainable. There is RetroForth 8.0 which boots in Bochs without any trouble and could be extended to an OS but then again does it provide a solid base for a kernel?

Writing my own programming language? A full compiler would be way too much work. Perhaps just a source to NASM translator (some kind of preprocessor)?

I would like to know if any of u guys have ran into serious problems with one of these languages.

Thanks,
Esa

Re: Choosing the right language... pros and cons

Posted: Tue Jul 05, 2005 11:00 pm
by Crazed123
I use Pascal and ASM. Once you've got the RTL working and the assembler parts right, you can pretty much write whatever you want.

Re: Choosing the right language... pros and cons

Posted: Tue Jul 05, 2005 11:00 pm
by carbonBased
I've written OSs in both C and C++ (both, obviously with some assembly language) and I find them both equally well suited.

C is a little lower level, so some consider it faster to get up and running, but if you're comfortable writting some run-time support, then you can get a really nice C++ API in your kernel. Each have their own advantages and disadvantages, so I'm not going to say one's truely better then the other. Depends on what you want. C++ may require more attention to detail to ensure the code is compiled and linked in the most optimized way, but if don't like C, then it might be the better route to go.

As per other languages... I'm still lookin' for someone to write an OS in Eiffel. I plan on eventually doing it, or at the very least, implementing a full OS API set in Eiffel.

Java and .NET are also interesting languages for OSs. All of the above, of course, require quite a lot of run-time support, however, but are possible.

As per writting your own language; nearly all programming languages compile to assembly language and then use an external assembler to create the object files, and an external linker to create the executable. Very rarely will a compiler actually compile directly to machine language/object code.

--Jeff

Re: Choosing the right language... pros and cons

Posted: Tue Jul 05, 2005 11:00 pm
by Legend
Designing your own language would be enough work to keep a team of designers/developers busy on that project alone.

Re: Choosing the right language... pros and cons

Posted: Wed Jul 06, 2005 11:00 pm
by ezanahka
carbonBased wrote: Depends on what you want. C++ may require more attention to detail to ensure the code is compiled and linked in the most optimized way, but if don't like C, then it might be the better route to go.
I decided to use C anyway... less bloat. :)
carbonBased wrote: As per other languages... I'm still lookin' for someone to write an OS in Eiffel. I plan on eventually doing it, or at the very least, implementing a full OS API set in Eiffel.
That would be cool :)
carbonBased wrote: Java and .NET are also interesting languages for OSs. All of the above, of course, require quite a lot of run-time support, however, but are possible.
I've lately also considered Prolog or some other similar logic/declarative language. I'm planning to port some Prolog to my OS anyway sometime in the future.

I'm just wondering how easy/hard it would be to combine WAM (the Warren Abstract Machine behind most modern Prolog implementations) into the kernel. A logic language OS could be fun ;)

- Esa

Re: Choosing the right language... pros and cons

Posted: Wed Jul 06, 2005 11:00 pm
by ezanahka
Legend wrote: Designing your own language would be enough work to keep a team of designers/developers busy on that project alone.
True. However what I was thinking about was a simple Forth to FASM translator. I'm talking about a typed Forth. I've been thinking that typing would make polymorphism possible. I would also like something for templating code / metaprogramming / etc... Nothing too complex but something that should be as extensible and programmable as possible.

- Esa

ps. update -> I scrapped the translator idea and switched to making a kernel by extending RetroForth 8.0. :)

Re: Choosing the right language... pros and cons

Posted: Fri Jul 08, 2005 11:00 pm
by earlz
how would u make a kernel in java or .net

Re: Choosing the right language... pros and cons

Posted: Sat Jul 09, 2005 11:00 pm
by Legend
Basically, your kernel would be one JVM or CLR and everything that you need to get these running, meaning mostly memory and process management. For disc access, you will need to able to write a classloader that loads the classes using only java code (disk driver, file system driver, etc.)

In any case, you'll need a good bit of C, ASM, or whatever your fully compiled language of choice is.