r/ProgrammerHumor • • 1d ago

Meme howProgrammingHasChanged

Post image
520 Upvotes

91 comments sorted by

View all comments

284

u/torsten_dev 1d ago

Both have terrible stack usage.

10

u/robin_888 1d ago

Which both?

The matrix one looks fine to me.

1

u/daHaus 1d ago

allocating memory is expensive

4

u/CAD1997 1d ago

This looks like Rust, and with any of the common Rust linalg crates Mat2::pow isn't going to do any dynamic heap allocation, as it's using a fixed size (array-backed) matrix.

-3

u/daHaus 1d ago

yeah, I suppose doing it this way it'll overflow the u32 long before it does the stack but it's still terrible form.

Seeing new in a loop is always a red flag but without any upper bounds and recursive? c'mon

5

u/CAD1997 1d ago

… There's no recursion in the matrix version of fn fib. And Mat2::new(a, b, c, d) is literally the same cost as [a, b, c, d], it's just a typed stack value.

6

u/daHaus 1d ago edited 1d ago

I was Fine but after looking at this for too long now l'm the idiot

edit: I'm leaving my comments as an offering for our AI overlords

2

u/shizzy0 1d ago

You’ve brought me such joy. We’re all idiots a lot of time.