r/ProgrammerHumor 3d ago

Meme boomerBummer

Post image
2.1k Upvotes

98 comments sorted by

345

u/navetzz 3d ago

The largest in size this data structure will ever get is 12.

138

u/FUTURE10S 3d ago

A genuinely good reason to be O(n2 ) tbh, naive and fast on tiny data structures beats out intelligent but with a lot of setup

54

u/Terroractly 3d ago

Yeah there's a lot of algorithms that have a relatively high amount of fixed cost compared to simpler and technically slower algorithms.

For instance one algorithm may have a runtime of n3 ms but the "superior" one has a runtime of (n2 + 1000)ms.

In this case the naive approach will be faster for any n<=10

-45

u/Superb_Chemistry_906 3d ago

My self diagnosed OCD would not let me do it even in that case.

37

u/potatopierogie 3d ago

After 200 hours of work you get it down to O(n1.9 )

-38

u/Superb_Chemistry_906 3d ago edited 3d ago

You ever heard of nlogn? That's the basic cliche. Your "joke" is absurd. You seem to lack basic university education.

46

u/Wesstes 3d ago

Something tells me you've only just passed the algorithm analysis class

-33

u/Superb_Chemistry_906 3d ago

What is that "something"?

30

u/potatopierogie 3d ago

You seem overly proud of knowing something literally everyone knows

-19

u/Superb_Chemistry_906 3d ago

Why did you then write that stupid O(n1.9)? Seems like nothing better came to your mind. I have not ever heard of such case. Utterly dumb.

23

u/potatopierogie 3d ago

I have never heard of something. If you have, you're dumb

Bro come on. You not ever hearing of something doesn't make anyone (but you) utterly dumb.

→ More replies (0)

8

u/FUTURE10S 3d ago

Cool, have a nlogn with a flat cost of 1000ns per each element, my n2 with a cost of 10ns per each element and at 12 elements, I'll have 1440ns and you'll have 12950ns.

-2

u/Superb_Chemistry_906 2d ago

I think that you just made up that flat cost difference assumption. In reality, it does not work like that, but rather it's about the overhead of the algorithm, while the flat cost is the same. And the claim that the input "will never be more than 12 items" is a typical one at the beginning of poorly optimized systems.

8

u/Furyful_Fawful 2d ago

Merge sort is O(n log n), and it has a large flat cost associated with allocating O(n) additional space worth of sub-arrays. A naive implementation of merge sort would easily hit the flat cost as specified, while naive n2 algorithms often rely on swap operations that are easily optimizeable by the compiler

3

u/Valuable_Leopard_799 3d ago

In that case you can try working on the switching version which checks the properties of it's inputs and chooses whichever is more suitable.

1

u/Superb_Chemistry_906 3d ago

I don't know - I just do not obsess about small inputs - they are small anyway. I think that the cases when optimizing for them is needed are very specific and I maybe even haven't come across them. It could be processing of a lot of small data records, but I haven't done such thing, I think.

44

u/zkwarl 3d ago

I actually hit that in production code once. There was a recursive binary search to find the nearest element in an array of sixteen sorted doubles. Converting to a linear search was about 10X performance gain.

7

u/Neverwish_ 3d ago

Welp, binary search is not supposed to be recursive...

23

u/Glass_Teach_2854 3d ago

Assuming comparisons aren't expensive, Binary search should be slower even if its not recursive for arrays that size. The book keeping will outweight the reduced lookups

10

u/Neverwish_ 3d ago

Yeah, no argument there. I was just pointing out that proper binary search should not be recursive.

13

u/Zeikos 3d ago

I had a data structure that was O(n!), got flack for it when it was impossible - there were guard clauses - for n to be higher than 3.

15

u/evanldixon 3d ago

If it will never be bigger than 12, it could be argued to be O(1). No one ever said how big 1 is after all.

2

u/Vesuvius079 3d ago

And even 1000 would unnoticeable with what the inner loop is doing.

1

u/neoronio20 2d ago

Then N = 12, O(144) == O(1)

1

u/DeltaV-Mzero 3d ago

Could be true if you use the right base

112

u/MayorAg 3d ago

Wouldn’t you un-press the button?

36

u/MRanse 3d ago

There were cases where the turbo button was inversed, so people had different experiences.

38

u/Z3r0funGuy 3d ago

Never experienced this.. the turbo buttons were originally a backwards compatibility feature to play nice with old software that was dependent on slower clock speeds.

-1

u/ArjixGamer 2d ago

That's weird, why would the playstation 2 have a turbo button then? It's a console with a curated list of games.

3

u/Z3r0funGuy 2d ago

I just realized how young you are. We are having a discussion from two completely disparate points of view.
I’m with you, it is a weird word choice. Take it up with the marketing department.
If you really want to understand, look up “486 turbo button” for the history.

