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

I'm on a similar boat as others here. I used to read all of Bjarne's books back in the day. Now I barely keep up with the language, and only update my knowledge of it enough to keep up with work -- and companies usually lag several standards behind. For my side projects, I've switched to C, which has a much smaller cognitive overload and allows to me focus more on the actual problem, or garbage-collected languages when I just need something quick.



I like C a _lot_, just wish it has more well-established data structure and algorithm collection like c++'s STL library to speed up coding, also wish it had a better way to do RAII-like resource management. Someone please invent c+ that can reuse all existing c code and even some c++ code, but more capable than c, much simpler than c++.


The ideas in the STL were novel enough that when it was originally opposed the C++ committee didn't really "get" it. Generic programming existed since the 1970s, but it wasn't popular until maybe this century.

So there's just no way K&R C gets anything like the STL. Maybe you get stuff like a char* (these days you would write void * but that's not a thing yet) linked list? That does not sound like a better world.


One pattern (not necessarily a good one, but it's definitely used out there) is to define your "generic" code in macros, and then expose a macro such as MAKE_LIST(int) that in this case instantiates a list of int. Then you get a 'type-safe' interface, or at least more type-safe than void*, and also less annoying.

And then you just abuse arrays as much as possible. For a small number of items, e.g. <100 on a modern laptop, that linear and cache-friendly search is going to beat std::map and std::unordered_map and friends.


What if the items in the array are bigger than a cache line?


Yes, of course, my statement has many caveats, you get the point.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: