Page 2 of 2
Re: Advice on OS Language please...
Posted: Wed Mar 11, 2009 10:12 am
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.
Re: Advice on OS Language please...
Posted: Wed Mar 11, 2009 12:54 pm
by magicstuff
ok i see.
Basicly, its easier just to use asm and C++?
Re: Advice on OS Language please...
Posted: Wed Mar 11, 2009 1:55 pm
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.
Re: Advice on OS Language please...
Posted: Wed Mar 11, 2009 2:53 pm
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
Re: Advice on OS Language please...
Posted: Fri Mar 13, 2009 12:54 am
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.
Re: Advice on OS Language please...
Posted: Fri Mar 13, 2009 4:47 am
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.
Re: Advice on OS Language please...
Posted: Fri Mar 13, 2009 6:04 am
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...
Re: Advice on OS Language please...
Posted: Fri Mar 13, 2009 6:06 am
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.
Re: Advice on OS Language please...
Posted: Fri Mar 13, 2009 6:27 am
by Solar
I see, you understand my pain.