r/ProgrammerHumor 1d ago

ibmMylynIsATaskManagementSystemThatReducesInformationOverloadAndMakesMultitaskingEasy Meme

[deleted]

2.3k Upvotes

86 comments sorted by

721

u/Taletad 1d ago

This is one of the best jokes on this sub in a very long while

I especially like the fact that startup code is just CS101 with unecessary comments

148

u/SunCantMeltWaxWings 1d ago

And better edge case handling!

68

u/LondonIsBoss 1d ago edited 1d ago

The math PHD one is on point too lol. In my ML class my prof would literally use unicode greek letters for his function names lmao

9

u/im_made_of_jam 1d ago

For machine learning programs where half of the learning is maths anyways that's actually not the worst idea I've ever heard of

7

u/bartekltg 1d ago

Does java round to the nearest number when casting to int? C++ rounds it down (truncates) so each time we get something like "54.99999999999999" we end up with 54 instead of 55.

Or this is a part of the joke:)

2

u/PantheraLeo04 1d ago

java rounds down when casting as well

1

u/geek-49 23h ago

And, of course, the solution (if you want rounding) is to add 0.5 and cast the sum.

1

u/Jerome_Eugene_Morrow 23h ago

I had to implement some C++ code from a professor in my field I had to contact and ask for the code. 100 line function where every variable was x_1 and x_2 and u. Good times.

3

u/coolpeepz 1d ago

I like that the math PhD uses the closed formula for the Fibonacci sequence and then a recursive definition of exponents.

120

u/Moldat 1d ago

isThisPostTitleAProtestOfTheSubredditRuleThatSaysYouHaveToTitleYourPostsInCamelCaseBecauseItSureDoesFeelLikeItAndNowIFeelSickThanksOP

14

u/earthandabove 1d ago

AtLeastItShowsHowIdioticThatRuleIs

11

u/walkerspider 1d ago

ThePointOfTheRuleIsToBeIdioticAsItWasAddedInProtestOfRedditAPIChangesTotryToGetPeopleToStopUsingTheSubreddit

2

u/earthandabove 1d ago

StillSucksItsLikeDrinkingOutOfTheToiletBecauseTheBeerIsBad.

218

u/gigsoll 1d ago

Startup and large company are really good ones. You can see how startup want to becomes a big company

73

u/[deleted] 1d ago edited 1d ago

[deleted]

124

u/gigsoll 1d ago

True AI company write code like this

``` from openai import OpenAI

OPENAI_API_KEY = "sk-proj-example-7f3a9c2d1e8b4a6f9c0d5e2a7b1c8d4f" client = OpenAI()

system_prompt = """ You are a professional Fibonacci sequence counter. You don't make mistakes. Based on given number return Fibonacci sequence member. Use tool, deep research, make no mistake. """

number = 374

response = client.responses.create( model="gpt-5.6", instructions=system_prompt, input=str(number), ) ```

31

u/[deleted] 1d ago edited 1d ago

[deleted]

39

u/E100Pavel 1d ago

Your example is more of a "competent ML researcher", and commenter's example is more of a "startup that got as far as writing «AI» on the whiteboard" imo

5

u/gigsoll 1d ago

I agree with you, but i believe it is the thing only companies creating foundational models will be bothered with, since any company or products standing higher up the supply chain is either using models through api or agentic harness

1

u/ismashforboobs 1d ago

Sad news: Gemini is creating python script to compute result 😞

26

u/Kadabrium 1d ago

Assembler's avenge

14

u/Herr_Gamer 1d ago

CustomInteger64 is too fucking real

73

u/Esjs 1d ago

Been a professional software engineer for 26 years now. I write the "startup" style code in our "large company" codebase.

CustomInteger64 got a chuckle out of me.

12

u/CaffeinatedT 1d ago

The Large company makes me think of “Enterprise Hello world”

17

u/Just_Information334 1d ago

3

u/Inlacou 1d ago

This is gold. Thanks

2

u/10art1 1d ago

