Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Okay, I hate C++ as much as the next guy, but this is ridiculous. There are dozens of ways to get similar code to what the author mentions.

So lets say a decent C++ programmer writes it with std::list<person *> then does some profiling and determines that heap fragmentation is becoming an issue. They can then refactor the code to use a more intrusive list type.

A crappy C++ programmer won't even know its a problem, but presumably we are comparing programmers of similar expertise?



A relatively new C programmer would probably come up with the C code. From the discussion of this topic it appears the C++ solution needs quite a bit more expertise to get right (I would not have known what exact C++ method to use, but I don't pretend to be a C++ expert at this point).

Hmm, actually I would expect most of the C++ methods not to have a problem with heap fragmentation, if they are copying the list when manipulating. The C one doesn't know when it will alloc a new bit of memory, so you might potentially have a cache miss for every single node in the C list, making traversal the worst case scenario.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: