This fun fact has been on my mind for a while, and a recent reddit thread about "Smuggling Checked Exceptions with Sealed Interfaces" made me write this post here. Namely, Java had union types before it was cool! (If you squint hard). What are union types? Ceylon is an underrated JVM language that never really … Continue reading Java’s Checked Exceptions Are Just Weird Union Types
Tag: structural typing
Do You Really Have to Name Everything in Software?
This is one of software engineering's oldest battles. No, I'm not talking about where to put curly braces, or whether to use tabs or spaces. I mean the eternal battle between nominal typing and structural typing. This article is inspired by a very vocal blogger who eloquently reminds us to ... [...] Please Avoid Functional … Continue reading Do You Really Have to Name Everything in Software?
We’re Taking Bets: This Annotation Will Soon Show up in the JDK
This recent Stack Overflow question by Yahor has intrigued me: How to ensure at Java 8 compile time that a method signature “implements” a functional interface. It's a very good question. Let's assume the following nominal type: @FunctionalInterface interface LongHasher { int hash(long x); } The type imposes a crystal clear contract. Implementors must provide … Continue reading We’re Taking Bets: This Annotation Will Soon Show up in the JDK
Duck Typing in Scala: Structural Typing
Scala goes very far with its loads of features improving the JVM world. Sometimes, a bit too far, maybe. But this feature here is just plain awesome! Typesafe duck typing! An example: def quacker(duck: {def quack(value: String): String}) { println (duck.quack("Quack")) } The above quacker method accepts any "duck" that can quack. Read the full … Continue reading Duck Typing in Scala: Structural Typing