Hacker News new | ask | show | jobs
by stormbrew 1653 days ago
I mean, I'm not sure where this 'fear' even came from?

At its core, inheritence is a special case of composition anyways (looked at from the other perspective it's syntactic sugar over either static or dynamic delegation), so it can't really be "faster".

At any rate, there's no abstraction so powerful it can prevent a programmer from making it slow.

1 comments

This is true for languages where most objects are not garbage-collected. In Java (modern days) this would add a level of indirection.
Which may be in certain cases trivially optimizable. Eg. an object available only inside a class can have its method calls inlined into the containing class’s methods.

(But I’m no JVM developer (unfortunately) so I’m not sure whether this exact optimization exists or not)