I’ve first read this post back in 2019 when it was released and I have to say that it really has left quite an impact on the way I write programs these days. The „make illegal states unrepresentable“ and „push proofs up“ guidelines are so simple yet so effective. Sure, there is some initial cost to create new datatypes, but it really pays off in the long run. Not having to worry about null or wrongly shaped data structures down the line is really nice, especially if you’re working on older code or develop in a team. Even though the post uses Haskell to explain the concepts, I found it to also work well in other languages, even Java or Python.
- 0 Posts
- 3 Comments
Joined 2 years ago
Cake day: April 3rd, 2024
You are not logged in. If you use a Fediverse account that is able to follow users, you can follow this user.
QT1@lemm.eeto
Programming@programming.dev•"GitHub" Is Starting to Feel Like Legacy Software
4·1 year agoIn Firefox, you can also override right-click capture by holding shift while right-clicking.
voidin Java andVoidin Haskell are quite different. As the post explains, in Haskell it’s a type with no possible values. In Java, the equivalent would be a class without a constructor (not sure if that’s even possible). It defines a type, but you cannot construct a value or object with that type. The equivalent of Java‘s void in Haskell is the unit type()which has exactly one possible value, also called(). It can be returned by a function, but it does not give you any information, just like void. By the way, Rust also uses the unit type instead of void.