logoalt Hacker News

el_pollo_diabloyesterday at 9:28 AM1 replyview on HN

You mean the downside that we also already know, i.e. that there are some situations where a custom data structure would be superior for various reasons (e.g. smaller footprint)?

Experienced programmers know when to reuse a generic library and when to roll out their own. We all know that.

Yet you dismiss generic red black trees because there is no realistic single program that uses 10 key/value combinations. Not only is this false, but as I illustrated in my reply, a single program is not the relevant scope to decide whether to use a generic implementation. And as someone who has written a red black tree library, I am definitely in favor of reusing an implementation unless you have an excellent reason, which "I do not need 10 different instances in my program" or "my favorite language and its standard library only have arrays built in" most definitely are not.


Replies

monkeyeliteyesterday at 2:18 PM

> Yet you dismiss generic red black trees

I use generic data structures all the time. That’s the default in programming. We know their advantages.

I am trying to say there is a world out there that doesn’t look like ours and it works just fine and has other advantages.

Are you saying the only real way to program is with generic data structures? I’m saying no because nobody did prior to the late 80s.

> I am definitely in favor of reusing an implementation unless you have an excellent reason

Let me try one more time. If you examine a program you won’t find 10 different red black trees. Data tends to follow a particular path and there is probably 1 red black tree and it’s a core feature of the application.

If that’s true then it’s not a big deal to write that core feature of your application.

It avoids premature optimization and code bloat because you tend to use complex data structures when they have a need.

Array is a good default. It’s how computer memory works, not just what happens to be lying around.

show 1 reply