Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When writing a compiler it helps for sure.

Though most of my time is protobuf in Java, I still wouldn't mind having an ADT or two for when I got lists of things and the things aren't exactly uniform but I don't want to make a type hierarchy.




Doesn't `sealed trait ... permits ...` and `record` satisfy that these days for Java? That's what our proto2 `oneof`s generate into.


> I don't want to make a type hierarchy

Yeah I could emulate it, but it's much more verbose, and the signal to noise ratio is bad. Ex, a four line Haskell ADT could be 40 to 100 lines of java, and you gotta think things through a bit more. Instead I might have two fields which are Optional and specify an invariant in the comments.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: