87 points · by azhenley · 5y ago · 13 comments
But IMO the most useful formal method in Software Engineering is modeling your code as an FSMs, for example using StateCharts UML notation [2,3].
That way even junior developers can reason about complex realtime systems.
Next close come Algebraic Type Systems, but they're usually not available in mainstream PLs.
Unfortunately Formal Specification/Verification tools like TLA+, Alloy, etc. are less practical for most real life projects.
--
[1] https://en.wikipedia.org/wiki/Decision_table
[2] https://en.wikipedia.org/wiki/UML_state_machine
[3] https://en.wikipedia.org/wiki/State_diagram#Harel_statechart
The typical argument against Formal Methods is based on cost, to which the reply could be "Well what's the cost of broken code?"
I'm glad the tools and languages to do FM are getting more common and familiar.
Verification is definitely a big concern for junior developers who don't know how to write good tests, however, beyond a certain level of expertise, the big challenge becomes validation.
If written properly, tests do a pretty good job at verification. Formal proofs only take care of rare edge cases (since tests can never be exhaustive), but many times, it's possible (and recommended) to write code in a way to minimize such rare edge cases anyway.