Advice on OS Language please...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
stephenj
Member
Member
Posts: 140
Joined: Wed Jul 23, 2008 1:37 am
Location: Canada

Re: Advice on OS Language please...

Post by stephenj »

Yes, writing a kernel in PHP is possible (The language would need to be augmented slightly). It is just a lot of difficult work that in my opinion isn't worth it. Not to mention that it would kill performance.

It is similar to a Turing Tarpit, just in the opposite direction of the normal case.

The path of least resistance is using assembly, with an optional additional language (such as C, C++, or Pascal). That would be easier than learning how to modify a compiler/interpreter to work with hardware in a limited environment.
magicstuff
Posts: 4
Joined: Wed Mar 11, 2009 1:29 am

Re: Advice on OS Language please...

Post by magicstuff »

ok i see.

Basicly, its easier just to use asm and C++?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Advice on OS Language please...

Post by Solar »

neon wrote:I dont think any general purpose HLL would support I/O ports nativity do to it being dependent on the architecture and platform. (C relies on asm to use port I/O)
Actually, extensions TR18015 and TR18037 added <iohw.h> to the C standard, which wraps port I/O without requiring Assembler.
Every good solution is obvious once you've found it.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Advice on OS Language please...

Post by neon »

Solar wrote:Actually, extensions TR18015 and TR18037 added <iohw.h> to the C standard, which wraps port I/O without requiring Assembler.
Did not know that. I will look it up when I get home. Thanks for the info :)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
AndrewAPrice
Member
Member
Posts: 2306
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Advice on OS Language please...

Post by AndrewAPrice »

I tend to think of languages not as if they are compiled to native code, byte code, or interpreted, but rather if it's a systems language (suitable for having exact control over every byte) or an applications language (focus is on abstraction and rapid development).

I have said it many times before that an OS is not just just the kernel. That is why I favour Microkernels, they move as much as possible in to normal programs (usually called drivers and servers) while keeping as little as possible in the actual "kernel" part. The advantage this has in relation to languages? You can use any language that you can write a standard application in (C++, C#, Java, PHP, Javascript) to write a core server in (VFS, audio manager, window manager - It may not be the best performing server though ;)). There are some exceptions to this rule, for example it might be difficult to write a driver in a language that does not support tightly packed data structures.
My OS is Perception.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Advice on OS Language please...

Post by Combuster »

True, when you can run a HLL program as a server, then you'd have the advantages of having such a language. The problem is to initially get to that point. That's where the difference between f.x. C and PHP lies - you can write kernel and driver code in C the moment you have linux installed, but you will have to do a ton of intermediate steps before you can do the same with PHP.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Advice on OS Language please...

Post by Solar »

Moreover, I'd see it as a significant disadvantage if core components of the OS - microkernel, file system server and network stack, for example - weren't written in one language, but several different ones.

While it might be convenient for the guy who did the writing (because he was able to stick with his most favourite language), it creates a maintenance nightmare, because one of the rules of the industry is, the guy doing the maintenance is never the guy who wrote it the first place...
Every good solution is obvious once you've found it.
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Re: Advice on OS Language please...

Post by ucosty »

Solar wrote:While it might be convenient for the guy who did the writing (because he was able to stick with his most favourite language), it creates a maintenance nightmare, because one of the rules of the industry is, the guy doing the maintenance is never the guy who wrote it the first place...
I believe another rule is you always end up maintaining code written by people who disregard the rule above.
The cake is a lie | rackbits.com
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Advice on OS Language please...

Post by Solar »

:twisted:

I see, you understand my pain. 8)
Every good solution is obvious once you've found it.
Post Reply