Hacker News new | past | comments | ask | show | jobs | submit login

Fair, but I was replying to this being a good example of modern C++. It's atypical that implementing your own vector and string is even a good idea, let alone exemplary.



The C++ stdlib versions of vectors have different design goals, including a bunch of ABI constraints for very old code (things like the vector<char> specializations). Likewise there are questionable spec behaviors like unordered_map that specifies suboptimal implementation.


Follow on thought - what happens for operator new[]() in kernel space? Does it depend on a malloc (vs. traditional kmalloc)?


It's currently ending up in kmalloc(). The compiler handles the new[]/delete[] element count and I don't ask any questions about how.


On the contrary, the standard vector and string classes are garbage UX-wise (e.g. unlike pretty much every other single dynamic array implementation in existence, vector does not have something like an "index of element" method and instead you are supposed to use std::find and subtract iterators with a special check for when the element wasn't found... like, WTF).


OK, fine. Then use std::string_view, etc., which are cleaner and more efficient usually. There are several reasons why C++ open source is hard to reuse, and not using standard types appropriately is one of them.


This entire project is about implementing already-existing functionality in its own way, with minimal dependencies, for fun.

Its use of the C++ language strives to be modern. There is no attempt to use modern 3rd-party C++ frameworks.


I just wrote that the API is garbage and then you recommend me to use the API? :-P The entire STL/StdC++ has the same design style, it is garbage all the way down.

I'd rather use something like Qt (which is far from great, but better than STL/StdC++). Well, personally i'd rather not use C++ in the first place, but if i'm going to use C++ i'd rather use something else (which frankly, would be my own container and string classes that provide a much better API).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: