News for hackers. Stuff that matters.
Re:Don't Be Afraid of Types by throw_m239339 on Saturday March 22, 2025 @11:11AM (#43446267)
Inheritance is one way to achieve polymorphism. it is not mandatory for OOP.

Unfortunately YES, because of "Java Entreprise" pushed by consultancies 15 years ago, a lot of developers insist on encapsulating everything, even when it's redundant.

Fortunately, Java is a better language today.

Re:Don't Be Afraid of Types by throwaway2037 on Sunday March 23, 2025 @03:19AM (#43451368)

    > a lot of developers insist on encapsulating everything, even when it's redundant.
Can you give an example? 15 years ago was 2010 and Java 8 was already released.

    > Fortunately, Java is a better language today.
In what ways? To me, it has barely changed since JDK 8 when it got lambdas. To be clear, the JVM is leaps and bounds better each long term supported release.
Re:Don't Be Afraid of Types by rustyminnow on Monday March 24, 2025 @01:57PM (#43463682)
Sealed interfaces and records allow you to effectively build sum types. Switch expressions with type based pattern matching really streamline certain patterns. Type inferred vars are massively welcome. Streams and lambdas are pretty old by now, but they are much more widely embraced in e.g. frameworks and std libs which is nice.

Independently none of these are game changing, but together they provide much improved ergonomics and can reduce boilerplate. Now if only we had null safe types <3.