Question

I have been pondering over the idea of a Python-based Operating System on top of the Linux kernel, much like how Android uses Java.

What if most of the system components were built using Python, this way most of the Operating System can be modified by anybody who understands Python code. This can allow anybody with Python experience to extend and fully customize the entire operating system. Since Python allows modules to be built using C, this can allow specific system components to benefit from speed where needed, such as a graphical interface. Using C interfaces also allows every part of the Linux kernel to be easily exposed to Python when attempting to build such an Operating System.

A large benefit of such an operating system is application portability, at least applications which are made in pure Python. The entire Operating System will run anywhere you can compile the Linux Kernel and Python into, with less effort than say porting all of Linux over to a different chipset. Python apps don't need to be re-compiled for the target CPU, and if most of the Operating System is made in Python, porting will be quite easy.

Edit: (Something I want to clarify after looking at the down votes)

I don't want to replace Linux, just a layer on top of it like Android does with Java. (Perhaps using virtualenvs)

Specific OS components will be compiled in C of course, since Python supports this using many different methods. Python shouldn't be much slower or faster than a Java VM, and Java works nicely on embedded devices. The main point of using Python over Java is licensing. After seeing what Oracle is doing to Google in Court over Android and Java, developing a Python solution would prevent any such issues and innovation can continue. The reason for not just using a strictly C system, is that Python is much more dynamic at runtime and with computers ever so changing, using a static language at the Operating System's core seems rather limiting.

About multitasking: The Linux kernel will be doing the multitasking. Python will not be kernel, or do any really low level stuff. GIL and stuff of CPython won't be involved here.

How Android does it: Android Core

Was it helpful?

Solution

Of course it can be done. But look at this architecture sheet: The kernel and kernel modules, which are to be kept in C, are AFAIK a major part of Linux. The "system libraries" need to be replaced or extended by a C-to-Python adapter, which will also be no pure Python. I am pretty sure the utilities layer, however, could be completely replaced by pure Python tools (though I have some doubts concerning the performance of the result).

So your idea that "most of the Operating System can be modified by anybody who understands Python code" in reality will IMHO become "some of the Operating System parts can be modified by anybody ...". The result would not be "an Operating System in Python", only an OS written in C with an utilities layer in Python.

Licensed under: CC-BY-SA with attribution
scroll top