yes, not a unix os but rather unix-like, and i want to program all of it on python, is that possible?? even the kernel, i want it all python. i know most kernels use c++ or c* but maybe python has a library to turn c* into python?? i’m still sort of a beginner but thanks and i would appreciate the answers

  • ursakhiin@beehaw.org
    link
    fedilink
    arrow-up
    4
    ·
    2 days ago

    I’m not going to tell you you shouldn’t do that, I think everybody else has done enough telling others what to do. I’ll try to focus more on what you’d need to accomplish and why what you’re asking hasn’t been done.

    Building an OS involves a lot of complex work using very low level calls. The easiest way to think about it, IMO, is that whatever language you use needs to be able to communicate directly with the hardware without any abstraction between the code and the hardware after it’s compiled.

    Basic Python, out of the box, requires multiple levels of abstraction to run.

    (I’m simplifying here) You write code which is run through an interpreter. The interpreter is a compiled application that translates Python into code the operating system can understand. Then the operating system translates that to calls the hardware can understand.

    In that process, the python code is translated to byte code, assembly, and machine code. The Python virtual machine handles memory management for you. It also handles some processing concepts for you.

    You’d need to start by finding (or inventing) a solution that compiles Python to assembly without the need of an interpreter or OS in between you and the hardware. It’s worth noting here that Python itself isn’t even fully written in Python and is instead written largely in C because Python isn’t a compiled language. You’d then need to extend Python with the ability to completely manage memory and processor threads without the VM. You’d need to do that because that’s really the main purpose of an operating system.

    Something we learn in programming is choosing the right tool for the job. Python isn’t a great option for this type of project because the requirements just to get to where you can start are so high that it’s not really considered worth while. Is it possible, yes, in theory. But without the python interpreter and VM, you’d have to ask if you’re really developing Python or something else that just uses pythons syntax.