Python is probably the easiest language I've come along, for use as an introductory language anyway. I, myself, started on HTML, then moved onto JavaScript, ActionScript 2.0, C++, and so on, but when I took my computer science class in September I was forced to use Python. Since I knew the class would be a breeze anyway, I had some fun learning Python. (Thank God it wasn't Perl.)

Python is a pretty neat language, actually. Neater than I originally thought. It has a few problems, though:

  • It's slow. It's a scripting language, which means that every script runs through the Python executable while it's running. This means everything has to be processed twice, instead of just running natively. (Just to compare it for you; Java runs as a script on Android 2.1 and runs natively on Android 2.2. And, as a result, Android 2.2 is approximately 5.5 times faster than 2.1.)

  • Its syntax is meant for babies. Sorry, but if (a and b) is just stupid. I wouldn't even care if they allowed that, but also allowed if (a && b). However, only the former is allowed. You also cannot use // COMMENT as a comment in Python, nor can you use /* COMMENT */. The corresponding Python comment syntaxes are # COMMENT and '''COMMENT'''.

  • Brackets are invalid. if (a) { b(); } is invalid. The proper syntax is if (a): b();. And if you're doing a multiline code, here are the C++ (both C++ are equivalent) and corresponding Python versions (second Python is invalid):

    if (a) {
        b();
        c();
    }
    
    d(); // Will execute regardless of a or !a.
    if (a) { b(); c(); } d();

    if (a):
        b();
        c();
    
    d(); # Will execute regardless of a or !a.

    # Invalid code.
    if (a): b(); c();
    d();

    It is also worth noting that, if on one line you have four spaces, then b();, and on the next line you have a four-space-wide tab and c();, you will get errors. This is a nightmare for using code from other people in existing programs.

  • for loops are disgusting. Yeah, I'm going to give you a C++ example and tell you how you'd have to do it in Python (two possible ways). That should be enough to convince you that Python's for loops are terrible.

    int m = 50;
    for (int i = 1; i < m; i *= 2) {
        print("%d\\n",i);
    }

    m = 50;
    i = 1;
    while (i < m):
        print i;
        i *= 2;

    m = 50;
    for i in [x for x in range(0, m) for y in range(0, x) if (2**x == y)]:
        print i;
  • Compatibility. I play The Elder Scrolls IV: Oblivion, and one of the best 3rd-party programs for modding the game is called Wrye Bash. It's built in Python and has one of the most annoying install processes in the world. It has to be installed with the following: Python 2.5 (no higher), Python COM Elements 1.0 (or 1.1, I forget), wxPython 2.8.8 (no higher), and a few other version-specific things. Luckily they made an installer that just does this all itself, but if they didn't, it would just be a pain. The bottom line is, a user has to install a bunch of stupid libraries to run a Python program whereas for C++, that's not so much of a problem.

I could go on, but these are the basic things that just irk me.

Having ranted about the bad stuff, there are quite a few things I like about Python.

  • Flexibility. I've discussed C++'s auto variables twice ([1] [2]) and both times have drawn a comparison to Python. What I love about Python's variable system is that I can literally reassign variable types and have arrays of multiple types without an error.

    x = 5;
    x = 10.6662;
    x = "String";
    x = ["Array","Of",123,4.56,["X"]];
  • Error handling. The try/catch in Python is superior to that of C++. I'm not going to explain why, 'cause I don't totally get the use of C++'s (perhaps someone can enlighten); but when I was trying to learn C++'s, it was like a gearshift with first & reverse. With Python, it's like a beautiful six-speed manumatic. Mmmmhm. :)

I don't just like two things about Python, but those are my two favorite. It's easier to run a simple program (because it doesn't require compiling) and it's more fun to just play around with in general. (The matrix calculator I made in Python was SO much more fun to make than in C++.)

But both languages have a purpose and for the most part, both serve their purpose well. It's up to the developer to decide when to use each language and for what.

Next Post Previous Post