Addison Wesley, 2001
As a long time Perl and Python programmer, I'm constantly finding myself using Perl constructs in Python or Python constructs in Perl. Worse, I can suddenly find myself trying to use a feature or system in a Python program that just doesn't exist, or does and works differently. What I needed was some sort of cross reference.
After talking to other programmers and developers it became apparent that a number of people were "jumping ship" from Perl to Python. Some with varying levels of success. The reasons for using Python in preference to Perl were different for each person, but there were some common themes:
Python is object-oriented. Although Perl has object orientation facilities they are not integrated into the system. In Python everything is an object or class – even the base data types are objects and have their own methods and attributes. This makes Python a great language to use in situations where you are working on applications that use object orientation as a core technology.
Python is easy to use. Python has a very clean and structured layout, and it's very easy to follow what's going on. Perl can frequently look like line noise, and particularly for new programmers this becomes a problem as they try to understand why their program works.
Python does what you tell it to. Perl suffers from a severe case of semi-intelligence. Statements and expressions in Perl have all sorts of rules, exceptions to those rules, and other artefacts that can make it difficult to follow what is going on. Just think about what happens when you call a function, was it called in list or scalar context?, what arguments did it have?, how do I get them back? These are regular questions when programming with Perl.
Python is cross-platform compatible. Perl is also cross-platform compatible, for certain values of compatible. Because of Perl's Unix roots – it is very much a Unix language – use Perl under Windows or MacOS and a large proportion of the built-in functions become obsolete. Python's functionality is supported by external modules, many of which use the correct version according to their platform whilst retaining the same API.
These aren't really hard and fast reasons for why you should make the jump to Python, but they are compelling reasons for why Python is at least worth a look.
In this book that's exactly what we try to do – show you how you can make the move from Perl to Python. Many of the basics are the same, and despite a change of language, you're unlikely to need to change the algorithms you are already using.
For the more advanced programmer, or, like me, the programmer who has to use both languages most days, the book should also work as a handy cross reference to allow you to look up Perl and Python statements and functions, and find out what you should use in both languages.