Making A Rust Project; Rust Language Basics

About This Course

  • We will learn to program in Rust

    • Work through a textbook
    • Write weekly homeworks
    • Write a 500+ line project
  • Goal: leave as competent Rust programmer (course objectives in syllabus)

About Rust

  • Rust is a "systems programming language" intended as a replacement for C/C++

  • Rust offers a unique type system that allows static automatic memory management: mallocs and frees can be inserted by the program as needed

    • The automatic memory management constraints make writing Rust programs harder than one might expect
  • Rust provides safety guarantees against common types of error. It also provides an "unsafe" mode to escape some of these guarantees when needed. Safe Rust programs are guaranteed to not have memory errors or data race conditions

  • Rust programs tend to have similar performance to C programs, better readability than C++ programs, be harder to write than either, and to be reliable and safe

  • Concurrency and functional programming features are first-class in Rust

  • Nice module and separate compilation system with package manager

Installing Rust

  • Install rustup tool: http://rustup.rs

      curl https://sh.rustup.rs -sSf | sh
    
  • Use rustup to install more of the Rust ecosystem

      rustup component add rustfmt
      rustup component add clippy
    
  • Now you're platform-independent and have access to nightly, beta and stable builds

Hello World In Rust

  • Initialize Cargo project

  • Edit provided program

  • Build and run program

Rust Testing

  • Built-in support for unit tests integrated with language and Cargo build manager

  • Can express positive and negative tests, conditional tests

Rust Program Documentation

  • Integrated doc comments as expected

  • Neat feature: doc tests

  • Integrated with Cargo

  • Works better with libraries than binaries

Rust Language Documentation

  • The course textbook (other books I've seen are kind of sketch)

  • "The Rust Book" online

  • The API docs

  • Various websites (linked from course page)

Homework 1: Build an app

  • Skills needed:

    • Git / Github
    • Programming ability
    • Ability to follow instructions
  • Time needed:

    • Estimated 8 hours
    • Plus 3 hours for the reading
    • Plus 3 hours for next week's reading (to get caught up)
Last modified: Monday, 24 June 2019, 6:01 PM