Etymology of Rust Language Terms

My impression of reading crate documentation is that much of Rust's community assume a fairly high level of understanding of systems programming and computer science. Perhaps that high level of assumed prior knowledge is one of the reasons that the language is often described as hard to learn.

Here is an example from docs as of Dec 2016. Without prior knowledge of what the terms “box“ and “destructure” mean, the introduction of the chapter "Box Syntax and Patterns" is hard to comprehend:

Currently the only stable way to create a Box is via the Box::new method. Also it is not possible in stable Rust to destructure a Box in a match pattern. The unstable box keyword can be used to both create and destructure a Box.

As someone who came to Rust with prior experience largely in very high level dynamic languages, especially Python, some of the terminology has been a little confusing.

Here are some notes that I've put together that may be useful for others. It will expand with time. Corrections are welcome. Ping me on Twitter or Reddit.

  • “static”, e.g. 'static lifetime
    Seems to come from the C keyword, which itself is probably recycled from an earlier language. Indicates that a variable has a static location in memory (although its value may change, i.e. it is not constant).
  • “unit” - e.g. unit struct, unit (())
    Comes from the term "unit type" of type theory, types that contain one value and thus no information. Imagine a Boolean object that could only store true. That's a unit type. Booleans could be implemented as the union of two unit types, True and False.
  • “move” - e.g. move semantics, contrasted with copy semantics
    Used fairly heavily in C/C++ texts, indicating that the owner changes (not the data!). Avoids unnecessary copying of data, e.g. should be a faster, simpler runtime.
  • “box” - e.g. Box::new(datum) - tells the compiler to allocate datum on the heap rather than the stack. rustc provides the ability for you to customise a Box's allocation an de-allocation behaviour with lang items.

Other terms I'm still looking into:

  • trait (was this an invention by Graydon et al to describe something that looks like but isn't an interface or behaviour?)
  • ownership (does this have a deeper/more technical meaning than the intuitive one that I've developed?)
  • lifetime (reading into Wikipedia's RAII article, it looks like this term was in use before its development, e.g. pre-1985)
  • Drop (is this just a shorter term for destructor?)

The question that I always have when encountering an English term used in a specific field, e.g. computer science, or community (how many definitions of the term "object" are there in programming?), is that the common English is only approximately correct. For programming it's slightly worse, as everything is a metaphor. Does that mean the term has been in use for 30 years and has developed a very technical and precise meaning.


Acknowledgements: many thanks to _habnabit on irc.mozilla.org#rust for reviewing the post