Combining python and perl

P

Peng Yu

Hi,

According to http://www.python.org/doc/essays/comparisons.html, it
says

"Python and Perl come from a similar background (Unix scripting, which
both have long outgrown), and sport many similar features, but have a
different philosophy. Perl emphasizes support for common application-
oriented tasks, e.g. by having built-in regular expressions, file
scanning and report generating features. Python emphasizes support for
common programming methodologies such as data structure design and
object-oriented programming, and encourages programmers to write
readable (and thus maintainable) code by providing an elegant but not
overly cryptic notation. As a consequence, Python comes close to Perl
but rarely beats it in its original application domain; however Python
has an applicability well beyond Perl's niche."

My question is that how to combine both python and perl to take
advantages of both their strong aspects. Of course, I want to
primarily use python---that is why I send this message to this group.

I see a module 'perlmodule'. But I would like to know whether there
are other tips besides using 'perlmodule' to take perl's advantage in
python.

Regards,
Peng
 
A

Albert Hopkins

Hi,

According to http://www.python.org/doc/essays/comparisons.html, it
says

"Python and Perl come from a similar background (Unix scripting, which
both have long outgrown), and sport many similar features, but have a
different philosophy. Perl emphasizes support for common application-
oriented tasks, e.g. by having built-in regular expressions, file
scanning and report generating features. Python emphasizes support for
common programming methodologies such as data structure design and
object-oriented programming, and encourages programmers to write
readable (and thus maintainable) code by providing an elegant but not
overly cryptic notation. As a consequence, Python comes close to Perl
but rarely beats it in its original application domain; however Python
has an applicability well beyond Perl's niche."

My question is that how to combine both python and perl to take
advantages of both their strong aspects. Of course, I want to
primarily use python---that is why I send this message to this group.

I'm not sure why you'd want to "combine" them. You can pretty much do
the same things with both language, it's just that one may emphasize one
thing or make it easier for the user than the other. For example,
regular expressions in Perl. It's built into the language, but that
doesn't mean Python doesn't have regular expressions, just that Python
is less "centered" around them. If you want to use regular expressions
with Python just "import re".

-a
 
P

Peng Yu

I'm not sure why you'd want to "combine" them.  You can pretty much do
the same things with both language, it's just that one may emphasize one
thing or make it easier for the user than the other.  For example,
regular expressions in Perl.  It's built into the language, but that
doesn't mean Python doesn't have regular expressions, just that Python
is less "centered" around them.  If you want to use regular expressions
with Python just "import re".

I understand that the sames things can be done with both language.

But I do think that certain applications can be done faster (in term
of the coding & debugging time, I don't care runtime here) with one
language than with another. Therefore, for any give problem, it is
meaningful to decide, based on the time to write and debug the code,
which part should be programmed with perl and which part should be
programed with python. However, when I split the code in perl and
python, the problem of the integration is introduced, which incur
additional coding and maintenance cost.

I am sure that somebody must has already encounter the similar
situation like I described above. I am wondering whether there are any
advices on how to take advantages of both languages to speed up the
code development time and reduce maintenance cost.

Regards,
Peng
 
A

Albert Hopkins

I understand that the sames things can be done with both language.

But I do think that certain applications can be done faster (in term
of the coding & debugging time, I don't care runtime here) with one
language than with another.

Yes, and usually that application is written in that language *or* the
other.
Therefore, for any give problem, it is
meaningful to decide, based on the time to write and debug the code,
which part should be programmed with perl and which part should be
programed with python. However, when I split the code in perl and
python, the problem of the integration is introduced, which incur
additional coding and maintenance cost.

Couldn't agree more.
I am sure that somebody must has already encounter the similar
situation like I described above. I am wondering whether there are any
advices on how to take advantages of both languages to speed up the
code development time and reduce maintenance cost.

Perhaps you need to give more specific criteria. I've worked on a few
projects where different languages are used, but in different "domains".
For example, the client may be written in Python but the server written
in Java or PHP. Or different subsystems written in different languages.
For example, the workflow engine may be written in Python but the batch
processor written in C. However in these cases, for the most part, the
systems themselves are monolingual though they communicate with each
other using well-defined, common interfaces (e.g. TCP/IP, XMLRPC, HL7,
etc.).

If, however, you are thinking of writing a sub-system in multiple
languages (ala permodule, for example), you are in for a world of hurt.
Not only will the code be difficult to maintain yourself, it will be
difficult for others to maintain/understand it. Most people don't say
things like "Well I'm going to write all the 'object' stuff in Python
but all the string processing in Perl. What usually motivates people to
write systems in multiple languages are:

* Availability of third-party libraries in a certain language.
* Combining separate systems written in different languages.
* Developer's capabilities in one language or the other
* External dependencies (e.g. need to to have a plugin system for
people to program in Python).
* Performance.
* Other types of "glue" (e.g. installation scripts need to be
written in Perl, test system is Java based so CI scripts need to
be in Java).

permodule is nice for "simple" or "one-off" kind of stuff (or for any of
the above reasons). But any reasonably-sized application using
something like that throughout is going to be a maintenance nightmare.
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top