Hacker News new | ask | show | jobs
by lukaslalinsky 457 days ago
See for example the last version, which is marked as "GOOD". It directly inlines all operations on the vector. The more you use it, the bigger the compiled code becomes. Need to debug it and want to set a breakpoint to vector_append? You can't. You also can't use callgrind/kcachegrind to see how fast the functions are. Yes, it's still C, but very awkward and finicky C.
2 comments

My point was that this is still C, I wasn't advocating using any of it.

People have different preferences though, so if someone has 50,000 lines of code invested in a C application, but wants to (for some reason) use generics in some way, perhaps this is their best option...

Any compiler worth its salt be inlining those functions (provided lto is enabled) because inlining that type of tiny function is a win. Additionally, the linker can deduplicate identical functions (eg vec append for two identically sized types)