NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
When did people favor composition over inheritance? (sicpers.info)
rurban 1 days ago [-]
I have a different view of them. For me, having implemented both in my object systems, composition is compile-time, early-bound, whilst inheritance is just another runtime indirection, late-bound.

Composition needs more memory per class and object, but is faster at runtime.

brad0 1 days ago [-]
The summary of the post says that lambdas/procedures/etc. are another type outside of composition and inheritance. I’ve always thought of lambdas as composition though. You’re assigning a function just as you would any other data, right?
Panzerschrek 23 hours ago [-]
Using inheritance becomes painful in languages like C++ as soon as diamond-like hierarchies are involved.
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 16:28:23 GMT+0000 (Coordinated Universal Time) with Vercel.