Live data from Hacker News

Functional programming and reliability: ADTs, safety, critical infrastructure

blog.rastrian.dev

171–180 of 191 posts

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#171

Earlier quoted context omitted.

Yes, I am wondering if opaque types would be difficult to implement somehow in TypeScript? It should really be part of TypeScript if at all reasonably possible.

I'm not that familiar with the TS internals. They'd have to add a keyword to the language which could break stuff. The smart move would be to reserve the `opaque` word a few versions in advance of introducing the feature that gives it a meaning

I don't think the keyword is the problem, I am wondering more about the internals of their type inference algorithm.

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#172
post #128

Earlier quoted context omitted.

Static types and ADTs are orthogonal to being FP, as Rust clearly shows. But to speak in terms of FP when those are the important things for you is just wrong since even non FP languages now have ADT, including also mainstream languages like Java, Kotlin, Dart, C# and more. Even purity is not something exclusive to FP, D and Nim also support separating pure from impure functions. And if you ask me, the reason not man…

Take a look at Algebraic Effects concept, I think you would like it.

That’s the “effects” I am referring to. Did you think it was something else? Is there other effects systems?

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#173

Earlier quoted context omitted.

>I don't think this happens most of the time, but it does mean that static typing isn't a strict upgrade in terms of reliability. It is a strict upgrade in reliability. You're arguing for other benefits here, like readability and simplicity. The metric on topic is reliability and NOT other things like simplicity, expressiveness or readability. Additionally, like you said, it doesn't happen "most" of the time, so even…

Your definition of reliability seems different to how people use the word. I think most would consider a program that was statically checked, but often produces a wrong result as less reliable than a dynamically checked program that produces the right result. >My argument is that in the totality of possible errors, statically typed programs have provably LESS errors and thus are definitionally MORE reliable than unty…

I think the disagreement here comes from overcomplicating what is actually a very simple claim.

I am not reasoning about infinities, cardinalities of infinite sets, or expectations over randomly sampled programs. None of that is needed. You do not need infinities to see that one set is smaller than another. You only need to show that one set contains everything the other does, plus more.

Forget “all possible programs” and forget randomness entirely. We only need to reason about possible runtime outcomes under identical conditions.

Take a language and hold everything constant except static type checking. Same runtime, same semantics, same memory model, same expressiveness. Now ask a very concrete question: what kinds of failures can occur at runtime?

In the dynamically typed variant, there exist programs that execute and then fail with a runtime type error. In the statically typed variant, those same programs are rejected before execution and therefore never produce that runtime failure. Meanwhile, any program that executes successfully in the statically typed variant also executes successfully in the dynamic one. Nothing new can fail in the static case with respect to type errors.

That is enough. No infinities are involved. No counting is required. If System A allows a category of runtime failure that System B forbids entirely, then the set of possible runtime failure states in B is strictly smaller than in A. This is simple containment logic, not higher math.

The “randomly picked program” framing is a red herring. It turns this into an empirical question about distributions, likelihoods, and developer behavior. But the claim is not about what is likely to happen in practice. It is about what can happen at all, given the language definition. The conclusion follows without measuring anything.

Similarly, arguments about time spent satisfying the type checker or opportunity cost shift the discussion to human workflow. Those may matter for productivity, but they are not properties of the language’s runtime behavior. Once you introduce them, you are no longer evaluating reliability under identical technical conditions.

On the definition of reliability: the specific word is not doing the work here. Once everything except typing is held constant, all other dimensions are equal by assumption. There is literally nothing else left to compare. What remains is exactly one difference: whether a class of runtime failures exists at all. At that point, reliability reduces to failure modes not by preference or definition games, but because there is no other remaining axis. I mean everything is the same! What else can you compare if not the type errors? Then ask the question which one is more reliable? Well… everything is the same except one has run time type errors, while the other doesn’t… which one would you call more “reliable”? The answer is obvious.

So the claim is not that statically typed languages produce correct programs or better engineers. The claim is much narrower and much stronger: holding everything else fixed, static typing removes a class of runtime failures that dynamic typing allows. That statement does not rely on infinities, randomness, or empirical observation. It follows directly from what static typing is.

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#174
post #149

Earlier quoted context omitted.

