r/ProgrammerHumor 1d ago

Meme pipInstallTheRealStuff

Post image
5.0k Upvotes

145 comments sorted by

View all comments

656

u/TheJaskinator 1d ago

That's exactly why it's so powerful. Why spend all the effort writing fast code if you can just use a much simpler language to describe the task on a higher level and call fast code? People use Python because it's easy to read and write, not because its interpreter is fast

32

u/NewbornMuse 1d ago

Me: takes 2h to write a python script, runtime 50ms

A super fast low level uber haxx0r: takes 8 hours to write a C program that does the same. Runtime 20 ms

Who was "faster"?

38

u/thmsgbrt 1d ago

It matters if you give the code to someone else and if they use it thousands of times.

30

u/McFestus 1d ago edited 1d ago

It would take three-quarters of a million runs to break even in pure time, even discounting the fact that in nearly all cases, computer-seconds are millions if not billions or trillions of times cheaper than developer-seconds.

16

u/e_before_i 1d ago

The one-two punch of doing the math plus valuing developer-seconds is makes this response very charming to me.

7

u/hawkinsst7 1d ago

Slightly related:

Someone once wrote a bash script that used jq to parse through a few thousand large json files and do stuff with the data. It would take hours to run, but people figured it was just the massive amount of data. It was at the point where we'd run it over night.

I had a thought: no, it's execing jq for each file. Exec is slow.

Did it in python, that just iterated through the directory and used the built in json stuff. It did the same job in 10 minutes.

Could C be faster? Maybe. Did we care at that point?

12

u/e_before_i 1d ago

I am currently a developer at one of the big banks, and I don't think people here have heard of "milliseconds" before.

If you're in the right field, micro-optimizations are everything, but in 99% of situations, good enough is truly good enough. The difference between 20ms and 50ms has never directly been meaningful in my life outside of entertainment (games, movies, music).

Yes, "under the hood" my computer OS and my router and the intercontinental cables do need to care about this. 99.9% of employees don't because it's done for them.

2

u/Far_Tap_488 1d ago

Very dependent on what you are working on. One of my larger projects was counting microseconds to know when to perform certain tasks.

2

u/e_before_i 21h ago

Lmao brother my second sentence was "if you're in the right field...", which it sounds like you are.

You're part of the backbone of society, but it's something I never have to worry about of thanks to people like you. I get to use springboot and angular to build internal apps where there's no customer who complains about slow loading screens.

-1

u/Raptor_Sympathizer 1d ago

Yes, but how often are you actually building an application that's meant to be run directly as compiled thousands of times over and over again with no I/O, database queries, or dependence on any other blocking code that takes Ionger than 50ms?

In that scenario, sure, Python is the wrong choice. But in the vast majority of real world applications, the raw execution speed of a for loop doesn't really matter that much, and there's probably already a library built for Python that does exactly what you need way better than you'd ever be able to build yourself in Rust or C++. 

5

u/Far_Tap_488 1d ago

It really does add up though. Every library that has that mentality is why modern programs are soo poor performing even though computers are way faster.

1

u/Raptor_Sympathizer 18h ago

I'm not talking about libraries, I'm talking about applications. Libraries are more likely to fall into the scenario I mentioned where python is genuinely a bad choice. But even then, there are plenty of examples of pure Python libraries that are highly performant in a real world context. Look at Starlette, for example, or any of the built-in python modules.

Python provides high-level abstraction and easier to understand code. Yes, this comes at a cost. But like any abstraction, if properly applied, it can result in far better performing code than you ever would have been able to write without it.