Hacker News new | ask | show | jobs
by Calavar 1709 days ago
> So you can (and probably should) do almost any memory management as you would in C++

Well that's already out the door because I almost never use shared_ptr in C++ code. The C++ core guidelines recommend using unique_ptr whenever possible. If you're going to use shared_ptr literally everywhere you do dynamic allocation, you'd be better off using a tracing GC to avoid the extra pointer indirection (and cache miss) with every dereference.

It seems to me that Cito should have manual memory management because a manual memory language can be trivially mapped onto a GC language (just turn every free or delete to an nop), while the inverse problem is intractable in the general case.

1 comments

Please show us real code where std::unique_ptr vs std::shared_ptr makes a considerable difference (with benchmarks). A pointer indirection causes a cache miss?

A shared_ptr can be optimized to unique_ptr if it's not copied.

Not sure what you mean by "a GC language". Most cito targets are garbage-collected.