logoalt Hacker News

monkeyeliteyesterday at 2:18 PM1 replyview on HN

> 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.


Replies

el_pollo_diabloyesterday at 9:12 PM

> Are you saying the only real way to program is with generic data structures?

Certainly not. As I said, the experienced programmer knows when (not) to use them. Some programs are better off without them, such as... most of the low-level software I write (security-critical operating systems).

> 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's not a big deal" are famous last words. Maybe it is not a big deal, but unless you have hard constraints or measurements that confirm that you would not be served well enough by an existing solution, it may very well be the reason why your competitors make progress while you are busy reinventing, debugging, maintaining, and obtaining certification for a wheel whose impact you overestimated.

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

Avoiding code bloat? Agreed, a custom solution cannot be worse than a generic one. Avoiding premature optimization? Quite the contrary: going straight for the custom solution without first confirming, with actual measurements, that the generic solution is the unacceptable bottleneck, is textbook premature optimization.

I am sorry but I do not understand what you are getting at.