Why is python not written in C++ ?

Carl Banks pavlovevidence at gmail.com
Sun Aug 1 22:13:04 EDT 2010


On Aug 1, 6:09 pm, John Bokma <j... at castleamber.com> wrote:
> Roy Smith <r... at panix.com> writes:
> > In article <4c55fe82$0$9111$426a3... at news.free.fr>,
> >  candide <cand... at free.invalid> wrote:
>
> >> Python is an object oriented langage (OOL). The Python main
> >> implementation is written in pure and "old" C90. Is it for historical
> >> reasons?
>
> >> C is not an OOL and C++ strongly is. I wonder if it wouldn't be more
> >> suitable to implement an OOL with another one.
>
> > One thing that comes to mind is that it's much easier to distribute C
> > libraries than C++ libraries.
>
> In the beginning of C++ there were programs that just converted C++ to C
> (frontends). At least that is how the C++ compiler Acorn sold worked.
> So I don't think your argument was much true back then.

No, it was that way back then too.  They might all generate C code but
different C code by different backends wouldn't be able to call each
other natively.

For instnace the function

int foo(int);

might be name-mangled this way in one cfront:

foo$d

and this way in another:

____int_foo__int_i


The virtual table of this class:

class Bar {
    virtual int foo(int);
    virtual int bar(int);
};

might be generated like this in one cfront:

struct Bar$$Vtable$ {
    int (*Bar$$bar$d)(int);
    int (*Bar$$foo$d)(int);
};

and like this in another:

struct ____class_Foo___vtable_ {
    int (*foo)(int);
    int (*bar)(int);
};


So, just because they both generated C code, it doesn't mean they can
call one another.


Carl Banks



More information about the Python-list mailing list