News for hackers. Stuff that matters.
Re:To Save C, We Must Save ABI by bluGill on Tuesday August 11, 2026 @08:43AM (#49257395)
They faced much slower computers with very limited memory. They couldn't afford the tricks that today are minimal cost.
Re:To Save C, We Must Save ABI by kmacleod on Tuesday August 11, 2026 @10:23AM (#49258897)
I discovered this recently as I tested an old idea I had to allow a dynamic language to use a C++-like vtable instead of an inline cache (like Objective-C or JavaScript does). It turns out modern CPUs predict an inline cache hit/miss result much better than always incurring the cost of the fetch in a vtable lookup.
Re:To Save C, We Must Save ABI by p_l on Tuesday August 11, 2026 @03:13PM (#49263047)
Inline caches require runtime supports that were ideologically verboten to C++
Re:To Save C, We Must Save ABI by Conscat on Tuesday August 11, 2026 @04:20PM (#49263896)
You can implement it with templates and people do things like this often. In modern C++, it's even pretty easy to make this type of trick support `constexpr`.
Re:To Save C, We Must Save ABI by p_l on Wednesday August 12, 2026 @02:34AM (#49268590)
Do it manually and hacky, yes.

At that point though, one could claim that they can do it in C as well and implement half of Objective-C

Re:To Save C, We Must Save ABI by pjmlp on Thursday August 13, 2026 @05:41AM (#49283607)
Except that to keep objc_msgSend performance good enough with Objective-C dispatch semantics, a little bit of pure Assembly code help is required.
Re:To Save C, We Must Save ABI by p_l on Thursday August 13, 2026 @06:11AM (#49283797)
well, I wasn't implying full semantics. Or fast, to be honest. Still could be faster than vtable though...
Re:To Save C, We Must Save ABI by pjmlp on Thursday August 13, 2026 @07:08AM (#49284250)
Sure enough.

Going back to the technical implementation part, depending on the C++ version, and being able to understand the target at compile time, no need to do it manually and hacky.

There is enough support in constexpr, consteval, concepts, and now compile time reflection, to do it automatically, assuming the dispatch target can be resolved at compile time.