20

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

you are viewing a single comment's thread
view the rest of the comments
[-] zagaberoo@beehaw.org 2 points 1 day ago

You're absolutely right, you could take any binary that runs under an OS and set up a bootloader to execute it directly without an OS.

The problem is that all programs, even ones in C, rely invisibly and enormously on the OS abstracting away hardware for them. The python interpreter doesn't know the first thing about how to parse the raw bytes on a hard drive to find the location of the bytes that belong to a given file path. Files and filesystems are 'fake' when you get down to it, and the OS creates that fiction so each program doesn't have to be customized per PC setup.

So, ironically, to be able to truly kernel hack in python like you want would require writing tons of C to replace all OS hooks (like fopen to interact with a file, e.g.) with code that knows how to directly manipulate your hardware (speaking PCIe/NVMe to get to the disk, speaking GPT to find the partition on the disk, speaking ext4 to find the file in the partition, e.g.).

OSes are complex as hell for a reason, and by retrofitting python to run on bare metal like that would require recreating that complexity in the interpreter.

this post was submitted on 09 Jan 2025
20 points (73.8% liked)

Programming

17788 readers
66 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS