News for hackers. Stuff that matters.
Re:Caramel: an Erlang back end for OCaml by pron on Sunday September 27, 2020 @02:16PM (#24608826)
> In my experience, Java's generics were horribly confusing and not quite type-safe, in contrast to the dead-simple polymorphism in Haskell. But feel free to correct me here.

Oh, they're typesafe (except for a bug in the implementation found a couple of years ago) but I agree they're more confusing than in languages without subtyping. I'd still pick Java over Haskell any day (but I'd take Haskell over Scala). Pick your poison, I guess.

> What a language gives you is less important that what it makes easy, and I cannot imagine a more cumbersome syntax for ADTs than the one in the linked proposal.

Nah, the syntax is fine. Somewhat more verbose than ML's or Haskell's, but it fits well with the rest of the language. So instead of Haskell's,

    data Expr = ConstantExpr Int
              | PlusExpr Expr Expr
              | TimesExpr Expr Expr
              | NegExpr Expr
       deriving (Show, Eq);
You write,

    sealed interface Expr {}
    record ConstantExpr(int i)       implements Expr {}
    record PlusExpr(Expr a, Expr b)  implements Expr {}
    record TimesExpr(Expr a, Expr b) implements Expr {}
    record NegExpr(Expr e)           implements Expr {}
Not quite as succinct, but it's not really any more tedious (and you get component names, too).
Re:Caramel: an Erlang back end for OCaml by creata on Sunday September 27, 2020 @04:33PM (#24609939)
Yeah, I guess I overreacted to the verbosity β€” it's definitely a huge improvement over the current state of Java. But is there a reason not to add NonNull annotations to the fields of type Expr?
Re:Caramel: an Erlang back end for OCaml by zaltekk on Sunday September 27, 2020 @05:38PM (#24610331)
It’s much more common nowadays to have SpotBugs/Checkstyle treat everything as non-null by default. Then you use Optional where necessary (or maybe @Nullable).
Re:Caramel: an Erlang back end for OCaml by pron on Sunday September 27, 2020 @05:39PM (#24610343)
I'm guessing that at one point or another Java will get nullability types similar to Kotlin's.