-2

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

  • 3
  • 1
    @ErikEidt: I suspect that Android is already heavily optimized for Java. Naturally, almost anything in computing is possible given enough time, money, effort and computing resources. Also, note that the core of Android is written in C and C++, not Java. – Robert Harvey Aug 24 '16 at 19:58
  • 1
    Are you talking about a real OS (ie: replacing linux), or are you asking about a desktop environment (ie: somethng like gnome) that provides the graphical and command-line interfaces on top of the actual OS? – Bryan Oakley Aug 24 '16 at 20:30
  • 1
    BryanOakley Something like Android, not replacing Linux, but a layer on top of it. The core (kernel, drivers, etc.) will be in a compiled language like C or C++. – sbrm1 Aug 25 '16 at 4:05
  • 3
    Can you? Of course. Is it likely to be of any benefit? No. – whatsisname Aug 25 '16 at 4:36
4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.