1

u/ArjixGamer 2d ago

Regardless of my age, I grew up with old tech.

But not old enough to use VHS tapes or floppy disks. I still have my PSX with 2 controllers and a memory card. But all my DVDs are damaged.

I am 22 btw

1

u/ekauq2000 1d ago

This is the turbo button they’re referring to:

https://en.wikipedia.org/wiki/Turbo_button

1

u/ArjixGamer 1d ago

Oh yeah, I had that on my first pc, never used it.

1

u/ih-shah-may-ehl 23h ago

There were plenty of games that dealt with time and clocks in weird ways. For example the old space quest games, which means that as computers got faster, some things became literally impossible because some in-game timers or counters elapsed in less time than needed to react to on-screen information.

32

u/NullVal 3d ago

What DID those turbo buttons actually do?

58

u/AdBrave2400 3d ago

I thought it was something for compatibility like for example games that would run at wrong speeds. Is that right?

15

u/LuigiWasRight447 3d ago

Yes that is correct

3

u/rnzz 3d ago

for me it was to help me get past some levels on Moon Bugs, Jaybird, etc

36

u/El_Mojo42 3d ago

It was actually to reduce the clock speed for compatibility reasons. Turbo was the normal speed. 

2

u/Nebula_Wolf7 3d ago

This, because the physics and other graphics were tied to the frame rate, reducing the clock speed made older games run normally

6

u/LuigiWasRight447 3d ago

It increased the cpu clock speed because for video games the speed of the game was tied to the framerate for the longest time and even to this day youll sometimes see games like that on consoles. Like the physics engine in fallout for example. So if youre game was running to slow turn on turbo. Too fast? Turn it off.

17

u/KawaiiMaxine 3d ago

It actually reduced the clockspeed to a specific common speed for compatibly

2

u/Xlxlredditor 3d ago edited 2d ago

To the crisp 4.77Mhz of the original 8088 of the IBM PC!

Edit: thanks u/JustSomeRandomCake fire the additional 770 kilohertz

1

u/JustSomeRandomCake 3d ago

4.77!

1

u/Xlxlredditor 2d ago

Shit I forgot 770 kilohertz, edited

1

u/LuigiWasRight447 3d ago

Oh i guess i got it backwards. That makes sense though. Im a little to young to have ever used one of those pcs so im just going off what ive heard

2

u/G3nghisKang 3d ago

for the longest time

Shit PC ports will still slow down when the framerate gets too low

3

u/Attileusz 3d ago

Tying framerate to simulation rate has advantages like everything being deterministic, if you press a button on frame n you'll get the same frame n+1 visually no matter the framerate. In this configuration you gotta cap the framerate or interpolate two frames (but this causes visuals to have a 1 frame latency over gamestate, this may or may not be fine for some games). It's a perfectly valid way to make a game IF your game is known to be optimised enough to run at at least simulation speed on supported hardware.

I'm not talking about tying time to clock cycles here, that's a dead paradime. We simply yield to the operating system and request that it schedules the program again when the next simulation tick needs to be computed and/or when the next frame needs to be drawn (usually called sleeping).

1

u/LawfulnessDue5449 3d ago

Turns on a machine that takes the exhaust air to spin a turbine that will compress air on the other side

-4

u/zomreddit 3d ago

I think placebo effect

4

u/4Floaters 3d ago

You weren't supposed to hold it down it was for quick boosts - joke

According to Wikipedia the turbo button allowed the computer slower for compatibility with older applications

65

u/sebjapon 3d ago

When I was in a Master course, my professor just told me: who cares about speed, Moore’s law will do that work for us.

So the answer is: wait 2 years, buy a new CPU/GPU and it will run faster

36

u/Superb_Chemistry_906 3d ago

I think Moore's law has been dead for some time - the main way to increase performance is just put more watts into it.

21

u/sebjapon 3d ago

Yeah my story is 15 years old though. At that time it made sense

3

u/GenericFatGuy 3d ago

And now we have a bunch of devs who don't know how to optimize.

2

u/Superb_Chemistry_906 3d ago

But even then, this story gives an answer to why, no matter how much faster HW got, the desktop experience was always a bit laggy, with another reason being the never ending urge to fill the performance potential with needless animations and effects.

2

u/remy_porter 3d ago

The thing is, most of those animations and effects are pretty cheap computationally. Especially in the era of GPUs.

2

u/Superb_Chemistry_906 3d ago edited 3d ago

Under this pretense, they are added up to conveniently cancel out any HW advances in order to keep computers annoying.

2

u/remy_porter 3d ago

Except that’s just not true, is my point. Those animations are actually very cheap to render. They can make the system feel slower when they’re badly done, not because it actually hurts performance but because nobody wants to wait for your animation to finish.

