Type Safety Doesn't Matter (2023)
fpcomplete.com
fpcomplete.com
Pushing runtime complexity into compile time complexity almost always pays off, regardless of the number of people who will tell you that hash table of hash table can take care of anything
I feel like it could really use a couple examples of situations where type safety is a waste of time. As-is the post vaguely suggests a tradeoff and doesn't elaborate.
Why is an example necessary for this? It's trivially correct.
That's the problem. You can't develop a meaningful sense of balance if you only say trivially correct things.
And the specific need for an example is situations where you could use type safety but don't want to.
Personal opinion: Type systems are more useful for initial code comprehension and tooling than for writing it in the first place, or preventing bugs.
exactly, it's clickbait
It's like saying: "This food, on its own, is not important. It's only useful because it provides me energy".
Add per se at the end of the title and it’s not clickbait any more.
Language is a thing.
> when discussing architecture of code or reviewing a pull request, I will often times push back on changes that add more complexity in the type system. The reason is because, even if a change adds “type safety,” this extra complexity is only warranted if it achieves our primary goal, namely reducing runtime errors.
It's poorly emphasized, but the author is referring to Typescript-style static typing which can come with a truck load of complexity. Something like Go's type system is fine (there's nothing sophisticated about it) but Typescript's type system gives you enough rope to hang yourself with.
They still love Typescript, but they don't abuse the type system.
...
> Bug reduction is not the only benefit of strong typing. There’s also: easier codebase maintainability, simplicity of refactoring, new engineering onboarding, potentially performance gains, and probably a few other things I missed.
But besides that, what have the Romans ever done for us?
I am implementing Practal in TypeScript, and it is so much more productive than if I had to do it in JavaScript. I am (mostly) not using any advanced features of the type system, but use it for its simple features, as described in this blog post. The greatest feature: I can ignore the type system, where it makes sense. That isn't as bad as it might sound, given that the type system of TypeScript is not sound in the first place.
The blog post suggests also thinking about other means to achieve the end (less bugs), such as push-button technology like static analysis. I agree with this, but am more interested in another direction of developing this thought: If we are actually proving theorems in a logic about mathematical objects like code, we don't need a type system, either. In fact, a type system can and will get in the way of formulating your theories in the simplest and most elegant way. It adds the additional constraint that on top of figuring out how to express something mathematically, you also need to figure out how to express it in this particular type system. And while often these two things are aligned well enough, this is not always the case. By the way, note that I am not saying that types themselves are not always useful. They are. It is just that we don't need a static type system to use types, which I think of as abstract sets.
Let me anticipate a comment someone will make: But type systems are how in practice logic is implemented, what are you talking about?! And yes, if you look at the main systems in the space, like Isabelle, Lean, Coq, they are based on type systems. But that is not how it necessarily needs to be done. You could be using first-order logic, like Mizar does, but that comes with its own set of restrictions, mainly missing out on higher-order features. What I am implementing in Practal instead is Abstraction Logic [1], which is higher-order, but based on a single mathematical universe instead of types.
Now, right now that is a far cry from the push-button alternatives the blog post suggests, but a) it is not opposed to these alternatives, but an additional angle to view things from, and b) it is becoming much more push-button than it used to be with the help of increasing compute power and AI.