← Back to context

Comment by jpc0

6 months ago

So you strongly believe that the programmer should implement .map on arrays and hashmaps etc themselves? Well you will love C code then.

The point of library code is to implement these things once in a safe and efficient manner and reuse the implementation.

Sometimes there are more domain or even company specific things that should be implemented exactly once and reused.

Nobody said there are different tiers of developers like "library developers" and "normal developers". Those are different types of programming that a single developer can do but fundamentally require a different thought pattern. Designing datastructures and algorithms are a lot more CS whereas general programming is much more akin to plumbing. If you think library code isn't needed it's because you overlook the library code you already use.

There are some things that are not yagni, if you have those in place then the rest of your code can literally be implemented that way because you literally won't need it.

It's not that shared_ptr isn't needed, it's that people don't use it where necessary, they use it because it's convenient not to think entirely and because the necessary Library code isn't there. I stand strong that seeing std::shared_ptr/box (or even std::unique_ptr/Box) in general code is a code smell, the fact that you even said that there are certain algorithm's that cannot be expressed without it means you agree, the algorithm should be implemented exactly once and reused. If it's only used one then sure it can be abstracted when needed but that doesn't mean you shouldn't need to justify why it's there.