Can python be used to develop an operating system considering it is a high level language | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Can python be used to develop an operating system considering it is a high level language

Operating Systems

6th Dec 2019, 12:15 PM
Da Ven
Da Ven - avatar
9 Answers
+ 8
I don't know if it can be done, but I think it probably shouldn't. Usually you want your operating system to spare as many resources as possible and run efficiently - because you don't want it to be in the way, when you're using your computer for whatever you're using it. With applications, you can decide whether they should run quickly, be memory-efficient or whatever on a case-by-case basis. Like when you're programming stuff that's not so hardware-challenging, you might go with Python, because writing is quick and simple. But when you need to do crazy processing, like in a 3d game or something, you'd choose a language that makes for quicker code. With an OS, you don't really have that choice - because it will always be running in the background, whatever you play on top of it. So it should probably be quick, small and rather invisible. I'd like to hear what more knowledgeable people say though.
6th Dec 2019, 12:31 PM
HonFu
HonFu - avatar
+ 5
When developing an operating system you're required to have direct access to certain memory regions and communicate with hardware. Python, being a high level language, cannot do these tasks. In the early stages you don't even have the functionality in place to support its allocation and garbage collection. You don't even have support for global variables in C yet. Assembly and C are the go-to languages. Assembly is used to switch the processor from real mode ( a 16 bit compatibility mode ) into protected mode and load in the kernel.
6th Dec 2019, 1:28 PM
Dennis
Dennis - avatar
+ 4
Yes it's possible
7th Dec 2019, 4:50 AM
Sam
Sam - avatar
+ 4
Do you know that the fastest operating systems even use fortran instead of c to just increase the speed a little bit. Fortran is I think at least 5 times harder to code than c and it's syntax is barely close to assembly. On making a operating system all that matters is the speed. Which is opposite of python.
8th Dec 2019, 11:00 AM
Ishmam
Ishmam - avatar
+ 3
And what if you make a python interpreter run in background. I mean, what if the python interpreter is THE main part of the system? You can write some c / asm functions for basic I/O and running task and make python interpreter run all the apps. Then you have : - kernel + routines wrote in c / asm - the python interpreter with all that functions linked, so that it can be called in python - the applicative part (all written in python)
6th Dec 2019, 9:23 PM
Théophile
Théophile - avatar
+ 2
Possibility is low but yea sure it can be
7th Dec 2019, 2:30 PM
Darrow Philip
+ 2
Mirielle🐶 [Inactive] it could support networking and graphics. You can create c / asm basic functions for networking, for example, then link them to Python functions. The python interpreter will just be an abstract level. Then, in that os, you can't create native apps in compiled langages, because all apps run with the Python interpreter. But you can still create low-level program in Python by calling the right low-level functions. Thus, you can even create a graphical interface in python, or a filesystem! About threads, why not creating a specific new Python interpreter that can run threads better? Definitely possible.
8th Dec 2019, 7:29 AM
Théophile
Théophile - avatar
+ 2
{ __ƒαянαn__ } I know that. I never said that it has to be fast. It only has to be fast enough, so that you can't see that it is written in python. That can work perfectly on recent processors. I never said I wanted to build an os in python, and if I've to build an os later, I'll never use python (asm and c instead, of course!). I just wanted to let you think about the possibility of writing an os in python.
8th Dec 2019, 11:33 AM
Théophile
Théophile - avatar
+ 2
Théophile Oh... I was just giving you an example. But as python is a platform independent programming language, I think maybe it's possible to make an os with it. But again it will must need a backup of c.
8th Dec 2019, 11:41 AM
Ishmam
Ishmam - avatar