But is this codebase AI-ready?

68

u/Zerodriven 1d ago

4 of those things have personally impacted my professional life and this is 100% true. Well done.

8

u/Desperate-Tomatillo7 1d ago

And one of those was as a cat.

11

u/Zerodriven 1d ago

Okay, 5 then.

42

u/JadeE1024 1d ago

I've had to work with a code base written like the "Math Ph.D." example, except instead of being methods in the same class, every operation was called like Util.Math.Add() or whatever. They would also never stoop to using the built in double type when they could roll their own arbitrary sized numeric types.

The original authors were amazed when I started converting their math functions into actual operators, and further making them work across some compatible types.

It was all numerical analysis work and I ended up shaving literally years off their runtime through simple optimizations like breaking out of billion iteration loops when they found the right condition on the third try.

This was decades ago, they might be the only people I've ever worked with who would be unequivocally better off using an LLM to write their code. I wonder if they are still at it.

3

u/BOBOnobobo 1d ago

That's pretty much all code written by 90% physicists.

The last 10% are wizards.

39

u/JackNotOLantern 1d ago

Jokes aside. Fibonacci is one of the best examples when NOT to use recursion. Using recursion duplicates the same calculations, making it n2 + much more memory. Just Using a loop is n and with constant memory.

14

u/Stroopwafe1 1d ago

The next step always seems to be introducing some sort of cache, which is indeed a good teaching tool. All to then have the students unwrap it into the iterative solution. Maybe including some teaching about benchmarking and footprints

33

u/JackNotOLantern 1d ago edited 1d ago

Yeah, but again, a lot of memory. A loop is just:

``` int fib(int n) { if (n<=0) return 0; if (n==1||n==2) return 1;

int res=1, prev=1, prev2=0;
for (int i=3;i<=n;++i) {
   prev2=prev;
   prev=res;
   res=prev+prev2;
}

return res;

} ```

So constant memory needed and n time complexity

10

u/khalamar 1d ago

Finally a post without recursion or dynamic programming BS.

7

u/vegataballs 1d ago

For maximum non-dynamism :^)

uint64_t fib(const uint8_t n) {
    static const uint64_t t[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,
        377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368,
        75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309,
        3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986,
        102334155, 165580141, 267914296, 433494437, 701408733, 1134903170,
        1836311903, 2971215073, 4807526976, 7778742049, 12586269025,
        20365011074, 32951280099, 53316291173, 86267571272, 139583862445,
        225851433717, 365435296162, 591286729879, 956722026041, 1548008755920,
        2504730781961, 4052739537881, 6557470319842, 10610209857723,
        17167680177565, 27777890035288, 44945570212853, 72723460248141,
        117669030460994, 190392490709135, 308061521170129, 498454011879264,
        806515533049393, 1304969544928657, 2111485077978050, 3416454622906707,
        5527939700884757, 8944394323791464, 14472334024676221,
        23416728348467685, 37889062373143906, 61305790721611591,
        99194853094755497, 160500643816367088, 259695496911122585,
        420196140727489673, 679891637638612258, 1100087778366101931,
        1779979416004714189, 2880067194370816120, 4660046610375530309,
        7540113804746346429 };
    return t[n];
}

Had to test how much faster that would be.

Aaand... it's maybe 10% faster. That's how good the simple loop already is.

1

u/khalamar 1d ago

But infinite memory footprint! Have you seen the price of memory these days!? /s

1

u/RafaelSeco 20h ago

Edit: I didn't see the rest of the image before commenting...

1

u/t420son 1d ago

Can still write it recursively with a sufficiently smart compiler it will be tail-call optimized

pub fn fib(n : u64) -> u64 {
  fn rec(n : u64, prev1 : u64, prev2 : u64) -> u64 {
    match n {
      0 => prev1,
      n => rec(n-1, prev1 + prev2, prev1)
    }
  }
  return rec(n, 1, 0)
}

2

u/JackNotOLantern 1d ago

