C/C++, Perl, etc. to Python converter

M

mm

Is there a Perl to Python converter?
Or in general: a XY to Python converter?

Is see, that Python is much better then Perl anyway.
But for beginners, they whant to konw how is this done with Python etc.

Sure, there are some docus out there in the internet. But a converter?
 
D

Diez B. Roggisch

mm said:
Is there a Perl to Python converter?
Or in general: a XY to Python converter?

Is see, that Python is much better then Perl anyway.
But for beginners, they whant to konw how is this done with Python etc.

Sure, there are some docus out there in the internet. But a converter?

Nope. Different languages have different idioms, translating them to each
other - while technically possible, at least to some extend - won't result
in anything that a human being can work with.

Diez
 
M

Matimus

I don't know of a converter, one may exist. I have seen similar
requests though and will give you a similar response to what I have
seen. A converter, if it exists, may be able to produce working code
but _not_ readable code. Python is a language whose strength comes
from, among other things, its readability and conventions. Learning
python is best done by using the online documentation
(http://docs.python.org/tut/tut.html) and reading existing code (take a
look at the built in modules).

My biggest fear of teaching someone to program by using a program to
convert perl to python is that they will end up writing python that
still looks like perl.

I don't know if it helps, but I know others will give you similar
advice.

-Matt
 
M

Michael

Yes, I konw what you mean. And thats the right way to do it - for
beginners. --But not for someone who allready know programmings things
for many years.

They ask themself: How can I do this in Python? I can remember, it was
that-way with Perl or C or C++ or whatever.

So, not only a ververter can be useful, also a translation table.
(Maybe just a table for print out.)

LangX <-> LangY
 
R

Richard Charts

mm said:
Is there a Perl to Python converter?
Or in general: a XY to Python converter?

Is see, that Python is much better then Perl anyway.
But for beginners, they whant to konw how is this done with Python etc.

Sure, there are some docus out there in the internet. But a converter?
I don't know of any converter, but I have seen a number of tutorials
that show how to do OO things in both perl and python for example.
Avi Kak of Purdue U. has one such tutorial.
When I took his class, he had a large package of notes that he said was
the basis for his next book. It doesn't look like he ever got around
to publishing that one.
However, if you google his homepage, he does have at last one tutorial
posted for Perl vs. Python.
 
T

Thomas Ploch

Matimus said:
I don't know of a converter, one may exist. I have seen similar
requests though and will give you a similar response to what I have
seen. A converter, if it exists, may be able to produce working code
but _not_ readable code. Python is a language whose strength comes
from, among other things, its readability and conventions. Learning
python is best done by using the online documentation
(http://docs.python.org/tut/tut.html) and reading existing code (take a
look at the built in modules).

My biggest fear of teaching someone to program by using a program to
convert perl to python is that they will end up writing python that
still looks like perl.

I don't know if it helps, but I know others will give you similar
advice.

-Matt

I think that it *is* possible to do it, but a whole lot of work had to
be done to achieve this. It is all about how many rules (like how to
convert this block of unreadable code of language X into a readable
python block) you are willing to find/program (and these are a lot). It
is a almost gigantic task to make this work proper, but it definitely
*is* possible.

Something like this doesn't exist yet, but people (especially
Computational Linguists) are working on this.

Thomas
 
D

Diez B. Roggisch

I think that it *is* possible to do it, but a whole lot of work had to
be done to achieve this. It is all about how many rules (like how to
convert this block of unreadable code of language X into a readable
python block) you are willing to find/program (and these are a lot). It
is a almost gigantic task to make this work proper, but it definitely
*is* possible.

It is definitely _not_ possible. There are so many design decisions that
are differing based on what a language offers - e.g. generators, garbage
collection, precise control over memory layout and so on.

Projects like jython or ironpython show that to some degree at least
binary compatibility is feasible - but beyond that, machine generated
cod will always be that, and by no means idiomatic.

Diez
 
J

John Nagle

Diez said:
It is definitely _not_ possible. There are so many design decisions that
are differing based on what a language offers - e.g. generators, garbage
collection, precise control over memory layout and so on.

Inter-language translators have been written. There's usually
a performance penalty, which can be severe when the idioms of
the languages are quite different.

Perl to Python translation might be worth doing. The
languages have quite different syntax, but roughly the same
functionality. You'd probably have to write a set of libraries
in Python with the equivalent definitions to their Perl
counterparts, but that's just time-consuming, not difficult.

John Nagle
 
D

Diez B. Roggisch

It is definitely _not_ possible. There are so many design decisions
Inter-language translators have been written. There's usually
a performance penalty, which can be severe when the idioms of
the languages are quite different.

The point discussed here was not the feasibility of language-translators
per se. These are certainly possible, yet I doubt that e.g. C++2Python
would really come to existence.

Thomas expressed his belief that a _idiomatic_ translator was possible.
And that certainly isn't the case.

Diez
 
U

Uwe Grauer

mm said:
Is there a Perl to Python converter?
Or in general: a XY to Python converter?

Is see, that Python is much better then Perl anyway.
But for beginners, they whant to konw how is this done with Python etc.

Sure, there are some docus out there in the internet. But a converter?

Maybe this can help in converting from prel to python:
http://www.crazy-compilers.com/bridgekeeper/

Uwe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top