Maybe Python is cooler than PHP.

How to write a spelling corrector in twenty lines of Python. The code involves the complete works of Sir Arthur Conan Doyle, and it’s brilliant. I have often pondered how to write precisely this software. There’s no way that I could have done it in less than 200 lines, and it wouldn’t have worked nearly as well as this. I’m just not clever enough with math. (Via Metafilter)

Published by Waldo Jaquith

Waldo Jaquith (JAKE-with) is an open government technologist who lives near Char­lottes­­ville, VA, USA. more »

4 replies on “Maybe Python is cooler than PHP.”

  1. Amen. :)

    Python and PHP both have their uses and specialties… but I’ve been coding in Python for years now and love it. Anything and everything I’ve written in the last eight or more years has been in Python.

    It’s a beautifully structured language and one that I think should be used for teaching the concepts of object oriented design (as well as programming in general). It’s actually kind of addictive once you get into it…

    My biased two cents…
    – Aaron

  2. Python is a nice, clean language. Whether it is the best example of an OO language is debatable, but PHP is mostly a hack that will rot your mind (see also: perl).

    I also object to the mixing of code and data/presentation that is pretty much built-in to PHP. That is a fast path to hard-to-maintain systems.

    Peace,
    Sean

  3. Rot your mind? You mean like the following utility I wrote a couple years ago?

    #!/usr/bin/perl
    ($\,@_)=(“\n”,”Do”,”Re”,”Mi”,”Fa”,”So”,”La”,”Ti”,shift);
    do{$_=$_[$_[$#_]%$#_].$_;$_[$#_]=($_[$#_]-$_[$#_]%$#_)/$#_}while($_[$#_]);
    print

    Takes base-10 input on stdin and converts it to base 7, with output to stdout in Julie Andrews song tones.

    Amazing the brain-rotting things you can do with a snippet of line noise, eh? :)

  4. Well, I won’t go so far as to say my statement meant “the best” example OOP, but I feel that it’s an excellent way to introduce (and use) the concepts of OOP. A person might well go on to C++ or other languages, but I suggest that they can gain the concepts behind OO coding far faster with Python’s syntax and approach to coding.

    – Aaron

Comments are closed.