about
RustStory Prologue
6/8/2022
Rust Story Code

RustStory Prologue

Getting started

"If you always do what interests you, at least one person is pleased."
- Katharine Hepburn

0.0  Getting Started

This is a story about the Rust Programming Language. Rust was originally designed by Graydon Hoare at Mozilla Research, with contributions from many others including Brendan Eich, the creator of JavaScript. The Rust compiler and its libraries are open-source. Rust is a programming language that is being developed starting from ideas from C++, with some echos of JavaScript. However, it has many features that are uniquely its own:
  1. Crates and Modules are the building blocks for Rust programs. They are housed in packages created by Cargo, the Rust package manager.
  2. Data is, by default, immutable. You use the mut keyword to allow a variable to be modified.
  3. Ownership of data - each value has only a single owner, but ownership can be tranferred. Also, code can borrow a view of the data without transferring ownership by constructing a reference or a slice.
  4. Traits are similar to interfaces or abstract classes and support polymorphic operations. They are frequently used to bound the set of types allowed as type parameters for a generic type.
Rust's goal is to be a safe system programming language. Safe means code generated by Rust is free of memory access and data race vulnerabilities. System programming language means that Rust programs are fast and able to use platform resources.

0.1  Primary Links

Rust has a very rich ecosystem of learning materials - see References in 3.0, below. Here are links to materials from this site:
Link Description
RustModels.pdf Slide presentation:
Type safety, Rust ownership, object model, generics, code structure
Code for RustModels Slides present a number of code fragments. These are the complete programs.
References Things to read and view for more details
This story Models, Data, Operations, Objects, Libraries
Code for this story Complete program sources for code fragments in the story
RustBasicDemos Repository of code demonstrations, many written to explore Rust
To get started, you need: basic knowledge of the language, a tool chain to build programs, and the interest to start building with much less than perfect knowledge. Rust models are unique, and the only way to fully understand them is to write code. You will find demo code in Rust Basic Demos will help you get started.
  1. Basic Rust Knowledge:
    This story provides some of what you need, along with code examples in the RustBasicDemos repository. Also see the references at the end of this page.
  2. Rust Tool Chain:
    For any environment, download Rust tools. This gives you Cargo, the Rust package manager, and rustc, the Rust compiler. This is all the tooling you need to start. Visual Studio Code
    Rust doesn't come with an IDE, but VS Code gives you a text editor with a terminal pane, from which you enter Cargo commands build, run, clean, and more.
    You will want to install the VS Code plugin Rust (rls) which gives you some syntax highlighting and code completion. The VS Code model expects you to use JSON files to configure build and debug launchers. I have found that occasionally hard to use, and often requires more effort to configure that I am willing to spend on this tool. Working in the code editor and launching Cargo commands in the terminal works well for me. For Windows I use the default PowerShell terminal. You can replace that with the Windows CMD terminal if you wish. On linux the default bash terminal works well.
  3. Now start:
    Download the RustBasicDemos. Open VS Code and open one of the folders in RustBasicDemos, then Cargo build and Cargo run in the terminal. You should see output in the terminal.

0.2  Contents

  1. Prologue
    Getting started.
  2. Rust Models
    Key ideas and background needed for later chapters.
  3. Data
    Types provided by Rust, usage, collection demos.
  4. Operations
    Functions, methods, std library facilities
  5. Structs
    Objects, Traits
  6. Libraries
    Several of the most often used libraries are discussed and code examples provides.
  7. References
    Quite complete set of references for the Rust Programming Language

0.3  References:

Reference Link Description
Rust (Programming Language) - Wikipedia Well written summary of the Rust language.
Considering Rust - Feb 2020 - Jon Gjengset Great what-is-it video, with code snippets and a lot of mind setting conversation by a very knowledgable presenter.
intorust.com A few short screen casts - Nicholas Matsakis, ...
readrust.net/getting-started Nice set of "first-look" posts.
rust-learning repository Extensive list of resources: books, videos, podcasts, ...
A half-hour to learn Rust Code fragments with commentary that cover most of the Rust ideas.
A Gentle Introduction To Rust A good walkthrough most of the Rust ideas.
The Rust Programming Language Long but gentle walkthrough of the Rust Language
An alternative introduction to Rust Steve Klabnik
Rust pain-points Steve Donovan
Rust by Example Rust docs - walkthrough of syntax
Getting Started with Rust on Windows and Visual Studio Code Install Rust, Verify, Configure Visual Studio Code, Create Hello World, Create Build Task, Configuring Unit Tests, Configure Debugging,
rust-lang.org home page Links to download and documentation
rust cheat sheet Quite extensive list of cheats and helpers.
More References Basic, intermediate, and advanced references
  Next Prev Pages Sections About Keys