x things I hate about python
So I just realised that both the applications I've demonstrated here have been in python. This makes me laugh, because these I think are the first two python applications I've built (I've modified plenty of python before, but never started a python project). So I'll be clear and say that this isn't a place where I use python for everything. So then, on to the python bashing:
- Built in functions - I don't care if they are named sanely, there are too many of these (
len(dir(__builtins__)) == 134), and I won't remember them. These functions don't look anything like the basis set of vectors I would use for describing every program. Obviously the language designers didn't view things the same way as me, and that is cool, but I much prefer a small language. - Recommending spaces for indentation - another popular holy war. But using spaces for indentation is wrong. If I'm viewing code, I want to choose how much indentation there is (in fact, on my widescreen laptop, I use 4 spaces but on this desktop I use 3 spaces - and at work I think I use 2). I disagree about mixing tabs and spaces also. Spaces should be used for alignment, and tabs for indentation. They have different purposes, so they shouldn't be mutually exclusive (for example, alignment of a multi-line condition should be done with spaces). Finally, if I'm wrong, then it is much easier to convert from tabs to spaces than from spaces to tabs (and one of my internal heuristics says that this means that tabs are right).
- Ugliness. After reading the start of any python tutorial, you will think that python is a nice looking language. Then you get the the section on classes, and are greeted by functions like
__init__, or is that_init_or___init___- fortunately everyone writes code in a monospace font. But I'm still struggling to come up with a reason why we needed these extra__at the end. Why not just__init? (or just say what you mean:def private init(self):. Which then exposes another ugliness which I'm sure people have complained about before - the "self" parameter. Unless I'm missing something, it could be made a keyword, and then we wouldn't have to include this parameter in every method. - Anonymous functions suck. Simple functions are fine
inc = lambda x: x+1, not so simple functions aren't:factorial = lambda n: reduce(lambda x,y: x*y, xrange(1, n+1), 1),isprime = lambda n: itIsEasierToJustWriteANamedFunctionAndCallItHere(n). Maybe this whole restriction of having a one-liner for an anonymous function was a design decision, because any function more than 1 line long should have a name. I think that this should be the programmer's judgement call, not the language's. - (Just because the documentation is in front of me): The function
raw_inputgives you the raw input... minus the newline. - Most of my python experience was in a situation where a debug cycle took about 30 seconds. I don't care that you can make a .pyc file that has abs("string") represented in it, that doesn't help me.
- The fate of reduce(). Well, I suppose my previous point about anonymous functions is being taken care of... by getting rid of them. How about getting rid of anonymous integer literals too? Sure, it would prevent you from finding code with magic number sprinkled all over the place with no indication about where they came from, but I'd love to see your "using python as a calculator" tutorial after the change. Why do people hate functions?
There are other things that irk me about it, generally the typing situation annoys me the most, then the whitespace, then the anger towards functional programming. I don't think it is going away, and I'll probably keep on using it because it has lots of good libraries for it. But I'll never be happy about it, and it looks like things are only going to get worse, since these seem to be things where I have different opinions to the language designer, not just because these things were oversights.

RSS