Hello World

About This Course

  • We will learn to program in Rust

    • Work through a textbook
    • Write weekly homeworks
    • Peer-grade weekly homeworks
    • Undergrads: Write a 1000-line project
    • Grads: Write a 5-page research paper
  • 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

  • Rust programs tend to have similar performance to C programs, similar readability to 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

  • Linux: install vendor package

  • Windows / Mac: I don't know

  • Install rustup tool

  • 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 (OK) support for unit tests integrated with language and Cargo

  • 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 (?)

  • "The Rust Book" online (second edition, mostly)

  • The API docs

Book Example: GCD

  • Simple command-line app

  • Your homework: extend it to do more things.

Last modified: Friday, 6 April 2018, 10:39 PM