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

  • Corbin@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    4 hours ago

    In short: If you’d like to learn more, come visit #pypy on Libera IRC. It’s an interesting discussion topic, particularly if we want standard-library imports like math, sys, or json to work.

    RPython is not capable of translating to bare metal today; it depends on libc and libffi for many features even when not producing JIT compilers. It’s also intended to operate on a layer of syscalls: rather than directly instructing hardware, it wants to make fairly plain calls, perhaps via FFI, passing ordinary low-level values. So, any OS developer would first have to figure out how to get RPython to emit code that doesn’t require runtime support, and also write out the low-level architecture-specific hardware-access routines.

    That said, RPython is designed to translate interpreters, and fundamentally it thinks an interpreter is any function with a while-loop, so a typical OS would be a fairly good fit in terms of architecture. RPython knows the difference between high-level garbage-collected objects and low-level machine-compatible values; GC would be available and most code would be written in a statically-typable dialect of Python 2.7 that tastes like Java or OCaml.

    The OS would be the hard part. RPython admits the same compositional flexibility as standard Python, so it should be possible to hack PyPy into something that can be composed with other RPython codebases. This wouldn’t be trivial, though; PyPy in particular is tightly glued to RPython since they are developed together in a single repository, and it wasn’t intended for reuse from the RPython side.

    If all of that sounds daunting, and what you would like to do instead is take an existing kernel or shell with C linkage and ELF support, and extend it arbitrarily using Python code, then PyPy can help you in that direction too. Compile a libpypy and embed PyPy against your kernel, and you can then run arbitrary Python code in a fairly nice environment which supports Python-first development. Warning: while the high-level parts of this might be nice, like Python’s built-in REPL tools, the low-level parts could be very nasty since this embedding interface is old and rotting, to say nothing of actually getting bare-metal code that doesn’t make syscalls.