views:

565

answers:

11
+4  Q: 

Python Critique

Hi,

I'm using Python now for about two months, and to be honest, it really made me love programming again. After programming in C, Java, and worst of all, C++, Python is incredibly fun. Thinking that I approach such language with all positive bias, I would love to hear some critique of Python language. Beside its extremely rich library, superb readability, builtin support for arbitrary size integers, etc. what are the negative features of Python? It is slow, naturally, for its interpreted nature. But how about language design, what parts are designed bad? And what major features the language lacks?

Please make your critiques around the core of Python. I mean, it is a scripting language so saying that "it shouldn't be a scripting language" is not much relevant, in my opinion. Instead, for example, please focus on how as a scripting language, it is inadequate.

I believe some critique and brainstorming would be fabulous for me to evaluate Python objectively.

Thanks in advance

A: 
  1. Speed comes in mind.
  2. I am not sure if this is a negative point but object oriented programming is very different.
  3. Sometimes due to scripting nature intellisence doesnt work perfectly.

In any case I Love python.

Umair Ahmed
Its dynamic nature, not its scripting nature.
Wahnfrieden
A: 

Minor gripe but significant white-space feels wrong. (As someone who doesn't use python day to day)

John Nolan
That's one of the main selling points of Python, IMHO
Nathan Fellman
@Nathan Fellman - Not in code golf, it isn't.
Chris Lutz
Is white-space really an issue for any "python developer"? I have a feeling this is just a beginner gripe that disappears with usage.BTW - python supports semi-colons if you miss them, and supports #{, #} or #start, #end tags as long as they're on a new line! ;)
monkut
@monkut it probably is a beginneer gripe as I am a beginner
John Nolan
+1  A: 
NicDumZ
This isn't helpful or even relevant.
Wahnfrieden
It could also be considered spam, since these comics are being sold as a book, and it contributes nothing to the discussion.
Wahnfrieden
this question is not very useful. I figured I might as well drop a nice xkcd strip. Since it's "trendy" here. [sarcam, where?]
NicDumZ
A: 

Inner classes could be really inner, and have access to parent class's namespace.

M. Utku ALTINKAYA
+9  A: 

Actually one main issue with CPython implementation is the GIL (Global Interpreter Lock) wich avoid any concurrent multi-threading on a multi-core processor.

This is to be changed thanks to the unladen-swallow project: an optimization branch of CPython, intended to be fully compatible and significantly faster.

Pierre-Jean Coudert
The question is asking about the language, not the implementation, so you're not really giving a useful answer, IMO.
djc
@djc I understand your point of view but usually have to be aware of real implementation gotchas when you choose a language. I alway try to keep in mind the Joel's Law of Leaky Abstractions ( http://www.joelonsoftware.com/articles/LeakyAbstractions.html ).
Pierre-Jean Coudert
The GIL certainly affects the language because you can't have real multithreading and that is something to consider when using threads in Python, for example.
juanjux
A: 

Python has multiple inheritance and some people think that it is evil.

But I don't think so. You can always avoid using it.

I love Python more than anything else. It rocks.

TheMachineCharmer
A: 

I'm still learning Python, and my first language was Perl, so take my opinions with however much salt you like.

One of my biggest gripes about Python is the syntax. Triple-quoted strings seem like a syntax-decision from my nightmares (or a David Lynch movie - same thing, right?), and double-underscores seem appropriate to me in C, but not in a language that provides list comprehensions. There has to be a better way to mark certain features as internal or special than just calling it __feature__.

Another gripe of mine is the immutability of strings. Why do I need to write var = func(var) to do a simple search-and-replace?

Another minor gripe is that functions require parenthesis around their arguments, even when not syntactically ambiguous, but at that point I might as well just go back to Perl.

Chris Lutz
+1 for dunder, -1 for Triple-quoted strings, sp +0 or is it -0
Anurag Uniyal
Are you on a one's-complement machine, Anurag?
Chris Lutz
Triple-quoted strings are great, save a lot of escaping. And a real plus of Python is its consistant syntax and module library (mysql_real_escape_string anyone?), so requiring parentheses cannot be considered a negative.
Ölbaum
@Olbaum - I much prefer Perl's here-doc string syntax to Python's triple-quoted strings. Alternatively, you could just allow strings to span multiple lines. I don't consider the required parentheses a negative, I just don't like them. It's a personal thing - I consider `print "Hello, world!"` to be _slightly_ cleaner looking than `print("Hello, world!")`, because the former has more whitespace and looks more empty (and more natural) than the latter. But that's entirely subjective. And under no circumstances would I claim that Python is worse than PHP, I promise.
Chris Lutz
You are more or less criticizing Python syntax. That really shouldn't been a critique? No offense, but I don't see how one could not get used to triple quotes. Maybe, if you are in love with some other language (which seems pretty popular these days).
iElectric
I'll give you that syntax is subjective, but any criticism is necessarily subjective. I do also criticize string immutability, which is a major language feature.
Chris Lutz
I don't understand the complaint about the string immutability. They are more or less like that in a lot of languages, C# and Java for example (that they might not be internally is not relevant)
Skurmedel
A: 

Multiple inheritance seems to cause problems whenever it gets used, in my experience. Just don't. I'm sure it seemed like a good idea when it was implemented, and I'm sure some people make use of it without problems. To me, it leads to a world of hurt.

The GIL can lead to scalability issues, depending on what you're doing. For me, that's the most common reason why I decide to switch to another languge, but YMMV.

Everything to do with the double-underscore notation feels like a really ugly hack to me; almost like they've been implemented as afterthoughts. I really hate typing "def __init__" rather than Ruby's "def initialize"; surely Python could have reserved method names such as "initialize" and "destroy"...

That said, I try to use Python, Ruby or Erlang as much as possible these days. They're "fun" languages, whereas others feel too much like work!

monch1962
+4  A: 

I like python, but:

  • No tail recursion optimization (in CPython)
  • Global Interpreter Lock (GIL)
  • Assignments are not expressions
  • Unicode string handling is somewhat awkward
  • Can be hard to deploy as a desktop app due to cross platform issues, language version, etc.
  • self everywhere can make you feel like OO was bolted on, even though it wasn't.
anthony
deploying desktop app just needs a lot of practice, as on any other platfrom.
iElectric
"Assignments are not expressions" That's debatable as a "problem". I've seen too much bad C and C++ programming to agree with this being a problem.
S.Lott
every "problem" is debatable. any feature can be over/misused, but if you come from a c background and assignment as expression feels natural, it's a hurdle when writing python. just like if you come from a functional background, lack of optimized tail recursion is a hurdle. you can cetrainly write great code without either language feature, it's just a matter of acclimation.
anthony
+2  A: 

unicode integration in 2.X. Having u"string" everywhere is ugly, and it's easy to miss handling encoding properly. Some modules expect str instead of unicode, etc...

(Luckily it seems pretty much fixed in 3.X)

monkut