Reimplenting Linux Kernel in Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maboroshi

    #1

    Reimplenting Linux Kernel in Python

    Hello

    My question has to do with python and linux - I was interested in
    finding out what it would take to reimplement the Linux Kernel in python
    basically just taking the source code from linux and rewriting it in
    python Would this idea make sense to do - if so what would be the
    benefits of doing this and in what way would this not be a good idea

    Cheers
  • Peter L Hansen

    #2
    Re: Reimplenting Linux Kernel in Python

    Maboroshi wrote:[color=blue]
    > My question has to do with python and linux - I was interested in
    > finding out what it would take to reimplement the Linux Kernel in python
    > basically just taking the source code from linux and rewriting it in
    > python Would this idea make sense to do - if so what would be the
    > benefits of doing this and in what way would this not be a good idea[/color]

    Um, you're the one suggesting a re-write. Doesn't that mean
    it's sort of your job to know the benefits of doing it? There
    are certainly endless reasons why it's not a good idea...

    -Peter

    Comment

    • Maboroshi

      #3
      Re: Reimplenting Linux Kernel in Python

      Peter L Hansen wrote:[color=blue]
      > Maboroshi wrote:
      >[color=green]
      >> My question has to do with python and linux - I was interested in
      >> finding out what it would take to reimplement the Linux Kernel in
      >> python basically just taking the source code from linux and rewriting
      >> it in python Would this idea make sense to do - if so what would be
      >> the benefits of doing this and in what way would this not be a good idea[/color]
      >
      >
      > Um, you're the one suggesting a re-write. Doesn't that mean
      > it's sort of your job to know the benefits of doing it? There
      > are certainly endless reasons why it's not a good idea...
      >
      > -Peter[/color]

      Um sorry I should say in your opinion what would be the benefits and
      also what would be the disbenefits
      [color=blue]
      > Um, you're the one suggesting a re-write. Doesn't that mean
      > it's sort of your job to know the benefits of doing it?[/color]

      I understand some of the benefits but not all

      Cheers

      Comment

      • Peter L Hansen

        #4
        Re: Reimplenting Linux Kernel in Python

        Maboroshi wrote:[color=blue]
        > Peter L Hansen wrote:[color=green]
        >> Maboroshi wrote:
        >>[color=darkred]
        >>> My question has to do with python and linux - I was interested in
        >>> finding out what it would take to reimplement the Linux Kernel in
        >>> python basically just taking the source code from linux and rewriting
        >>> it in python Would this idea make sense to do - if so what would be
        >>> the benefits of doing this and in what way would this not be a good idea[/color]
        >>
        >> Um, you're the one suggesting a re-write. Doesn't that mean
        >> it's sort of your job to know the benefits of doing it? There
        >> are certainly endless reasons why it's not a good idea...[/color]
        >
        > Um sorry I should say in your opinion what would be the benefits and
        > also what would be the disbenefits
        >[color=green]
        > > Um, you're the one suggesting a re-write. Doesn't that mean
        > > it's sort of your job to know the benefits of doing it?[/color]
        >
        > I understand some of the benefits but not all[/color]

        Let me be more explicit then. I think this is an idea that
        is based on very little understanding of what is involved,
        to the point that I think it would be pointless to discuss
        it without knowing what are the things *you* perceive as
        being benefits, and what disadvantages or potential road-blocks
        *you* have already thought of.

        -Peter

        Comment

        • Phil Frost

          #5
          Re: Reimplenting Linux Kernel in Python

          You should take a look at Cleese <http://www.jtauber.com/cleese> and
          Unununium <http://unununium.org/>

          On Wed, Oct 13, 2004 at 03:32:01PM -0700, Maboroshi wrote:[color=blue]
          > Hello
          >
          > My question has to do with python and linux - I was interested in
          > finding out what it would take to reimplement the Linux Kernel in python
          > basically just taking the source code from linux and rewriting it in
          > python Would this idea make sense to do - if so what would be the
          > benefits of doing this and in what way would this not be a good idea
          >
          > Cheers[/color]

          Comment

          • Carlos Ribeiro

            #6
            Re: Reimplenting Linux Kernel in Python

            On Wed, 13 Oct 2004 15:32:01 -0700, Maboroshi <nobody@hotmail .com> wrote:[color=blue]
            > Hello
            >
            > My question has to do with python and linux - I was interested in
            > finding out what it would take to reimplement the Linux Kernel in python
            > basically just taking the source code from linux and rewriting it in
            > python Would this idea make sense to do - if so what would be the
            > benefits of doing this and in what way would this not be a good idea[/color]

            To put it simply, it does not make sense, in its pure form. Linux is
            written in C for a lot of good reasons: portability, need to access
            the hardware, and performance comes to mind. Besides that, Linux is
            Posix compliant and emulates Unix system calls to a large extend, and
            that also makes C a natural choice. To do a similar implementation in
            Python would be similar to try to use a knife to sculpt a marble piece
            -- it's the wrong tool for the job.

            Now, let me re-state your question in a broader sense. Is it possible
            to write an OS using a language such as Python? Yes. But the resulting
            OS will surely be different from Linux -- by design it would be a
            completely different beast. Some parts would still be written in C and
            assembler, because it needs to access the hardware, and also for
            performance reasons. But an API could be devised to allow higher-level
            functions to be written in Python, while calling the low-level
            C+assembler stuff. But as I said, it's _so_ completely different from
            anything else in use today as to make it pretty much a theorethical or
            academic exercise with little practical use. I can't see a project
            like that taking off, even if I would love to see it working.

            --
            Carlos Ribeiro
            Consultoria em Projetos
            blog: http://rascunhosrotos.blogspot.com
            blog: http://pythonnotes.blogspot.com
            mail: carribeiro@gmai l.com
            mail: carribeiro@yaho o.com

            Comment

            • Grant Edwards

              #7
              Re: Reimplenting Linux Kernel in Python

              On 2004-10-13, Carlos Ribeiro <carribeiro@gma il.com> wrote:
              [color=blue]
              > To put it simply, it does not make sense, in its pure form.
              > Linux is written in C for a lot of good reasons: portability,
              > need to access the hardware, and performance comes to mind.[/color]

              Definitely.
              [color=blue]
              > Besides that, Linux is Posix compliant and emulates Unix
              > system calls to a large extend, and that also makes C a
              > natural choice.[/color]

              Not sure I follow on that point. Any low level language that
              can deal with a C "struct" and byte-addressible memory would be
              fine.

              --
              Grant Edwards grante Yow! I'll show you MY
              at telex number if you show
              visi.com me YOURS...

              Comment

              • Phil Frost

                #8
                Re: Reimplenting Linux Kernel in Python

                On Wed, Oct 13, 2004 at 08:24:48PM -0300, Carlos Ribeiro wrote:[color=blue]
                > ...
                >
                > Now, let me re-state your question in a broader sense. Is it possible
                > to write an OS using a language such as Python? Yes. But the resulting
                > OS will surely be different from Linux -- by design it would be a
                > completely different beast. Some parts would still be written in C and
                > assembler, because it needs to access the hardware, and also for
                > performance reasons. But an API could be devised to allow higher-level
                > functions to be written in Python, while calling the low-level
                > C+assembler stuff. But as I said, it's _so_ completely different from
                > anything else in use today as to make it pretty much a theorethical or
                > academic exercise with little practical use. I can't see a project
                > like that taking off, even if I would love to see it working.[/color]

                I can state from first-hand experience that this idea is not too
                far-fetched. It is possible to enable Python to express device drivers
                and low level OS functions like multitasking with an amazingly small
                amount of C+asm; I'd say around 2000 lines, excluding the Python
                runtime. If Pyrex counts as not-C, then I bet it could be done in 500.

                The performance problems are a bit harder, but with a good JIT compiling
                VM the runtime performance of Python could theoretically come very close
                to C.

                I do agree though that there is little point in rewriting Linux in
                Python. The advantage in Python is its expressiveness, but by rewriting
                an existing system you gain nothing.

                Comment

                • Carlos Ribeiro

                  #9
                  Re: Reimplenting Linux Kernel in Python

                  > > Besides that, Linux is Posix compliant and emulates Unix[color=blue][color=green]
                  > > system calls to a large extend, and that also makes C a
                  > > natural choice.[/color]
                  >
                  > Not sure I follow on that point. Any low level language that
                  > can deal with a C "struct" and byte-addressible memory would be
                  > fine.[/color]

                  Well, Unix itself was written in C, and a good part of the C standard
                  library maps naturally to (or at least helps to implement) functions
                  that are mandatory in a Posix-compliant OS. This does not meant that
                  other languages cant be used; it only means that C is a natural
                  choice.

                  Of course, you can provide a C-like interface for a Python program
                  (for example). But a OS written in pure Python would make a much
                  better use of the language if it provides a Pythonic interface. I
                  believe we can agree on this point, dont you think?

                  --
                  Carlos Ribeiro
                  Consultoria em Projetos
                  blog: http://rascunhosrotos.blogspot.com
                  blog: http://pythonnotes.blogspot.com
                  mail: carribeiro@gmai l.com
                  mail: carribeiro@yaho o.com

                  Comment

                  • Francis Lavoie

                    #10
                    Re: Reimplenting Linux Kernel in Python

                    Phil Frost wrote:
                    [color=blue]
                    >On Wed, Oct 13, 2004 at 08:24:48PM -0300, Carlos Ribeiro wrote:
                    >
                    >[color=green]
                    >>...
                    >>
                    >>Now, let me re-state your question in a broader sense. Is it possible
                    >>to write an OS using a language such as Python? Yes. But the resulting
                    >>OS will surely be different from Linux -- by design it would be a
                    >>completely different beast. Some parts would still be written in C and
                    >>assembler, because it needs to access the hardware, and also for
                    >>performance reasons. But an API could be devised to allow higher-level
                    >>functions to be written in Python, while calling the low-level
                    >>C+assembler stuff. But as I said, it's _so_ completely different from
                    >>anything else in use today as to make it pretty much a theorethical or
                    >>academic exercise with little practical use. I can't see a project
                    >>like that taking off, even if I would love to see it working.
                    >>
                    >>[/color]
                    >
                    >I can state from first-hand experience that this idea is not too
                    >far-fetched. It is possible to enable Python to express device drivers
                    >and low level OS functions like multitasking with an amazingly small
                    >amount of C+asm; I'd say around 2000 lines, excluding the Python
                    >runtime. If Pyrex counts as not-C, then I bet it could be done in 500.
                    >
                    >The performance problems are a bit harder, but with a good JIT compiling
                    >VM the runtime performance of Python could theoretically come very close
                    >to C.
                    >
                    >I do agree though that there is little point in rewriting Linux in
                    >Python. The advantage in Python is its expressiveness, but by rewriting
                    >an existing system you gain nothing.
                    >
                    >[/color]
                    unununium, except is name, look very amazing ... but we still have to
                    wait to see a product.

                    Comment

                    • Grant Edwards

                      #11
                      Re: Reimplenting Linux Kernel in Python

                      On 2004-10-14, Carlos Ribeiro <carribeiro@gma il.com> wrote:
                      [color=blue][color=green][color=darkred]
                      >>> Besides that, Linux is Posix compliant and emulates Unix
                      >>> system calls to a large extend, and that also makes C a
                      >>> natural choice.[/color]
                      >>
                      >> Not sure I follow on that point. Any low level language that
                      >> can deal with a C "struct" and byte-addressible memory would be
                      >> fine.[/color]
                      >
                      > Well, Unix itself was written in C,[/color]

                      Originally it wasn't, but recent versions are.
                      [color=blue]
                      > and a good part of the C standard library maps naturally to
                      > (or at least helps to implement) functions that are mandatory
                      > in a Posix-compliant OS.[/color]

                      True, but that has nothing to do with writing a kernel. When
                      working in kernel space, you don't have access to Posix
                      services or the standard C library. Since you can't use the
                      standard C library when writing a kernel, it doesn't matter
                      what language it was designed for. Likewise for any of the
                      Posix standards that specify the API between an application and
                      the system libraries.
                      [color=blue]
                      > This does not meant that other languages cant be used; it only
                      > means that C is a natural choice.[/color]

                      I still don't see why.
                      [color=blue]
                      > Of course, you can provide a C-like interface for a Python program
                      > (for example). But a OS written in pure Python would make a much
                      > better use of the language if it provides a Pythonic interface. I
                      > believe we can agree on this point, dont you think?[/color]

                      Not really -- the interace between the kernel and user-space
                      isn't particulary C-oriented. IIRC on the x86 platform, you
                      make a system call by loading values into registers and
                      executing an interrupt instruction. You can't even make a
                      Linux system call on Linux using standard C. You have to use
                      assembly language wrappers that convert between the system call
                      API and the C API. It would be just as easy to make those
                      assembly language wrappers convert to a Pascal or Python API.

                      --
                      Grant Edwards grante Yow! Isn't this my STOP?!
                      at
                      visi.com

                      Comment

                      • Dennis Lee Bieber

                        #12
                        Re: Reimplenting Linux Kernel in Python

                        On Wed, 13 Oct 2004 15:32:01 -0700, Maboroshi <nobody@hotmail .com>
                        declaimed the following in comp.lang.pytho n:
                        [color=blue]
                        > Hello
                        >
                        > My question has to do with python and linux - I was interested in
                        > finding out what it would take to reimplement the Linux Kernel in python
                        > basically just taking the source code from linux and rewriting it in
                        > python Would this idea make sense to do - if so what would be the
                        > benefits of doing this and in what way would this not be a good idea
                        >[/color]

                        You'd have to name the result Ouroborous...

                        After all, common Python relies on the C-library making OS level
                        I/O calls... (and the C-library may be relying on assembly modules yet).


                        If it were possible, it would run VERY slowly; you'd be using a
                        byte-code interpreter to perform what is normally highly optimized
                        native code.

                        --[color=blue]
                        > =============== =============== =============== =============== == <
                        > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
                        > wulfraed@dm.net | Bestiaria Support Staff <
                        > =============== =============== =============== =============== == <
                        > Home Page: <http://www.dm.net/~wulfraed/> <
                        > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

                        Comment

                        • Cliff Wells

                          #13
                          Re: Reimplenting Linux Kernel in Python

                          On Thu, 2004-10-14 at 01:44 +0000, Grant Edwards wrote:[color=blue]
                          > On 2004-10-14, Carlos Ribeiro <carribeiro@gma il.com> wrote:
                          >[color=green][color=darkred]
                          > >>> Besides that, Linux is Posix compliant and emulates Unix
                          > >>> system calls to a large extend, and that also makes C a
                          > >>> natural choice.
                          > >>
                          > >> Not sure I follow on that point. Any low level language that
                          > >> can deal with a C "struct" and byte-addressible memory would be
                          > >> fine.[/color]
                          > >
                          > > Well, Unix itself was written in C,[/color]
                          >
                          > Originally it wasn't, but recent versions are.[/color]

                          'Recent' meaning since 1974? ;)

                          --
                          Cliff Wells <clifford.wells @comcast.net>

                          Comment

                          • Neal D. Becker

                            #14
                            Re: Reimplenting Linux Kernel in Python

                            Maboroshi wrote:
                            [color=blue]
                            > Hello
                            >
                            > My question has to do with python and linux - I was interested in
                            > finding out what it would take to reimplement the Linux Kernel in python
                            > basically just taking the source code from linux and rewriting it in
                            > python Would this idea make sense to do - if so what would be the
                            > benefits of doing this and in what way would this not be a good idea
                            >
                            > Cheers[/color]

                            Yeah, that's a great idea. Go for it. Let me know when you're done.


                            Comment

                            • Miki Tebeka

                              #15
                              Re: Reimplenting Linux Kernel in Python

                              Hello Carlos,

                              [Maboroshi][color=blue][color=green]
                              > > My question has to do with python and linux - I was interested in
                              > > finding out what it would take to reimplement the Linux Kernel in python[/color][/color]

                              [Carlos][color=blue]
                              > I can't see a project like that taking off, even if I would love to see
                              > it working.[/color]
                              In a diffrent language, MzScheme can boot as an OS on x86
                              (http://www.ccs.neu.edu/scheme/packages/mzscheme/) using OSKit
                              (http://www.cs.utah.edu/flux/oskit/)

                              Bye.
                              --
                              ------------------------------------------------------------------------
                              Miki Tebeka <miki.tebeka@gm ail.com>
                              Find information, resources and relevant links for spymac.net. This domain may be for sale.

                              The only difference between children and adults is the price of the toys

                              Comment

                              Working...