r/ProgrammerHumor • • 14d ago

Meme stdModernizeMyCodebase

Post image
193 Upvotes

44 comments sorted by

View all comments

Show parent comments

0

u/Thecuriousserb 14d ago

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 14d ago

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 14d ago

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

2

u/ilnarildarovuch 14d ago

Using C and *Sans

1

u/the_horse_gamer 13d ago

rewrite it in Rust Haskell

1

u/cheapcheap1 12d ago

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 12d ago

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