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.

  • Your assumption is not far off; I'd say, "It is free of data races by design." However, there may be a particular meaning to the word "construction" in the Rust language -- many object-oriented languages, such as C++ and Delphi, have constructors. See what the author has to say later, when construction is covered, "in more detail." Aug 20, 2021 at 2:22
  • Thanks for the comment! I'm learning Rust and I don't think here "construction" refers to a Rust specific thing. Aug 20, 2021 at 2:25

1 Answer 1


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

  • "by the way it is built", awesome explanation for "by construction". Thanks for the answer! Aug 20, 2021 at 2:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .