logoalt Hacker News

drutaTushar • today at 2:56 PM • 1 reply • view on HN

Partially I agree. But when it comes to errors/not-happy path - I am talking about pesky issues, driver/hardware errors which can never be mapped to any "Type". There is a reason every statically-typed programming language has Root Error type. For eg. Java has `Throwable` with two subtypes - `Error` and `Exception`. A `RuntimeException` is type that does give handle to programmers and JVM guarantees that it will be thrown. But sometimes one has to catch root "Throwable" or "Error" types in order to prevent JVM crash. It will be tedius to have formal verification theorems referring to "Throwable" in order to be formally verifiable. I guess It can be done - only if languages like Lean are expressive enough - but only using LLMS, for humans it will be quite complex. IMO - not worth. It will be repeat of "elegant" functional programming languages failing to go mainstream.


Replies

rramadass • today at 5:13 PM

My previous comments already pointed to Meyer's "Applying Design by Contract" paper which shows how to integrate exception handling with DbC. Here it is directly - https://news.ycombinator.com/item?id=48358691

Basically, you have to keep your module internals "pure", distinguish between domain exceptions (i.e. checked) vs. environmental runtime exceptions (i.e. unchecked) and push all "impure" operations to the boundary of the module.

Also see the following paper which shows how to formally model hardware faults;

Faulty Logic: Reasoning about Fault Tolerant Programs - http://www.cs.princeton.edu/~dpw/papers/faultylogic_esop2010...