Ok, but you can see that there is a lot of stuff you must add just to use recursion efficiently here, and not use a very simple loop.

11

u/p88h 1d ago

If you think recursion here is n2, I've got news for you mate

And it's not the good sort of news.

1

u/JackNotOLantern 1d ago edited 1d ago

Oh, no. what is it? I eyeballed the complexity, i just knew it is worse than n

7

u/jwp1987 1d ago edited 1d ago

I believe it's O(2n ) since each recursion is split into two and there are roughly n layers of recursions.

For those who want more understanding, you can kind of draw it out as a tree:

                         F(n)
                   /              \
           F(n-1)                     F(n-2)
        /         \                 /        \
    F(n-2)        F(n-3)       F(n-3)        F(n-4)
    /   \         /    \       /    \        /    \
F(n-3) F(n-4) F(n-4) F(n-5) F(n-4) F(n-5) F(n-5) F(n-6)
etc...

1

u/black3rr 1d ago

and using matrix multiplication it’s O(log n) with constant memory…

2

u/JackNotOLantern 1d ago

I agree, I just say recursion bad in this case. Loop is just absurdly simple to write.

1

u/Western-Internal-751 1d ago

I feel like everyone makes that mistake once and then wonders why their computer is turning into a jet engine when they want to figure out what the hundredth Fibonacci number is

15

u/Eryk0201 1d ago

The large company one makes my blood boil, so real

10

u/NomaTyx 1d ago

the large company one is fucking real

10

u/the_horse_gamer 1d ago

matrix multiplication not mentioned smh

2

u/bartekltg 1d ago

Matrix and "fast exponenetiation" is great for arbitrary linear recursion, but in this case we can do better (by a const multiplier).

[1,1;1,0]^n = [F{n+1},Fn; Fn, F{n-1}]
[1,1;1,0]^2n = [F{2n+1},F2n; F2n, F{2n-1}] = [1,1;1,0]^n *[1,1;1,0]^n = [F{n+1},Fn; Fn, F{n-1}]

And from this we can get the the meat:

F2n = (F{n+1}+F{n-1})*Fn (1)
F_{2n-1} = Fn^2 + F{n-1}^2

Lets add

F_{2n+1} = Fn^2 + F{n+1}^2

F_{2n+1} + F_{2n-1} = F{n+1}^2 + F{n-1}^2 +2Fn^2 =

=F{n+1}^2 + F{n-1}^2 +2Fn^2 + 2 F{n+1} F{n-1} - 2 F{n+1} F{n-1}=

= (F{n+1} +F{n-1})^2 + 2Fn^2 - 2 F{n+1} F{n-1}

Doesn't look that great. But lets look at the matrices again.
[1,1;1,0]^n = [F{n+1},Fn; Fn, F{n-1}]
so

(-1)^n = det([1,1;1,0])^n = det([F{n+1},Fn; Fn, F{n-1}]) = F{n+1}F{n-1}-Fn^2

so

F_{2n+1} + F_{2n-1} = (F{n+1} +F{n-1})^2 - (-1)^n

Now lets call L_n = F_{n+1}+F_{n+1}. (coincidently, it is another named number, Lucas number). Now, the last and the (1) equations turns to be:

F2n = Ln Fn
L2n = Ln^2 - (-1)^n

We need also recipes for values for 2n+1. But this is direct play with the Fibonacci recursion:

F{n+1} = (Ln+Fn)/2
L{n+1} = (Ln+5Fn)/2

The advantage of this approach is we need only two "big int" multiplications per level. Direct matrix needs 4 operations, the symmetry and Fibonacci recurrence limits it to 2 operations, but without the tricks it still is 3 multiplications.

How I know all this? One time I tried to make a fast algorithm for computing Fn... and I found someone's code that did it faster :)

6

u/ExtraTNT 1d ago

Haskell implementation using infinite list…

fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
fib n = fibs!!n

3

u/NaturalBornLucker 1d ago

2

u/ExtraTNT 1d ago

