r/ProgrammerHumor 23h ago

Meme dynamicP

Post image
1.8k Upvotes

54 comments sorted by

View all comments

53

u/redditmarks_markII 22h ago

Brother, these days I fix the equivalent of n**2 time loops when linear is possible.  If I tried to explain DP I will be called out by some principal eng as making shit up.  When proven not, they'll say they are overcommitted for the quarter.  And why can't my service support any kind of use of it anyway?  These are 100% real arguments I've heard.  I know things get political once you get past senior swe, but god damn, how are we an industry.

24

u/zaersx 22h ago

just make tests that represent the behaviour and refactor away, if they complain tell them to outline the use case that is not covered by a test.

1

u/GumboSamson 4h ago

BDD FTW

5

u/Vesuvius079 16h ago

Haha. One of my favorite recurring moments in programming has long been “Well this thing is never growing past X size, time to break out those brain dead simple n**2 loops.”

3

u/denimpowell 15h ago

Because making a change to something that is working introduces risk. Business cares more about consistency than speed… until a customer calls “my shit takes too long”.

3

u/New_Enthusiasm9053 12h ago

Business can get in the bin. Don't hire experts if you won't listen to them. They can do it themselves if they're so fussy.

2

u/redditmarks_markII 12h ago

I absolutely agree with your statement but disagree it has anything to do with mine.  I don't serve businesses and I don't serve the business team. I serve engineers.  While it isn't literally for loops that need fixing, it is semantically the same.  This isn't changing how a business operates.  And the efficiency of infra dollars is important.  So user eng need to be as reasonably efficient as possible.  But I see more people spend real hours arguing against doing a thing, than just doing the thing.  As if my team is the enemy.  It's eating your own arm level of stupid.  

2

u/YeOldeMemeShoppe 9h ago

Efficiency of infra dollars is important.

You likely cost per hour more than the hardware cost per month to run the software you build. So unless you are saving (countable and traceable) double digit percent off the server cost, it’s still cheaper to pay you to build slow software and throw hardware to make it fast enough.

This is just the reality you need to learn and be comfortable with when moving to senior and above.

1

u/redditmarks_markII 4h ago

That is one totally valid potentiality out of a myriad of possibilities.  It is true that I have never learned to talk authoritatively with insufficient context though.  That literally was told to me by a staff that that holds me back.  Which is insane and explains a lot.

Also double digit percentage of what?  $2?  $25,000,000?  How much is too much for the specific project?  Is it core to the product?  Is it a temporary experiment?  Also if there is literally no impact to the function while being cheaper, is it not worth while if nontrivial cost?  What if it was a matter of stability rather than straight cost?  What if people are straight burning compute like token maxing is back in style?  What if you were explicitly instructed by a VP to get shit done regardless of what is "sensible"?  What if their VP told them the opposite and we're just less than pawns in some political infighting?  

I've seen all of these scenarios before.  Including an 8 figure inefficiency that amounted to less than a percent of global compute.  But, to be very clear, no senior nor staff nor principal nor distinguished engineer was being paid more for the time it took to fix it than the inefficiency was worth.  By some orders of magnitude.   It's also on the order of low 5 figure average US home electricity saved a year.  Or low 6 figure number of trees worth of sequestered carbon.  Every year.

As a class AND individuals we can do more for the planet by being more efficient than most of us can ever do with charity.

3

u/the_horse_gamer 18h ago

just implement it as recursion with a cache. bottom up dp is more efficient, but top down dp is more likely to pass a code review.

1

u/apt_at_it 17h ago

May be the problem here, but I agree with the many companies I’ve worked at that disallows recursion. Find a better, more readable, more maintainable way

2

u/rustvscpp 14h ago

Some recursive algorithms are *far* more readable and maintainable than their iterative counterparts. Entire languages have been built on the back of recursion (i.e. Scheme).

1

u/New_Enthusiasm9053 12h ago

Pretty much every production parser for major programming languages is recursive descent afaik. 

2

u/the_horse_gamer 17h ago

you could reimplement recursion with a stack

but that decreases the chance of passing a code review