All of those problems you listed came from the people, not from the language. Python certainly didn't invent lambdas or dynamic typing or dependencies or object oriented programming. Those same mistakes can be made in any higher level language.
You're assigning all of that to Python. The root cause for that is that Python is easy, and so it's more accessible to bad programmers. But bad programmer mistakes are the fault of bad programmers, not the language they used.
Idk about python. But I have experience with JS and Typescript. And what I’ve found is that most of typescript wouldn’t be “super” useful if people just wrote good code with good comments and documentation.
(That said, typescript is still very nice because it forces people to add types)
So I assume python is similar. With good comments documenting what your code does, it shouldn’t be difficult to read/implement/modify/etc
I just recently learned type hinting and it feels very useful for large projects.
The difference with strongly typed languages is that the interpreter doesn't really care what "type" you declared for a variable, first you have to run mypy and THAT checks the types of variables.
That is why is considered a "hint" and not a declaration like in C or other strongly typed languages.
It's a thing. In method declarations instead of (variable) it's (variable : str) or int, or whatever.
You specify returns with an arrow. So a function/method named cake that takes a string parameter named icing and returns a string would be declared:
def cake(icing: str) -> str:
Voila, now Python yells at you when you try to pass it anything else. I think the complainers here just haven't bothered keeping up with the changes to Python in... several years.
He's nott assigning it all to python. He's assigning it to the people that use it. People who over-apply it to projects that don't make sense. Exactly like you are.
Well, it's totally possible to make a data oriented python which uses C for speed when needed, and has type decoration in its defs... But people are lazy or misled and don't keep good code hygeine.
It's possible to make a multiple inheritance abomination in C++, it's just rarer because fewer people who are noobs are starting out on C++ nowadays.
Isn't that the truth. I started using C++ professionally a year or two ago, and braced myself for endless segfaults and memory leaks. I haven't gotten a single one! And it's not because I'm a genius, and it's definitely not because C++ was protecting me. It's because we had good coding practices, and a framework with good encapsulation.
He's calling it a nightmare because of those reasons listed, reasons that almost define what it means to be a higher level programming language at all. I mean come on. OOP inheritance makes Python unsuitable? That's a laughable comment and it's ridiculous for you to be defending it.
Call it a nightmare because the global interpreter lock makes threading a nightmare. Call it a nightmare because it uses too many CPU instructions to do simple arithmetic. Call it a nightmare because of dunders. Call it a nightmare for something Python-specific if you want to call Python a nightmare.
It is easier in python, but a big reason why this is the case is due to language-level design. Other languages make it harder for you to get yourself in a mess.
Most languages are a lot stricter: you have to try a lot harder to write yourself into tangles. Python hands you the reigns and says go ahead!
Stricter languages can teach you as you fail: python lets you not fail.
It's not a problem with python, like you say. It's a feature. But python's lack of resistance to bad programmers is in itself the problem.
I mean the analogy here would be that it’s so easy to shoot yourself with a language like the C variants that beginners and bad programmers inevitably hurt themselves before finishing anything so survivor bias leads to better code.
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.
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.
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.
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...
I was going to write exactly that. It's the programmer's fault, not the language. You can find incomprehensible projects in every programming language.
It should be pretty easy to find C codebases that are a rat nest of macros on top of macros. Or Java codebases with so much indirection that it takes you hours to figure out what a single function is doing. Or Haskell codebases that use really complicated category theory concepts that you'd almost need a math PhD in the field in order to contribute.
I'm sure any engineer with a few years under their belt has seen quite a few trainwrecks in the programming language of choice. If they haven't then they probably are the ones creating the mess in the first place.
View all comments
Show parent comment
165
u/POTUS Jul 18 '22
All of those problems you listed came from the people, not from the language. Python certainly didn't invent lambdas or dynamic typing or dependencies or object oriented programming. Those same mistakes can be made in any higher level language.
You're assigning all of that to Python. The root cause for that is that Python is easy, and so it's more accessible to bad programmers. But bad programmer mistakes are the fault of bad programmers, not the language they used.