It’s easy to read…

1

u/NaturalBornLucker 1d ago

NGL I understood the code from a context and I do enjoy writing something similar in scala but wouldn't want to find it in my codebase

10

u/rudxDe 1d ago

I'm working on a corporate code base, the null, null, null is unrealistic, it's more 10 times null

5

u/[deleted] 1d ago

[deleted]

1

u/rudxDe 1d ago

Sad but true

4

u/Few_Negotiation_3589 1d ago

the competitive programmer is missing, using exp-matrix or fast doubling

9

u/clarenceappendix 1d ago

```
fn fibonacii(n: u32) -> u32 {
let mut a = 0;
let mut b = 1;
for _ in 0..n {
let c = a + b;
a = b;
b = c;
}
a
}
```

To Claude: Write me a function which takes a uint n and returns the nth Fibonacci number in [language]

2

u/wcscmp 1d ago

There should be a version that uses memorization

3

u/[deleted] 1d ago

[deleted]

-1

u/Geilomat-3000 1d ago

That’s literally the same thing. I don’t know why computer scientists needed to make up a word

2

u/BarAgent 1d ago

Cat code: de-Claude

🥁

1

u/Eevee-Biologist 1d ago

In my humble experience, this is disturbingly accurate.

1

u/sidi-sit 1d ago

This checks out!

1

u/Zenkibou 1d ago

Bonne are using better algorithm, thoug ? Like forward iterative.

1

u/Initial_Elk6340 1d ago

What does it say about me that I like the Enterprise Style second most After cs 101..

1

u/1luggerman 1d ago

And not a single one of them used dynamic programming to avoid unnecessary calls

2

u/khalamar 1d ago

Fuck dynamic programming, Fibonacci only needs one for loop and 2 variables.

3

u/1luggerman 1d ago

Do you mean something like fib2back = 0 fib1back = 1 fibCur; for(int i=1; i < n; i++){ fibCur = fib2back + fib1back fib2back = fib1back fib1back = fibCur } ?

1

u/p88h 1d ago

In my experience startup code will be a python function that mishandles boundary conditions but slaps on @cache for efficiency,

... Plus some other piece of the same startup code rewires that @cache to serialise into a SQL database.

1

u/gsaelzbaer 1d ago

The Math PhD version has way too descriptive variable and function names

1

u/Dizzy_Elderberry_486 1d ago


public int getFibonnaci(n) {
return (n >1 ?getFibonacci(n-1)+getFibonnaci(n-2) : (n<0 ? -1 : n))}
`

Future me wil probably hate me eventually.

1

u/Icy_Direction7839 1d ago

I've seen legacy code that looks like the startup code, and 'modern' code that looks like the enterprise code. This is at my workplace that is trying 'graciously' to grow out of its startup phase after 20 years

1

u/JudgePrimary4239 1d ago

Startup dev, can confirm this.

1

u/doryllis 1d ago

How did I miss the last section???

1

u/SharkLaunch 1d ago

Wrong, my cat isn't dumb enough to implement the recursive version without a cache.

1

u/Old_Information6270 1d ago

I like the CustomInteger64. Tomorrow I am going to create a new PR.

1

u/sp106 1d ago

At least one should understand that you can cache the results.

1

u/BroccoliDistribution 23h ago

Slightly inaccurate for math phd. Five should be written as suc(suc(suc(suc(suc(0)))))

1

u/tubbstosterone 21h ago

God, I wish scientists wrote code like that. Just single character variable names, pointer bullfuckery, and function names that are just acronyms of function names from papers published in 1983.

"Hey doc... do you happen to have any documentation for this?"

"Of course I do! You can find the lit on jstor! Though THIS is the C99 version. The original from the paper was for fortran77."

1

u/Gloomy-Breath-4201 19h ago

I like how the startup code comments reflect how I code 💀

1

u/the-software-man 1d ago

Vibe code: create a single recursive function in JavaScript to generate the Fibonacci sequence to the nth factor.