>I don't think this happens most of the time, but it does mean that static typing isn't a strict upgrade in terms of reliability. It is a strict upgrade in reliability. You're arguing for other benefits here, like readability and simplicity. The metric on topic is reliability and NOT other things like simplicity, expressiveness or readability. Additionally, like you said, it doesn't happen "most" of the time, so even…

Readability and simplicity can increase reliability, because simple readable code is easier to review.

From a practical perspective, most programmers will agree with me when I say that static types are more readable.

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#175

Earlier quoted context omitted.

this makes me want to move to a haskell (or any hard fp language) shop in 2026..

I've been using Haskell professionally for the last 5 years, I definitely hope I can continue!

happy to hear that, do you happen to know good places to connect with haskell teams ?

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#176
post #153
post #121

Earlier quoted context omitted.

> The best argument for dynamic types systems, is enjoying debugging in production. This comment is either severe snark or severe ignorance.

Please, do elaborate... If you remove passes of a compiler, you, looking at it whilst running, are the compiler.

I agree. So I write tests. I use architecture to defend against the risk of super-rare code paths where I wouldn't rapidly notice if they broke. I dogfood so I find prod bugs before users do.

None of this seems that new. Even people who write TS code still write tests and still ship bugs and still have to think about good architecture patterns, like the ones in the linked post.

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#177
post #149

Earlier quoted context omitted.

Readability and simplicity can increase reliability, because simple readable code is easier to review.

From a practical perspective, most programmers will agree with me when I say that static types are more readable.

Sure. That’s a different kind of argument from the absolutist argument you were making earlier.

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#178
post #177

Earlier quoted context omitted.

From a practical perspective, most programmers will agree with me when I say that static types are more readable.

Sure. That’s a different kind of argument from the absolutist argument you were making earlier.

Right and it’s completely off topic. This is a tangent you decided to turn the conversation toward. Tangents are fine, I’m just saying that you are wrong on both the main topic and the tangent, which is also fine.

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#179
post #177

Earlier quoted context omitted.

Sure. That’s a different kind of argument from the absolutist argument you were making earlier.

Right and it’s completely off topic. This is a tangent you decided to turn the conversation toward. Tangents are fine, I’m just saying that you are wrong on both the main topic and the tangent, which is also fine.

The point is that a dynamic language will in some cases enable code that is simpler and more readable (and hence probably more reliable) because sometimes the simplest code is code that wouldn’t type check. Even if statically typed languages are more readable on average, this fact invalidates your claim that statically typed languages are strictly better in terms of reliability. This can only be true if you artificially restrict attention to the subset of programs in the dynamic language that could have been statically typed.

By the way, could you tone down the rhetoric a notch?

Re: Functional programming and reliability: ADTs, safety, critical infrastructure

#180
post #179

Earlier quoted context omitted.

Right and it’s completely off topic. This is a tangent you decided to turn the conversation toward. Tangents are fine, I’m just saying that you are wrong on both the main topic and the tangent, which is also fine.

The point is that a dynamic language will in some cases enable code that is simpler and more readable (and hence probably more reliable) because sometimes the simplest code is code that wouldn’t type check. Even if statically typed languages are more readable on average, this fact invalidates your claim that statically typed languages are strictly better in terms of reliability. This can only be true if you artificia…

My claim is not invalid. It’s just being evaluated against a different question.

The original post says that claims like “static typing improves reliability” are unfalsifiable and therefore just vibes. That’s false, because the claim being made is not empirical to begin with. It’s a statement about language semantics.

Holding everything else constant, static typing eliminates a class of runtime failures by construction. Programs that would fail at runtime with type errors in a dynamic language are rejected before execution in a statically typed one. That is not a hypothesis about the real world, teams, or productivity. It’s a direct consequence of what static typing is. No evidence or falsification is required.

When you argue that dynamic languages can sometimes enable simpler or more readable code that may be more reliable in practice, you’ve changed the claim. That’s a discussion about human factors and development process. It may be true, but it does not invalidate the original claim, because it addresses a different level of analysis.

Additionally in practice it isn’t true. Your entire argument flips context and is trying to point out a niche corner case to show that my overall correct argument is not absolute. You’re already wrong practically, and you’re also wrong absolutely.

So the correct framing is:

- At the language level, static typing is strictly more reliable with respect to runtime type errors.

- At the human/process level, tradeoffs exist, and outcomes can vary.

Calling the first claim “invalid” only works if you silently replace it with the second. That’s the source of the disagreement.

Post reply on HN