r/ProgrammerHumor • • Oct 12 '26

Meme stdModernizeMyCodebase

Post image
195 Upvotes

44 comments sorted by

View all comments

Show parent comment

0

u/Thecuriousserb Oct 13 '26

Unique pointer and other seemingly trivial types can fuck up your codegen and give you unoptimized assembly, chandler carruth from LLVM has many talks/slides that discuss this exact issue with unique ptr. Remember kids, there is no such thing as a zero-cost abstraction!

11

u/Fast-Satisfaction482 Oct 13 '26

That's such a straw man argument. Just because there may be cases where the hot spots of your software can benefit from using raw pointers doesn't mean it's reasonable to go bare metal in the whole code base.

3

u/Daemontatox Oct 13 '26

Oh wise one , how can one achieve perfect optimized and safe code

2

u/ilnarildarovuch Oct 13 '26

Using C and *Sans

1

u/the_horse_gamer Oct 13 '26

rewrite it in Rust Haskell

1

u/cheapcheap1 Oct 14 '26

How is unique_ptr not a zero cost abstraction? Is this anything other than compilers making avoidable optimization errors that will get fixed with time?

3

u/Thecuriousserb Oct 14 '26

Long story short unless you turn off exceptions, the stack unwinding code fucks up assembly for hot loops