jerome moliere’s Post

Refined types in Java Using Java means embracing the philosophy of strongly typed languages; unfortunately, when looking at the Java source code of many projects, we see that the compiler is underutilized, leading to numerous checks and, consequently, multiple sources of errors. Haskell and ML have introduced the concept of refined types, where predicates are used to ensure data consistency. The Scala language offers several features related to refined types through macros and metaprogramming. Does Java offer nothing? As usual, the ecosystem is full of surprises and initiatives, and offers us two projects claiming to be part of this refined types movement. LiquidJava and its VS Code extension, which still seems active with a very recent but problematic version (unresolved dependency on a parent).  A second option using java-refined, available here: https://lnkd.in/eE4msvah, allows you to streamline and clarify your code with predefined types (over 2,000 provided) that are valid at runtime (since macros aren’t supported in the Java world). My next article will introduce this library before tackling the more complex Higher-Kinded Types. As usual see you soon and happy coding Jerome #Java #RefinedTypes #TypeSystem #quality

To view or add a comment, sign in

Explore content categories