June 21st, 2024

Formal methods: Just good engineering practice?

Formal methods in software engineering, highlighted by Marc Brooker from Amazon Web Services, optimize time and money by exploring designs effectively before implementation. They lead to faster development, reduced risk, and more optimal systems, proving valuable in well-understood requirements.

Read original articleLink Icon
Formal methods: Just good engineering practice?

Formal methods in software engineering are considered crucial for building efficient systems, especially in large-scale, distributed, and low-level applications. Marc Brooker, an engineer at Amazon Web Services, emphasizes the importance of formal methods in optimizing time and money in software development. By using tools like TLA+ and P, engineers can explore designs more effectively before implementation, leading to faster development, reduced risk, and more optimal systems. While formal methods may not be suitable for all software types, they prove valuable in systems with well-understood requirements. The debate between upfront design and agile methodologies often stems from different approaches to requirements gathering. Brooker suggests that formalizing requirements, although challenging for certain aspects like UI aesthetics, can prevent wasted time and conflicting directions. Overall, incorporating formal methods into the software engineering process is seen as a fundamental aspect of good engineering practice, enabling faster and more efficient software development.

Related

There's more to mathematics than rigour and proofs (2007)

There's more to mathematics than rigour and proofs (2007)

The article explores mathematical education stages: pre-rigorous, rigorous, and post-rigorous. It stresses combining formalism with intuition for effective problem-solving, highlighting the balance between rigor and intuition in mathematics development.

Documenting Software Architectures

Documenting Software Architectures

Documenting software architectures is crucial for guiding developers, facilitating communication, and capturing decisions effectively. The arc42 template and C4 model offer structured approaches to achieve this, balancing detail and clarity.

Exposition of Front End Build Systems

Exposition of Front End Build Systems

Frontend build systems are crucial in web development, involving transpilation, bundling, and minification steps. Tools like Babel and Webpack optimize code for performance and developer experience. Various bundlers like Webpack, Rollup, Parcel, esbuild, and Turbopack are compared for features and performance.

Software Engineering Practices (2022)

Software Engineering Practices (2022)

Gergely Orosz sparked a Twitter discussion on software engineering practices. Simon Willison elaborated on key practices in a blog post, emphasizing documentation, test data creation, database migrations, templates, code formatting, environment setup automation, and preview environments. Willison highlights the productivity and quality benefits of investing in these practices and recommends tools like Docker, Gitpod, and Codespaces for implementation.

No Matter What They Tell You, It's a People Problem (2008)

No Matter What They Tell You, It's a People Problem (2008)

The article emphasizes the crucial role of people in software development, citing teamwork, communication, and problem-solving skills as key factors for project success. It highlights the importance of job satisfaction and team cohesion, underlining the significance of positive personal relationships within development teams.

Link Icon 13 comments
By @pjmlp - 5 months
The main issue is that most of these tools like TLA+, live in another dimension, proving something in TLA+, doesn't mean when the algorithm gets actually implemented in C, it still maps to TLA+ as proven.

Formal methods need to be like SPARK 2014, or DbC, actually part of the programming language, or being able to generate code in the target language, interop with its libraries ecosystem, and have good quality good with performance, that won't make people want to remove the generated code and rewrite it manually.

By @robocat - 5 months
I like the quote:

  “It would be well if engineering were less generally thought of, and even defined, as the art of constructing. In a certain important sense it is rather the art of not constructing; or, to define it rudely but not inaptly, it is the art of doing that well with one dollar, which any bungler can do with two after a fashion.” Arthur Wellington
Where is the boundary between finance and engineering? And Engineering is also about making optimal tradeoffs in other dimensions (he mentions time, performance, scalability, sustainability, and efficiency).
By @Almondsetat - 5 months
In my opinion formal methods are what's missing from software engineering to make it a serious engineering discipline. In all other engineering fields you have to produce calculations and "proofs" that your design ought to work. In software engineering everything is basically overcomplicated handwaving.
By @nanolith - 5 months
In my opinion, most developers should be using bounded model checking if available for their language / platform. This is certainly true for C, Rust, Java, and others.

I consider bounded model checking to be "formal methods lite". It provides most of the benefits at a lower cost of entry than using a proof assistant or building constructive proofs. Really, there's little added overhead. Perhaps 30% to 40% more time to build out the function contracts and model checking. Given that this overhead more or less prevents errors that would likely be introduced without it, I think it's a reasonable investment.

TLA+ is certainly related, since it uses an SMT solver at its base. I see it as useful for designing algorithms and protocols. A tool like CBMC or Kani provides similar guarantees at the source code level. It's not perfect, as currently CProver does not have direct threading support, but with a reasonable application of method shadowing and function contracts, even things like threading can be anticipated. Using a bounded model checker effectively means changing the design of software to work best with it. This is little different than using concepts like TDD or continuous integration.

By @kazinator - 5 months
Non-software engineering doesn't excessively use formal methods. Only where required. (Like where a system is tightly optimized.)

For instance, in electronic engineering, you don't use the most accurate model of a diode at all times. Sometimes it's just a one-way valve. Sometimes, it's just one-way valve with a 0.7V drop (if silicon).

In mass production, you will not get the accurate parts needed for the most formal model to be justifiable, and the cost of those parts would not be justified in most of the circuitry.

By @DoingIsLearning - 5 months
Is there formal methods 'tooling' similar to TLA+ that is more targeted to State Machine design and perhaps State Machine Replication?
By @erik_seaberg - 5 months
I learned some TLA+ and started reading about Coq, but I was pretty disappointed to learn of the "verification gap" between the the algorithm to be delivered in a normal programming language and the manually-restated algorithm that passed the checker. We need to make a checker's input language ergonomic enough for daily use and then "synthesize" something that runs efficiently while still being known correct, or make a checker understand everyday programs (which, not being so minimalist, probably have a much larger space of reachable states to check).
By @ChrisMarshallNY - 5 months
I worked for a [Japanese] corporation, that took “formal methods” into overdrive.

They made really, really good hardware, but it was extremely painful for us software schlubs.

That said, I don’t know if it’s really possible to do really big stuff, with a team, unless you have some degree of formality.

Best practices are usually a good place to start, and I would suggest that the degree of necessary formality, is inversely proportional to the experience of the team. If you have a lot of really experienced engineers, in a mature team that has been together a long time, the formality is still there, but doesn’t need to be written down.

I usually work alone, or as the sole technical person, in a diverse team. I’m really experienced, and don’t write much down.

But I’m also really, really formal. It just doesn’t look like it.

By @hresvelgr - 5 months
I think we might potentially be looking at this backwards. There is a great talk by Jack Rusher [1] on why having really slow iteration loops and being too disconnected from running programs creates a desire for theorem proving because it becomes the faster way to arrive at a correct solution.

I am of the belief that we need to return to modifying live environments instead of sending code through a lengthy build pipeline. Instead of trying to make live environments secure and durable we got scared and now we have modern CI/CD.

[1] https://www.youtube.com/watch?v=8Ab3ArE8W3s

By @zeroCalories - 5 months
I do often employ the simple whiteboard methods described, but I've never found the energy to learn and use stuff like TLA+. What fields do people find them useful in?
By @verisimi - 5 months
> What is TLA+? > > TLA+ is a formal language for specifying systems used in industry and academia to verify complex distributed and concurrent systems. Among others, the TLA+ methodology is successfully applied at Amazon Web Services, Microsoft, and Oracle.

https://conf.tlapl.us/home/

By @ozim - 5 months
Just wanted to post this video link in this discussion:

Glenn Vanderburg - Real Software Engineering

https://www.youtube.com/watch?v=RhdlBHHimeM

By @treprinum - 5 months
"Beware of bugs in the above code; I have only proved it correct, not tried it. " -- Donald Knuth