Answer the question
In order to leave comments, you need to log in
Which PL (programming language) is best for writing the operating system kernel?
I welcome everyone! Interested in general development.
I recently found out that the Linux kernel is made in C. Darwin (Apple) based on Linux => also C.
Is it possible to use Java, Go, Scala or other languages to create the kernel?
It would seem that C is complex and rather old, should it have a substitute, or does it still know how to do something that other languages \u200b\u200bare not able to do, or is it easiest or something else?
Thanks for your reply!
Answer the question
In order to leave comments, you need to log in
So far, only SI. Well, unless you come up with a new alternative to
C:
----Java
----Go
----Scala
Don't be afraid that C is old. Sometimes the old is the time-tested and the best!
The Java machine is the Java OS. There were also Lisp machines and Fort machines. There is an OS written entirely in assembler menuetos.net/. Now the OS is being actively developed on Rust https://www.redox-os.org/
C, D, Rust, Modula-2, Oberon, Ada and others. You can also use C as the target language.
In C, historically, there is more code and examples, but this does not mean that you cannot write the OS kernel and drivers in others.
And system utilities and other things in user space are easier to write in higher-level languages than C.
You can use either python or php. If you can provide the necessary functionality and make the interpreter work in the right environment. Or you can translate to C and compile
I personally write the OS, I will say this, you have to be prepared for difficulties, there are no amenities there, you can’t allocate memory there (until you implement the memory manager yourself), the banal implementation of printing text on the screen will take at least a week, you need to implement everything yourself. The conveniences that modern languages such as Java provide simply do not exist there. Therefore, C and assembler are the best tools. Of course, you can write in some other language, but this will create more problems than benefits.
The operating system is the lowest layer in HAL :)
the closer the language is to the processor command system, the more efficiently you can work out the operating system, and all the above "lying" programs will be executed faster.
I recently learned about an interesting alternative - forth. An interesting point is the fact that, in principle, the language can be used immediately instead of a shell command for the OS. But it's just for playing around and cycling, if something practical, then it's C, C ++ and ... everything else that compiles (in addition to everything, see LLVM frontend list)
In principle, why C is enough - yes, because hardware in relation to the OS often acts in the form of finite automata, which, as it were, tightly binds hands to write within the framework of a structure-oriented code. OOP is simply not needed, and if the language was designed for the development of application programs, then there is too much useless from the point of view of solving the problem of writing an OS. Given the simple C memory model, it is very easy to control the state of caches of all levels, and given the tens of thousands of hours invested in gcc, there is no point in writing something practical except for assembler (see KolibriOS).
Proceed from what execution context for your OS you are interested in - if this is not hardware, then there may be some kind of virtual machine.
Although, based on very practical considerations, it is better not to write an OS, but to write several kernel modules for Linux.
In assembler or C. But it's a huge mess! There will be a cloud of difficulties. Memory management, interaction with I / O devices - do it yourself. So a couple of years from life will have to be allocated, whatever one may say.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question