Sunday, December 14, 2008

Python: Programming made easy

A pair of years ago I tested this programming language called Python, in honor of Monty Python. It's an easy to learn language, in fact the easiness is part of the design, but in this case easy doesn't mean lack of power. Some months ago I developed a little program for a friend, and decided to give Python another go. It didn't let me down.

It's not a compilable language, it's interpreted, but now days, with the amount of power we have under the hood in our computers, this distinction looses sense, at least in most cases. The advantage of a compiled language is it's compact size and it's speed, but in most cases, for programs made for ourselves, that distinction loses it's effect.

Interpreted languages advantages are mostly concentrated in one point: development speed. There are other advantages, but this one is usually the selling point. Of course, it doesn't hurt that they are usually easier to port to other operating systems.

To modify a compiled program, we need to modify the source code, recompile it (complete or partial recompile) and then execute it. If we need to test it step by step, we'll need to recompile it to add the necessary debugger links, which generates a heavier program, and then run the debugger. Once the problem is found, we need to correct the source code and recompile. Even if we notice the problem was in the dataset used for testing, we need to recompile it to get an unbloated executable.

In an interpreted program, the source code is the program, and the interpreting is handled at runtime. If there's some error, we modify the source code and execute again. Debugging is usually done with the same interpreter and the same program, executing the source code step by step. This results in really smaller times between modification and modification, speeding development times a lot.

To this general advantages of interpreted languages Python adds an interactive command interpreter, where we can test commands and see the results instantly, which is really helpful to learn the language. Python can be used to make procedural, functional or object oriented code.A nice perk is that everything in the language is an object, so we get a lot of predefined function like methods with every variable we create.

Python syntax is really clear, and the fact that we have to indent the code for it to use loops and conditions adds even more legibility. Contrary to popular belief, indenting in Python is not burdensome, it comes naturally after as little as half an hour into the learning process.

Lastly, the language itself is open source, meaning that those with the knowledge can modify it, and that you don't need to pay any license to use it. Even more, the programs we develop with it can have any license we want.

With the new Python 3.0 out there, it's a good time to jump on and learn, as a lot of people are doing it right now to see if it suits them so there'll be a lot of people you can ask for guidance.

No comments: