Why Python rocks


After writting the article Why Java rocks, I have no other option than writting why Python rocks.

Before starting, I might advise you that Python is my favourite language. And this is like search your best friends defects.

Python Rocks

Dynamic typing

Opposite to people's opinion, Python is strongly typed. But it is dynamically typed also. You cannot modify the type of a variable, but you can reuse the same variable to point to... another thing.

Dynamic inheritance

In addition, it follows the duck typing principle: "If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck". This simplifies the inheritance management, because it is not necessary to inherit from anything. If only it has the required methods implemented, then it matches the interface. That's all.

Objects are first class citizens

What means that any object can be used as a parameter of any method.

Everything is an object

Whatever: basic types, a method, a class... Everything is an object. If you mix this with the previous feature, everything can be used as a parameter of a function. Or can be stored in a variable, an array, a hash, ...

Hashes and arrays are built-ins

You can instanciate a hash or an array directly, without any reserved words or difficult API structures.

Wide API

Standard Python has everything you can need, since command line managers to web servers, passing over threads management, configuration files management, XML readers, other language parsers, TK graphical interfaces,... whatever you want.

Command line interpreter

The command line interpreter is a marvel. Even more if you use any interpreter with steroids, like ipython or bpython.

Zip support built-in

Zip support is native. You can store anything in a zip and try to execute it with python, and it will look for the file __main__.py.

Structured

As far as it is strongly indented, document indentation should be perfectly readable.

Expected and homogeneous

When you are a newbie in the language and you learn the basic functionality, whatever you want to do you know how. This is because it is homogeneous, and everything is executed in the most expected way.

Usually there is only a right way to do things. If you try another way, it would be more hard (until you realize of it).

Web oriented

From its base. And there are a load of platforms to develop for the web.

Properties

Forgive getters/setters. That is not pythonic. In python we use public vars. If you want to modify its usage afterwards, it is enough to upgrade them to properties, but its external usage will be the same.

Public

Everything is public. The only private things are by convention, so they are accesible too.

Small

Whatever you want to do is small. Since the own compiler and interpreter that requires about 20 Mb. Everything is easy with Python.

Fast

Speedy. So in its execution as in its development.

Python do not rocks

Global Interpreter Lock (GIL)

It is a mutex that avoids that several Python threads may be executed simultaneously. This can cause horrible performance problems and, what is more, it cannot take advantage of all system resources: multiprocess systems are strongly limited.

Network library

Standard Python has a network library too complex and few pythonic in its API. Fortunatelly, we have GEvent library and requests library, that solve the proble, but they are out of standard API.

Package systems

Despite all Python advantages, the package system is depresing: easy_install is not so "easy", and there are problems to retrieve a fixed version of a package. There are some more problems, but I think that it is enough with what I said.

Update: now we have pip that seems to be easy to use and looks like the standard package management system.

The hateful self var

Usually it is hateful to explicitly pass the self variable as first parameter for every method. But this feature allows you to use several oparations that are uglier in other languages or, they cannot be used at all.

Indented!

A lot of people finds the strongly type as a problems. It is a mixed bag for me. Globally I like it, but I have to admit that it is a disadvantage some times.

There is no IDE

It is quite difficult to build an IDE for a language which can modify its methods in run time. But there are some of them good enough. Despite of them, I use my lovely Emacs.

Good for scripts but nothing more

Somple people argue that, but I do not think so. I think that BitBucket is made with Python, and Google uses it too.

Method overload

Along it is not typed, it is impossible to manage method overload. But it has an easy default valuated system for parameters that is versatile enouth.

End

There are a lot of reasons to use Python and very few to not doing it. It is so beautiful!


Comentarios

Comments powered by Disqus