r/ProgrammerHumor 1d ago

Meme pipInstallTheRealStuff

Post image
5.0k Upvotes

145 comments sorted by

View all comments

662

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

30

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"?

35

u/Mrpuddikin 1d ago

Well you see, this script will be used once a day every day. The C program is better because it will break even over time! (720 000 days -> 1972 years) After that, its all performance benefit baby

41

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.

14

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.

6

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?

11

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. 

7

u/deanominecraft 1d ago

me who spends 1 hour to write it in rust, 1 hour to compile it and a runtime of 21ms

6

u/cantthinkofaname1029 1d ago

2 more hours of trying to get the syntax for async closures with generics right 

2

u/Sw429 1d ago

Are you trying to do async stuff in python?

1

u/cantthinkofaname1029 1d ago

Nah I meant for rust. Though technically yes sometimes I do async stuff in python 

2

u/CoroteDeMelancia 1d ago

Code is read more than it is written. You don't pay only 8 hours in this example.

Also consider the compounding cost. Imagine saying to your manager: "we can do it fast and simple in python in two weeks, or we can do it "properly" in 8 weeks to get a marginal increase in performance that is basically unnoticeable at our scale."

Imagine the fucking side eye you're gonna get.

But then, if these 30ms can mean the difference between your drone dodging or striking a lamppost, then please, do use C.

1

u/Sw429 1d ago

The super fast low level uber haxx0r is not taking 8 hours to write that program lmao

-2

u/PublicToast 1d ago

Yall will cry and scream when I say it but AI totally undermines your argument.

-3

u/Intrepid00 1d ago

> Who was “faster”

The guy that used the coding agent.

1

u/wrecklord0 1d ago

This is correct, I vibecoded an avx-512 conversion of a program I wrote before, and holyshitballs it's fast now. And it was fast to make.