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.
Advice on OS Language please...
-
- Posts: 4
- Joined: Wed Mar 11, 2009 1:29 am
Re: Advice on OS Language please...
ok i see.
Basicly, its easier just to use asm and C++?
Basicly, its easier just to use asm and C++?
Re: Advice on OS Language please...
Actually, extensions TR18015 and TR18037 added <iohw.h> to the C standard, which wraps port I/O without requiring Assembler.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)
Every good solution is obvious once you've found it.
Re: Advice on OS Language please...
Did not know that. I will look it up when I get home. Thanks for the infoSolar wrote:Actually, extensions TR18015 and TR18037 added <iohw.h> to the C standard, which wraps port I/O without requiring Assembler.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
- AndrewAPrice
- Member
- Posts: 2306
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: Advice on OS Language please...
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.
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.
- Combuster
- 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...
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...
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...
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.
Re: Advice on OS Language please...
I believe another rule is you always end up maintaining code written by people who disregard the rule above.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...
The cake is a lie | rackbits.com
Re: Advice on OS Language please...
I see, you understand my pain.
Every good solution is obvious once you've found it.