Neil's News

Polyglot 6: Python

18 September 2004

[Python] Sixth is Python. Good general-purpose language. If there isn't a language which specialises in the desired task (high-level = Lisp; speed = C; multiuser = Moo) then Python is usually a safe bet. The biggest downside is that when compared with other languages, the documentation is poorly organised and poorly written. The docs are so bad that the only way I could write this application was to disect the C source code. I'd argue that the 'Python Paradox'[?] is actually caused by everyone but the most determined programmers switching to lanugages which are properly documented.

Here's the Python source code and a running implementation of the standard colour program. Due to pathetic programming within the Python-GD interface, images are limited to a maximum of 256 colours. Worst implementation yet, and the one that took the longest to program too.

On an unrelated issue, let's play with fire:

Python
def maxrec():
  maxrec();
maxrec();
PHP
function maxrec(){ maxrec(); }
maxrec();
Perl
sub maxrec { maxrec(); }
maxrec();

What do they all do? Blow up, obviously. But how they do it is interesting.
Python (like the Moo) runs a bit then spits out a full traceback ending with "maximum recursion depth exceeded". Good. One can debug that.
PHP runs a bit then quits with "Segmentation fault" offering no clue what happened or where. This isn't ideal.
Perl (like Euphoria) runs and runs and runs. There's a giant sucking sound as memory disappears and all other applications on the server grind to a halt. Meanwhile the sysadmin is sweating bullets trying to kill the task before the server falls over.

[Richard, don't even think about it. I know where you live.]

< Previous | Next >

 
-------------------------------------