September 19, 2019

Python as a replacement for perl

The scripting language Perl doesn't need a introduction, because since the 1990s it is widespread used by the UNIX community for automating daily tasks. Perl has the same status like the AutoIt language under the Windows operating system, it's everywhere and nobody admits, that he has written such a script.

The problem with perl is that the language has many disadvantages, not in comparison to a compiled language like C but in comparison to Java and Python. Perl programs look like an improve bash script which means, that it has subfunctions and variables but it's hard to create larger projects. The recommended alternative over Perl is the mentioned Python programming language. The only thing what is important is, that the Python code starts with a different header:

#!/usr/bin/env python3
print("hello world")

Similar to a perl script the python program has made executable with chmod +x helloworld.py This allows to run the script from the command line. It will search for the Python interpreter automatically, and then the cpython program will execute the script.

The performance of Python is the same like in the case of Perl, that means it will run fast enough for most of the tasks and if the user needs a higher performance he has to rewrite critical code segments in the C language. One major improve of Python over Perl is, that it's possible to create graphical applications. This is possible with the object oriented features which allows to send messages to classes. Around the pygame library an entirely community has been formed which is programming simple games with Python.