Prepare the exercises in the following list according to the sessions they are assigned to. Each exercise should take about 30min to complete, if approached right. There are 2 times 42 exercises (what a surprise). The first 42 are to warm up and get comfortable with Rust. The second 42 are a little more complex and require either a clever algorithm or a good design. Make use of any tool at your disposal and do work in groups to reflect upon the different solutions possible:
Credit: The exercises are taken from Exercism, you can find many other languages to practice there and a helpful community. You can also find solutions to each exercise. In you own interest, only look at these solutions after spending at least 30min on an honest attempt to each exercise.
Learning Goals:
- Understand why are types important for programming in General
- Understand how can types help support efficiency, safety, and security
- Know basic types in Rust and understand how they compare to Python
- Understand the differences between scalar types, compound types, and structs
- Apply Numeric Types, Strings, and Pointers in your programs.
- Apply Tuples, Arrays, Vectors, and Hashmaps in your programs.
-
Exercise Review:
-
Lecture: Why do we need types and what can we do with them?
-
Project: Creating preliminary Data Structure and Logic for our Game of Clack
Additional Reading:
- Rust Pointers in C: https://blahg.josefsipek.net/?p=580
Learning Goals:
- Understand head and stack and their usage and implications for structuring programs
- Understand the need for and pitfalls of pointers
- Understand the difference between mutable and immutable types
- Understand how C, Python and Rust handle memory
- Understand Ownership and Borrowing and Rust for both mutable and immutable types
- Analyse and resolve issues arising from Ownership and Borrowing in your own code
Additional Reading:
- https://depth-first.com/articles/2020/01/27/rust-ownership-by-example/
- https://fasterthanli.me/articles/declarative-memory-management
The detailed content of each Session will be added here during the term.
Learning Goals:
- Understand and apply important principles of systems design
- Know and apply the Separation of Concerns principle
- Know and apply the Don't Repeat Yourself Principle
- Know and apply the KISS Principle
- Know and apply the SOLID Principle
- Know and apply the YAGNI Principle
- Avoid premature optimization
-
Exercise Review
-
Lecture
- Programming Principles
- Project
- Create Basic Data Structure and Simple Frontend for Clack
Learning Goals:
- Understand the basics of object-orientation
- Know and understand how to build a Struct in Rust
- Develop a basic understanding of Traits and Generics
- Get to know Enums and understand when to use them
- Understand Generics and Enums
- Apply Pattern Matching
-
Exercise Review
-
Lecture:
- Object Orientation and Generic Types in Rust
- Enums and Pattern Matching
- Project:
- Building Game, Turn and Clacking Function
Learning Goals:
- Get an Advanced understanding of Abstract Types
- Understand the differences between Trait Object and Generics
- Know how to write own Traits Object and Generics
- Know how to use Generic Functions and Type Parameters
- Understand Polymorphism, Apply Generic Traits and Operator Overloading
- Know and apply Utility Traits
Learning Goals:
- Understand the differences between object-oriented Programming and functional Programming
- Know and apply higher-order functions in Rust (aka Iterator Adapters)
- Understand and apply closures in Rust
- Using and apply functional patterns to collection types in Rust
UTF-8:
- Encoding: https://en.wikipedia.org/wiki/UTF-8
- BOM: https://en.wikipedia.org/wiki/Byte_order_mark
- Grapheme Clusters: https://hsivonen.fi/string-length/
Strings in Rust:
- https://www.simonwenkel.com/notes/programming_languages/rust/strings_with_rust.html
- https://chrismorgan.info/blog/rust-fizzbuzz/
- https://dev.to/dsysd_dev/string-vs-str-in-rust-understanding-the-fundamental-differences-for-efficient-programming-4og8
- https://betterprogramming.pub/strings-in-rust-28c08a2d3130
- https://www.linkedin.com/pulse/understanding-string-str-utf-8-byte-arrays-inrust-luis-soares-m-sc--dnwcf/
- https://fasterthanli.me/articles/working-with-strings-in-rust
- String Conversion: https://stackoverflow.com/questions/41034635/how-do-i-convert-between-string-str-vecu8-and-u8
- Byte Strings: https://blog.burntsushi.net/bstr/
- Grapheme Clusters: https://hsivonen.fi/string-length/