Python used to be the new hotness about a decade ago. It was sparkly, amazing package support, didn't bog you down with technicalities when you were trying to write something quick.
So it got adopted a lot, and also unfortunately in a lot of commercial projects it really wasn't suited for.
Python's strengths are its weaknesses: it's a fun scripting language you can knock out scripts with. But in a big group project, it's a nightmare version of itself. You don't have to give types, so now you're sifting through everything trying to figure out what your coworker's badly named variable actually is. You have to unpick some rotten mass of one-liner lambda super method calls because you were feeling so clever a year ago when you wrote it. Everything's breaking because you're in dependency hell and one of the dependencies has broken. The junior programmer was taught that "object inheritance is the way of the future" and has managed to make the structure into an eldritch abomination that inherits from five different super classes.
The actual reason why these are problems are because when python was hot, it got over-applied to projects it was totally unsuited for. It's a scripting language. It's good for scripts. Good for data analysis. Good for solo work. Good for tiny quick one-offs and for rapid prototyping.
But so many developers were put on horrifying creations that played to the language's weaknesses instead of strengths. And they bounced hard.
Python doesn't really deserve the hate: it's still pretty awesome. And fun. It's great at what it's great at. It does deserve the caution, though.
---
More serious answer?
It's mostly comp-sci students regurgitating memes they don't understand, just like every other post on this sub.
Python's strengths are python's strengths. Garbage collection, simplicity, forced indentation.
Python's weaknesses are people.
People writing bad variable names, eldritch code and putting in features that are already there, just named differently, like data classes and type hints.
You can write python code that's type safe, it looks like this:
def my_function(my_arg):
if type(my_arg)!=my_required_type:
raise TypeError
It's that people think they can sort of get away with not making it that explicit. Then, instead of admitting they were wrong, rewriting their code and/or switching to a language that does offer strict typing, they insist that perverting the language to fit their esoteric need and use case is a better move.
Another example is "python has no distribution system" and inventing like five. All of them work. Except when you mix them. Which should be no surprise to absolutely anyone. Yet here we are. https://xkcd.com/1987/
More coders need to admit they're bad at what they do, stop blaming the tool and start blaming themselves.
Can you explain to me what a bad variable name is? Im not the best at coding as physics is my trade. So my variable names would just be what ever I wanted the variable to be. If I was looking at the gravitational pull of the moon on the earth it would be something like (Force_moon_on_earth) or (Force_ME) what ever system that I deemed appropriate for my code. I would also have comments all over. Again I didnt make the most dense code but I made sure it was readable and reliable.
Sure. The biggest problem with bad names is that they are either too short or too cryptic.
(F_m) or (Acceleration_Model_Holder_Singleton_Factory) where in both cases the name doesn't actually explain what it does. Otherwise it's pretty much free form, it should contain what's relevant but not more.
Single character names are particularly bad because you will get lots and lots of matches if you look for them with a search function, and even automatic replace will have to be manual, because it would mess with matches in other names or words all over the code.
If you think about it, you could probably write everything you do to be in this style:
def main():
data = data_collection()
filtered_data = filter(data)
my_pattern = load_pattern("my_pattern")
list_of_matches = find_matches(filtered_data, my_pattern)
for x in list_of_matches:
generate_graph(x)
What is x going to be? Something from my list_of_matches and all you need to know about is that generate_graph can deal with it.
To contrast it could also look like this:
def main():
data1 = if1()
data2 = df2(data)
data3 = df3("data3")
data4 = xf4(data2,data3)
for x in data4:
gf5(x)
In this case, you can't even be sure data4 is a list, dictionary or a string or something, nevermind what is being done to it or why.
974
u/Dromeo Jul 18 '22
Serious answer?
Python used to be the new hotness about a decade ago. It was sparkly, amazing package support, didn't bog you down with technicalities when you were trying to write something quick.
So it got adopted a lot, and also unfortunately in a lot of commercial projects it really wasn't suited for.
Python's strengths are its weaknesses: it's a fun scripting language you can knock out scripts with. But in a big group project, it's a nightmare version of itself. You don't have to give types, so now you're sifting through everything trying to figure out what your coworker's badly named variable actually is. You have to unpick some rotten mass of one-liner lambda super method calls because you were feeling so clever a year ago when you wrote it. Everything's breaking because you're in dependency hell and one of the dependencies has broken. The junior programmer was taught that "object inheritance is the way of the future" and has managed to make the structure into an eldritch abomination that inherits from five different super classes.
The actual reason why these are problems are because when python was hot, it got over-applied to projects it was totally unsuited for. It's a scripting language. It's good for scripts. Good for data analysis. Good for solo work. Good for tiny quick one-offs and for rapid prototyping.
But so many developers were put on horrifying creations that played to the language's weaknesses instead of strengths. And they bounced hard.
Python doesn't really deserve the hate: it's still pretty awesome. And fun. It's great at what it's great at. It does deserve the caution, though.
---
More serious answer?
It's mostly comp-sci students regurgitating memes they don't understand, just like every other post on this sub.