From: Christian Heimes on
Am 02.08.2010 01:08, schrieb candide:
> Python is an object oriented langage (OOL). The Python main
> implementation is written in pure and "old" C90. Is it for historical
> reasons?

Python is written in C89 to support as many platforms as possible. We
deliberately don't use any new features and almost no compiler specific
extensions to make the interpreter portable. AFAIK the only compiler
specific feature used in Python are computed gotos and they are optional.

> 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.
>
> Has it ever been planned to rewrite in C++ the historical implementation
> (of course in an object oriented design) ?

I like to say that the Python interpreter is written in object oriented
C code. Every Python object evolved around PyObject and PyType structs
that are extended (subclassed) to add additional members. Python won't
gain anything useful from a pure C++ implementation. C++ would only add
a major layer of complexity and scary features.

In your opinion what would Python gain from a C++ implementation?

Christian

From: Tomasz Rola on
On Sun, 1 Aug 2010, John Bokma wrote:

> 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.

Those that I (tried to) used on Amiga were based around the same concept.

It seems, that Comeau C++ compiler (which I never tried) still requires C
compiler as a backend (and is highly regarded by some).

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:tomasz_rola(a)bigfoot.com **
From: Carl Banks on
On Aug 1, 6:09 pm, John Bokma <j...(a)castleamber.com> wrote:
> Roy Smith <r...(a)panix.com> writes:
> > In article <4c55fe82$0$9111$426a3...(a)news.free.fr>,
> >  candide <cand...(a)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
From: Albert Hopkins on
On Mon, 2010-08-02 at 01:08 +0200, candide 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.
>
> Has it ever been planned to rewrite in C++ the historical implementation
> (of course in an object oriented design) ?

Disclaimer: I am neither a C nor C++ programmer. In fact I can barely
even program in Python ;-)

I would propose that in fact most programming languages are implemented
in C. Sun's (Oracle's) Java compiler and runtime are written in ANSI C.
The core of the Gnu Compiler Collection (which includes C++ and
Objective-C compilers) is written in C. The official Ruby is
implemented in C. The Squeak Smalltalk implementation uses C instead of
C++. I can't even think of a programming language that is implemented
in C++ (maybe C++ is).

C seems to be a good, portable language for writing interpreters and
compilers.

But I wonder if someone has/has tried to write a programming language in
C++ and what were their experiences.

From: Tomasz Rola on
On Sun, 1 Aug 2010, Albert Hopkins wrote:

> C seems to be a good, portable language for writing interpreters and
> compilers.

And one should not forget about performance. C++ was for a long time
behind C, and even now some parts (like iostreams) should be avoided in
fast code.

BTW, C++ can be IMHO a bit tricky in situations when one would like to
call back from JIT-generated code into parts written in C++... I mean
things like virtual functions, overloading, code generated from templates,
accessing private members etc. All those issues are non essential from the
point of interpreting or JIT, yet they stand in a way. While this could be
solved (with some headache, I suspect), C is far simpler and function
calls or manipulating structs are actually trivial...

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:tomasz_rola(a)bigfoot.com **