logoalt Hacker News

spacechild106/15/20252 repliesview on HN

Do you understand how your compiler works? Shouldn't you be writing assembly instead? You can't understand all internals and that's perfectly fine.

Why do you even care how std::function is implemented? (Unless you are working in very performance critical or otherwise restricted environments.)


Replies

kjksf06/15/2025

I've listed several reasons why I decided to write and use this implementation:

  - better call stacks in crash reports
  - smaller and faster at runtime
  - faster compilation because less complicated, less templated code
  - I understand it
So there's more to it that just that one point.

Did I loose useful attributes? Yes. There's no free lunch.

Am I going too far to achieve small, fast code that compiles quickly? Maybe I do.

My code, my rules, my joy.

But philosophically, if you ever wonder why most software today can't start up instantly and ships 100 MB of stuff to show a window: it's because most programmers don't put any thought or effort into keeping things small and fast.

show 1 reply
maleldil06/15/2025

> You can't understand all internals, and that's perfectly fine.

C++ takes this to another level, though. I'm not an expert Go or Rust programmer, but it's much easier to understand the code in their standard libraries than C++.

show 1 reply