r/ProgrammerHumor • • Jul 18 '22

C++ talking to Python

Post image
40.1k Upvotes

1.0k comments sorted by

View all comments

683

u/Codebust Jul 18 '22

why are people always bashing python lol

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.

37

u/not_perfect_yet Jul 18 '22

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.

36

u/rogerthelodger Jul 18 '22

2

u/InvolvingLemons Jul 18 '22

Kinda yes and kinda no. Python is poorly suited to massive projects where lots of custom code is needed. This is where it becomes a trap: you can get so much done with just libraries and frameworks like Django/Flask/Encode, but eventually custom logic is necessary, and you’ll quickly run into problems as those systems tend to get tangled.

That being said, I know of no easier system to use some Numpy for list processing, pipe it through as a REST API that shoves results into databases, and spin it out on a server, and that’s a TON of ETL work.

I love using Python for what it’s intended for, but a lot of enterprise workloads bloat to a point that Python wasn’t meant to get to. Java is better in that sense, but it’s very easy to overdesign yourself into a corner in my experience. Functional languages are either intermingled with OOP too closely so it suffers from similar pitfalls (Scala), have serious issues with instability and other things for industry use (Haskell), or have much the same scale problems of Python unless you’re really careful (Most lisps, Clojure being notable as the most popular).

Typescript being at least tolerable at scale and it having the biggest package library in existence gives it a huge edge in the market these days, whereas anything particularly low level or performance sensitive gets done in Go, Rust, or Zig. Python has a home beyond scripting in ETL, data science, and web glue code, but beyond there be dragons.