1

u/Superb_Chemistry_906 3d ago

I have animations turned off and even then, when the system is somehow strained, it even takes some time for a window to get focus after a click. So every little thing adds up. And of course, animations are long and annoying, I agree.

3

u/remy_porter 3d ago

That sorta makes my point: it’s not the animations that are causing performance issues.

1

u/Superb_Chemistry_906 3d ago

In the case of the strained system, animations make it even worse: they add more strain and turn even slower and more glitchier, making the PC experience even more annoying - so they are just pointless flashy thing which kick you in the ass in the hardest times.

6

u/whackylabs 3d ago

My professor also told me: Ontogeny Recapitulates Phylogeny. So every time a new hardware system comes to life you need to start thinking in machine cycles all over again.

5

u/FUTURE10S 3d ago

Throwing hardware at a software problem, a tale as old as time itself (and ngl it works pretty well)

2

u/zomreddit 3d ago

I glued another Turbo button to the existing button and quadrupled the speed!

2

u/Arclite83 3d ago

I've enjoyed watching us "top out" though, first on single processors and embracing threading, then on nm size getting to the point where "gold atoms are too big".

The high precision machines needed to make high end and quantum processing chips to the molecular precision they require are marvels of technology just themselves.

1

u/HungryCaterpillers 3d ago

How long ago was that? Because even when I was in college, we had already approached the limit of Moore's law.

13

u/2204happy 3d ago

Real ones know that the turbo button actually makes the CPU run slower.

9

u/floatinggoateyeball 3d ago

decreasing N, obviously

8

u/pabloramon044 3d ago

The turbo button that slows it down?

10

u/GrandDukeNotaras 3d ago

So it runs in O(zzzzzztututututu) time 

5

u/stupled 3d ago

So much nostalgia.

4

u/glx0711 3d ago

I just reduce delay_ms(8); to delay_ms(5);.
To still have some room for improvement.

4

u/RarerGiraffe 3d ago

If it works don't fix it. If it doesn't work don't tell me.

3

u/_Repeats_ 3d ago

I would profile the entire application and see if this algorithm was a hotspot. If not, move on to the next ticket.

3

u/stormbringerelric77 3d ago

For real though, what did the turbo button actually do? And why wouldn't you want it on all the time?

12

u/synchrosyn 3d ago

Old games used the clock speed of the computer to determine certain things like enemy movement (move on every tick). But the Devs didn't account for newer CPUs having different clock speeds so the timing was completely wrong and games would act erratic. 

The turbo button actually slowed the clock speed to match the previous generation thus making games work again. 

You pressed it only when playing games because otherwise your entire system is slowed down. 

1

u/ArjixGamer 2d ago

Uhh, why would it be called turbo then?

Turbo implies it makes it faster, not slower.

Also, I remember my Playstation 2 controller had a turbo button.

1

u/synchrosyn 2d ago

It is a marketing thing. It was called turbo so that people actually would press it. If they called it the "nerf" button nobody would ever press it even if they needed it.

Turbo also implies "only use it when necessary". The standard user would not understand why they need to slow their computer or use some sort of compatibility mode. The idea is that a standard user would think is "games need more power, let me press the turbo button, but I shouldn't waste my turbo otherwise". Or "oh I left turbo on, it is too much power for my other apps, I should turn it off". So people did the right thing, even if it was for the wrong reason.

The turbo button on your PS2 controller is a completely different concept and surely was a 3rd party controller. It lets you hold a button and it would button mash it for you, it had nothing to do with the system or performance.

1

u/ArjixGamer 2d ago

Now that you say it, yeah it might have been a 3rd party controller.

1

u/slaymaker1907 3d ago

Easy, we’ll keep the inputs small

1

u/BenadrylTumblercatch 3d ago

Change the rgb to blue and the wavelength of the code will be shorter

1

u/Vesuvius079 3d ago

It works ok.  I don’t need to make it faster then.

1

u/GoddammitDontShootMe 3d ago

I thought I heard pressing it in actually made your computer slower.

1

u/wu-not-furry 2d ago

Scratch programmers be like

1

u/WeirdTie2290 2d ago

Software architects nowadays scale horizontally. Add 4x the hardware for 50% overall performance gain.

1

u/iyamegg 2d ago

The 'DLSS will make it playable' argument backported to ye olde times.

1

u/ofnuts 1d ago

Would also replace the SX proc by the DX version.

1

u/Mr_DeWitt_ 23h ago

The Turbo button was designed to slow down the CPU rather than increase its speed.

1

u/Balahawka 22h ago

Turn it into O(2n) because bigger number better

0

u/seyy02 3d ago

I honestly thought the turbo button made it faster though 😂

0

u/danf10 3d ago

Can confirm. Had a PC with a turbo button, and it indeed made it faster.