786
STOP WRITING C (lemmy.world)
submitted 10 months ago by Maven@lemmy.world to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] NotMelon@lemmy.world 49 points 9 months ago

Let's rewrite Linux kernel in Python

[-] CaptainProton@lemmy.world 21 points 9 months ago

Nobody's built a supercomputer powerful enough to run a python version of even Linux Lite Edition.

[-] WhiskyTangoFoxtrot@lemmy.world 27 points 9 months ago

Redstone it is, then.

[-] Blisterexe@lemmy.zip 7 points 9 months ago

I mean, someone made a barebones Linux work in scratch

[-] CaptainProton@lemmy.world 4 points 9 months ago

Like... Kernel written in scratch?

[-] CrayonMaster@midwest.social 11 points 9 months ago* (last edited 9 months ago)
[-] Blisterexe@lemmy.zip 2 points 9 months ago

Yeah, it uses Ed as it's text editor

[-] Jordan_U@lemmy.ml 19 points 9 months ago* (last edited 9 months ago)

Fun fact!

The Asahi Linux drivers for the Apple M1 GPU were originally written in Python: https://asahilinux.org/2022/11/tales-of-the-m1-gpu/

GPU drivers in Python?!

Since getting all these structures right is critical for the GPU to work and the firmware to not crash, I needed a way of quickly experimenting with them while I reverse engineered things. Thankfully, the Asahi Linux project already has a tool for this: The m1n1 Python framework! Since I was already writing a GPU tracer for the m1n1 hypervisor and filling out structure definitions in Python, I decided to just flip it on its head and start writing a Python GPU kernel driver, using the same structure definitions. Python is great for this, since it is very easy to iterate with! Even better, it can already talk the basic RTKit protocols and parse crash logs, and I improved the tools for that so I could see exactly what the firmware was doing when it crashes. This is all done by running scripts on a development machine which connects to the M1 machine via USB, so you can easily reboot it every time you want to test something and the test cycle is very fast!

[-] ICastFist@programming.dev 3 points 9 months ago

Good for testing and iterating, but what about performance? Though I guess getting everything right is more important right now, translating it into another language will probably require less work that way

[-] Jordan_U@lemmy.ml 6 points 9 months ago

It has already been translated into rust. Python wasn't ever intended to be used in the "real" driver, but I thought it was a fun anecdote none the less.

[-] gigachad@feddit.de 5 points 9 months ago

Yes and let us build the environment with conda, it's going to be a fun time!

this post was submitted on 21 Jan 2024
786 points (93.4% liked)

Programmer Humor

32479 readers
242 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS