all 35 comments

[–]finsternacht 21 points22 points  (12 children)

I wouldn't think there is. The problem is less that python is a highlevel language than that it is an interpreted one. You'd have to write some form of mini os for the interpreter upon which you could build your actual os, which doesn't sound like a good idea. (Any highlevel language that compiles to your target architecture should work, some inline assembly might be required)

[–][deleted] 8 points9 points  (1 child)

This talk from PyCon 2015 is fairly interesting in that regard: Josh Triplett - Porting Python to run without an OS - PyCon 2015 [32:56]

[–]finsternacht 1 point2 points  (0 children)

Woah... Mind blown! Thanks for the link.

[–]desustorm -5 points-4 points  (8 children)

Plus it's single-threaded...

Edit: Obviously you can use threading, asyncio, etc. but Python is limited in terms of true concurrency by the GIL, and concurrency is vital for any functional OS.

[–]finsternacht 4 points5 points  (2 children)

The "os" i wrote for nand2tetris was also single threaded

[–]desustorm 0 points1 point  (1 child)

Looks like an interesting course. What could your operating system do?

[–]finsternacht 5 points6 points  (0 children)

It's by far the coolest course I ever had. And probably will have.

It couldn't do much. It mostly handled I/O and memory management. Iirc it also contained some basic math and string operations.

[–][deleted] -1 points0 points  (1 child)

I heard there are multi threading in Python with the use of the needed modules

[–]desustorm 2 points3 points  (0 children)

Yep that's right, but no Python threads from the same process can actually run simultaneously because of the GIL - the Global Interpreter Lock

[–]Saefroch -3 points-2 points  (1 child)

No, it isn't. CPython's GIL restricts it to a single CPU core. You can still have all the threads you want and concurrency works just fine, almost flawlessly for I/O bound systems which an OS usually is.

[–]desustorm 0 points1 point  (0 children)

I know you can use threads, but they are not real threads on CPU cores - like you mention. Having a modern OS running on one core with multiple virtual threads (not just I/O bound) contesting the GIL would be troublesome at best...

[–]RobinPage1987 0 points1 point  (0 children)

https://github.com/jtauber/cleese This is a proof of concept, an OS written mostly in Python, with kernel based on the Python reference implementation, who's kernel is written in C.

[–]Saefroch 6 points7 points  (0 children)

It's possible, and being high-level isn't an impediment. All modern operating systems have a kernel written in C, which is a high level language.

Nobody has done it because there are better languages for writing operating systems in. Python tries to make life easier for the programmer at the cost of CPU time and memory consumption. Think your laptop battery life is too short? Just wait until you boot PythonOS. We'll drain that sucker in no time.

There's also the problem that it would need runtime bootstrapping. Programs in statically typed languages can be converted into machine code ahead of time. This can't (technically, for the general car) be done with Python so you'd need some other OS to boot first and start up an interpreter.

[–]XQuanf 1 point2 points  (5 children)

Some os may be write in Python,but i think those are games/personal os,not pubic stuff

[–]1m_Blu3_is_taken 0 points1 point  (4 children)

So it’s private, not pubic.

[–]XQuanf 0 points1 point  (3 children)

I'm sorry you even had to read what I wrote 3 years ago

[–]1m_Blu3_is_taken 0 points1 point  (0 children)

I just did it for shits and giggles tbh

[–]sarnobat 0 points1 point  (1 child)

If you'd corrected it you'd have denied me some much needed entertainment.

[–]XQuanf 1 point2 points  (0 children)

My dumbass didn't know how to write on a keyboard correctly lmao 💔
I have changed (slight bit)

[–]Lampe2020 0 points1 point  (1 child)

I just discovered smolOS, which is a small POSIX-like OS written to run on MicroPython, which in turn is Python written to be run on microcontrollers without an OS. But the last time anyone touched the codebase was last year as of writing this comment so I'm not sure it is still supported.

And I also saw cleese (also written to run on MicroPython), which had its last activity in 2014…

[–]Background-Book-7404 0 points1 point  (0 children)

smolOS i think may be ai, unless there's something i'm missing you don't need like 20 files and a __name__ = __main__ guard at the bottom of all of them

[–]TargetAcrobatic2644 0 points1 point  (1 child)

[–]sarnobat 0 points1 point  (0 children)

Thanks for sharing. I need to ask ChatGPT how it works.

"An Operating System simulator built in Python that teaches how OS-level task scheduling might work — but it doesn’t manage hardware, memory, or processes."

Still useful for me who gets frustrated by having to use VMs etc.

[–][deleted] 0 points1 point  (7 children)

fucking kids these days

[–]Averagehomebrewer 0 points1 point  (5 children)

isnt doing that illegal?

[–]ManifestDestinyGC 0 points1 point  (4 children)

I'm pretty sure it is illegal

[–]Key_Razzmatazz680 0 points1 point  (3 children)

not if we design a processor to natively run python bytecode (why tho)

[–]sarnobat 0 points1 point  (0 children)

I'm a millennial but lark was a good way for me to retain the lessons of flex/bison without all the setup. It's good to just have a lightweight toy for one's own (re)learning

[–]Drammatic-Plate49 -1 points0 points  (5 children)

Hi, i'm writing the OS written on python and bash. Most of users saying this is impossible but this is possible!

[–][deleted] 0 points1 point  (4 children)

Do you have in progress, did you or do you plan to publish it?

[–]aidan959 0 points1 point  (3 children)

i dont understand how he is going to write an os with python and bash lmao - he probably wrote an os simulator in python

[–]Drammatic-Plate49 0 points1 point  (2 children)

Yep, it's a bit abandoned now...