Secure Systems Engineering, Spring 2024

Lab 1

Please read this description in its entirety before starting the lab!

Introduction

This lab will be our first experience writing Rust, a programming language for secure systems engineering. To quote the Rust book:

The Rust programming language helps you write faster, more reliable software. High-level ergonomics and low-level control are often at odds in programming language design; Rust challenges that conflict. Through balancing powerful technical capacity and a great developer experience, Rust gives you the option to control low-level details (such as memory usage) without all the hassle traditionally associated with such control.

Learning objectives

In this lab, you will:

Helpful resources

Lab setup

If you did not set up Rust during lecture, you’ll need to install it first.

Open a terminal and enter the following command:

$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

The command downloads and runs the rustup script, which installs Rust:

Rust is installed now. Great!

I highly recommend installing VSCode and its Rust extension while learning Rust. Take a minute to do so before you begin – part of Rust’s value is in its robust tooling and developer support. There also is support for other IDEs and text editors. For example, if you are a l33t h4x0r and want to use Vim, you can still take advantage of the tooling.

Note. If you were unable to bring your laptop to class today, or cannot set up Rust right now, you can also complete this lab using the Rust Playground (though the experience might be degraded on a tablet or smartphone).

Part 1: A guessing game

Go through Chapter 2, “Programming a Guessing Game” in the Rust book. Follow each step, line-by-line. By the end, you will have a working guessing game – and have written your first real Rust program!

I encourage you make sure to type each line into your editor, rather than copy-and-pasting. It may seem silly, but typing the code well help you get the muscle memory of writing Rust faster. I will be available if you want to ask any questions.

Part 2: Reflection

After you’ve completed the guessing game, add comments to the top of src/main.rs answering the following three questions:

  1. Identify three Rust syntax structures used in the design of the guessing game. How are these syntax structures similar to programming languages you have seen in the past? How are they different?
  2. While the game logic itself is straightforward, how did working with Rust’s syntax and features influence your approach to solving the problem?
  3. What aspects of Rust did you find easy to grasp, and what parts required more effort or additional resources?

What to turn in

Upload the following to Blackboard before the due date above: