Meaning – Does ‘By Construction’ Mean ‘From the Ground Up’?

meaning

I'm reading a book about Rust programming and below is an excerpt from it.

The immiscibility of shared and mutable references really demonstrates its value when writing concurrent code. A data race is possible only when some value is both mutable and shared between threads—which is exactly what Rust's reference rules eliminate. A concurrent Rust program that avoids unsafe code is free of data races by construction. We'll cover this aspect in more detail when we talk about concurrency in Chapter 19, but in summary, concurrency is much easier to use in Rust than in most other languages.

From the context I feel that "by construction" means "from the beginning" or "from ground up". Is my understanding correct? I actually tried to look it up in the dictionary but I can't find this usage.

Best Answer

Your understanding is correct in context.

"By construction" means "by the way it is built". (Whether the "it" refers to the Rust programming language, or an individual Rust program, is unclear to me.) Most programming languages cannot or will not detect if a program contains a data race, so you are free to build programs with data races if you so choose. A skilled and careful programmer will avoid data races in their code, but this is an extra layer on top of what the language permits or does not permit. Rust, on the other hand, contains safeguards that prevent you from building data races at all; code that would allow data races is not valid. So Rust programs are indeed safer "from the beginning".

Even though data races effectively constitute undefined (or weakly defined) behavior for concurrent code, most "safe" languages (such as Java and Go) permit them, and they are a reliable source of concurrency bugs. In contrast, Rust's type system rules out data races at compile time.

Source: https://m-cacm.acm.org/magazines/2021/4/251364-safe-systems-programming-in-rust/fulltext

Related Topic