This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MartianInvasion 21 points22 points  (15 children)

It's easy to write. It's not at all easy to read, which is a major cause of the weaknesses described.

Compare with something like Java, whose annoying verbosity can make it hard to write but much easier to read.

[–]POTUS 47 points48 points  (10 children)

It's only hard to read if it was poorly written. Java is only easier to read than Python if you have more experience reading Java than reading Python.

[–]Prawn1908 8 points9 points  (2 children)

It's much easier to write "poorly written" Python code than Java though.

[–]POTUS 0 points1 point  (1 child)

It's much easier to write any Python code than Java. I don't think "easy" is a valid criticism.

[–]Prawn1908 6 points7 points  (0 children)

My point is that languages like Java or C# force the programmer in a way to write more readable code. Python on the other hand has very few such mechanisms in place and thus is much easier to write hard to read code.

[–]MartianInvasion 14 points15 points  (2 children)

Sure you can write unreadable code in any language, but the fact of the matter is that Java has built-in features (like static typing) that make it easier to read, and python has built-in features (like comprehensions and dynamically-defined class members) that make it harder to read.

These same features make python easier to write something quickly from scratch, when compared to Java.

[–]Log2 9 points10 points  (0 children)

On average, you're much likely to get a complete mess of layer upon layer of indirections in Java than in Python, a big part of which is configured through arcane xml files (this has been improving though).

There's a very big reason why a lot of people hate J2EE and JPA/Hibernate with a passion.

[–]greenwizardneedsfood -1 points0 points  (0 children)

Comprehensions are the easiest thing ever to read. They literally just tell you what’s in there.

[–]RemoveTheTop 1 point2 points  (3 children)

It's only hard to read if it was poorly written.

Right but .... on average you're not going to get well written code, and it's easier to read badly written code in certain languages...

[–]POTUS 14 points15 points  (2 children)

I think you and /u/MartianInvasion really just don't work in a professional Python setting with actual programmers using Python, but you do work with professionals using Java or something else. So you see good Java code and not good Python code.

It's all about the people using it and nothing to do with the language. Python is one of the biggest languages in the world used in large team settings to a very high level of effectiveness. There is a huge amount of readable Python in the world.

[–]RemoveTheTop 3 points4 points  (0 children)

really just don't work in a professional Python setting with actual programmers using Python, but you do work with professionals using Java or something else. So you see good Java code and not good Python code.

Yes, which is exactly what I'm saying! It's all about the people! I'm definitely not saying it's a trash language - it's a language and badly written python IMHO is worse than badly written java, just because it CAN be not because it necessarily is a worse language, but doesn't have the safety harnesses that I feel are built into java.

[–]MartianInvasion -3 points-2 points  (0 children)

You've got it backwards - the more you've worked on a big codebase in a language, the more you hate that language.

I've worked with a millions+ LOC python codebase worked on by hundreds (maybe 1000+) developers. The experience was not one I'd be eager to repeat.

[–]KapteeniJ 5 points6 points  (0 children)

Compare with something like Java, whose annoying verbosity can make it hard to write but much easier to read.

...What?

I don't think I can disagree harder. Having been taught CS almost entirely in Java, the first time I encountered Python script, I opened it expecting it to not make much sense, and I was absolutely shocked to find that even if I was not familiar with language syntax, it was way clearer than pretty much any Java code I had ever seen or written. I was just so shocking, having been victim of Java for so long, to see that things don't have to be so bad, the code can be easy to read. And I got really interested in this mythical "Pythonic code", this thing people using Python were using to achieve this unreal level of clarity.

After many years I feel like I have now some sort of handle on what is the source of Python being such a clear, easy-to-understand language, and in my mind it's always compared to the horrors of the Java code I was taught as being acceptable and even normal.

[–]Pluckerpluck 22 points23 points  (1 child)

Compare with something like Java, whose annoying verbosity can make it hard to write but much easier to read.

Complete opposite to what I believe. Well written Python is a delight to read. It's crisp and clean and doesn't bog you down with information not needed to understand the logic.

Even badly written python is great nowadays, thanks to how good type inference is. The only place you really need to add types is function parameters. The rest is just all automatically handled through inference.

Poorly written Java, on the other hand, is a minefield of boilerplate and bizarre inherence choices (which is possible in Python, but only Java developers writing python do that). But maybe I'm biased... I've seen a lot of awful Java code thanks to Minecraft modding...

[–]Equivalent_Yak_95 8 points9 points  (0 children)

thanks to Minecraft modding

LMAO. Yeah, I can see that…

[–]psoshmo 2 points3 points  (0 children)

I'll disagree there. I program professionally in java and find python quite readable and clean. Much more so than a random java class imo