logoalt Hacker News

gorgoiler • yesterday at 8:46 PM • 3 replies • view on HN

It’s nice they tried with a more fleshed out exemplar. Polymorphism (“generics”) and interfaces (“OOP”) would have been even better to see, especially across any kind of visibility boundary enforced by the language (packages, and the like.)

Programming to an abstract interface — and in large codebases, enforced visibility controls — represent the middle ground everyone wants, in my experience, between “OOP” and “sir, this is C”.


Replies

owlstuffing • yesterday at 10:40 PM

> Polymorphism (“generics”) and interfaces (“OOP”) would have been even better to see

Yep. Interface-based (true) delegation between objects would be my go-to if it existed.

sproutini • today at 12:22 AM

Subtyping and generics raise the question of whether containers are covariant or contravariant.

joe_the_user • yesterday at 9:16 PM

Yes,

The example definitely shines. Doing something barely non-trivial is great since it gives a feeling for the language. I wish other language introduction pages would take note.

➕ show 1 reply