Can I add for example Python support for my OS? Or any kind of language, like Java, Ruby, PHP etc?
Sorry if this questions have already answered but I really don't find any material about this. And sorry for mah bad English, i'm brazilian.
How can I add support for other languages in my OS?
How can I add support for other languages in my OS?
OS Development is awesome!
|AetherOS Project|
|AetherOS Project|
Re: How can I add support for other languages in my OS?
In user mode or in kernel mode?
Re: How can I add support for other languages in my OS?
First, have a comprehensive enough userspace that it makes sense... You'll need a C standard library at the very least, and likely a bunch of other support libraries.
Second, port the language's compiler(*)/interpreter/runtime to your OS. Depending on how comprehensive your userspace is, how similar it is to other OS's that the language supports and how much of a priority the original developers put on portability this can range from "trivial" to "several years of work".
The wiki has an article on Porting Python, which should at least cover the basic concepts (although the exact steps will be different) for porting similar software.
If you're talking about using other languages in your kernel, that's a bit different. Some highly-portable languages (such as those designed to work on "embedded" systems) like Lua can be adapted for kernel use fairly easily, but anything with a substantial runtime is likely to be quite difficult...
(*) For compiled languages, you may not have to port the compiler to your OS itself, but just re-target it to act as a cross-compiler running on another OS (i.e. your development environment).
Second, port the language's compiler(*)/interpreter/runtime to your OS. Depending on how comprehensive your userspace is, how similar it is to other OS's that the language supports and how much of a priority the original developers put on portability this can range from "trivial" to "several years of work".
The wiki has an article on Porting Python, which should at least cover the basic concepts (although the exact steps will be different) for porting similar software.
If you're talking about using other languages in your kernel, that's a bit different. Some highly-portable languages (such as those designed to work on "embedded" systems) like Lua can be adapted for kernel use fairly easily, but anything with a substantial runtime is likely to be quite difficult...
(*) For compiled languages, you may not have to port the compiler to your OS itself, but just re-target it to act as a cross-compiler running on another OS (i.e. your development environment).
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: How can I add support for other languages in my OS?
If you do that then of course you'll only be able to run the compiled binaries on your OS, you'll still need another system to compile the source code that's been written in your chosen language.mallard wrote:For compiled languages, you may not have to port the compiler to your OS itself, but just re-target it to act as a cross-compiler running on another OS (i.e. your development environment).
Also in addition to porting the interpreter/runtime to your OS you'll also need to write a binding between your OS's API and your chosen language (unless the interpreter/runtime provides a standard API, in which case you'll need to implement the standard API using your OS's API as part of the porting step).
It's best to not think of this as "adding support for a language to your OS". OSes do not "support" languages. For compiled languages you're making the compiler support your OS, not the other way around. For interpreted languages you're porting the interpreter to run on your OS. Your OS "supports" any language for which there is a compiler that can compile for it or an interpreter that can run on it. Language "support" is not built into an OS but is dependant on the compilers/interpreters rather than the OS itself.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing