Why do I hate python

Some people who know me, might have noticed that I am not really a big fan of python. To prevent myself from repeating the reasons why over and over again, I will try to summarize it here.

How I see python

I can’t really say that I hate python that much as long as it is being used as a scripting language, because that is IMHO what python is. Just like bourne shell can be useful to implement simple scripts, while it’s definitely not a best choice, for example to write some server application (not that it wouldn’t be possible), python is also useful tool when someone needs to write a simple script in order to automate some stuff. It however, isn’t really a best choice for large solutions, which many people use it for these days (such as GUI applications, large projects etc). I will try to explain why bellow:

Interpreted language

Python is an interpreted language, that means it requires interpretor for it to run. That brings several disadvantages:

* It is slow

At least for some tasks it will always be slower than compiled binaries. Even for simplest “hello world” you will need to load a number of libraries and python executable just so that it reads your script from storage, parse it (compile if you like), evaluate and process. That requires a huge number of cpu instructions which will always be overhead.

* It eats a lot of memory

Again, you need to load lot of stuff you wouldn’t need for binary + python comes with Garbage Collector (useful for programmers – they don’t have to deal with memory management) which naturally causes programmers to often write a shitty code (let me explain this: imagine you are writing a code in c++, you allocate memory for some object, then you no longer need it, but even if you don’t intend to, you still hold reference to it somewhere, and you even access it. That will crash your application because when you delete it, this reference will point to invalid memory, so your application crashes right away and you know you have a problem and you fix it, however if you are working with garbage collectors, it will know you are holding a reference, so that it will not delete the memory and your application will just silently leak memory, you will have problem, you will likely not find it out and your application will suck). Also it seems to me that python handles memory pretty poorly because even very simple objects need to consume far more operating memory than they would need in other languages. For example, every single variable in python is an object which needs to contain information about its type, because it’s dynamically typed language, which requires more memory than in any static typed language.

* It brings more dependecies

Every system you want to run the application on, requires the interpretor. While many linux distributions come with python, Microsoft windows and most of UNIX platforms (HP-UX, AIX, Solaris) do not. For all of them, you need to install python.

* It makes it harder to identify your process

Because in fact you never have a process of your own. It will be python’s executable that will run. So tools like killall will just not work.

This all applies to all interpreted language, not just python, that’s why I don’t like any interpreted language to be used for large solutions

Syntax

Is most ugly syntax I have every seen for a programming language, seriously, even brain-fuck looks better to me. But this is very personal opinion, many people feel opposite about it.

I don’t like that python forces you to use specific indentations, other languages that use brackets give programmers more freedom. They can choose style they like. In python everyone must use same style, like in some totalitarian fashion.

The way how classes are defined is absolutely un-failsafe and probably causes heavy troubles to many programmers.

The syntax itself is full of various restrictions and writing anything in python makes me feel like if I was moving in a mud. I basically have to be careful about every space, bracket and colon because in python it may have some special meaning, different than somewhere else in source.

It’s nothing new

There are many interpreted languages out there, which are IMHO even better and better supported, like perl. I don’t know why people still need something new, when we already have that and it works.

No static typing

Python is strong typed, which takes away the freedom you should have, but dynamically typed which gives you the freedom where you shouldn’t have it, that means you do not declare what types are you working with statically in machine code, but it’s dynamically decided during runtime. While this may seem to be a good thing to some beginner programmers (they can declare variable x and assign any object to it), it’s pain in ass for more experienced ones. So I have this code:

# x didn’t exist so far
x = a + b;

Now tell me what the hell these variables are? I don’t even know from the code if I am declaring x here, or assigning to it. In order to find out answer to what type a and b are, and if x is being created or assigned, I have to browse through possibly huge source. That really makes things hard.

def foo(bar):
# now 400 lines of source code follow

Tell me, what type is “bar” and what type does it return? Hm, maybe I will just have to read these 400 lines of code to figure out…




No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *