Hacker News .hnnew | past | comments | ask | show | jobs | submitlogin

Well I guess we can always play micro-benchmarks game if you want to go down that path, including selecting specific compiler toolchains and flags while making it a point that it is a property of language XYZ, to make it even better.


I don't see the std::vector example as a micro-benchmark, we're not talking about wasting a few microseconds in a contrived example, we're talking about destroying the amortized constant time growth performance of the data structure because of an API goof.


Which std::vector, from which C++ compiler, targeting what OS, with what set of compiler flags, and optimization passes?


You'd think right?

Except nope, it's an API design problem. If you write a std::vector or equivalent but where reserve has analogous behaviour to Vec::reserve you can't do Vec::reserve_exact at all and that can really hurt in other cases.

There really are two distinct features and C++ specifies a single API call.


Yes, it only matters that it fulfills the algorithm requirements described in ISO C++, how the implementation look like is another matter.

Still, this is going way down into the weeds and very far away that any mature AOT compiled language offers good enough speed, ignoring toy compilers done by students.


You'd think right?

Except nope, it's an API design problem. If you write a std::vector or equivalent but where reserve has analogous behaviour to Vec::reserve you can't do Vec::reserve_exact at all and that can really hurt in other cases.

There really are two distinct features and C++ specifies a single API call.




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

Search: