Being an intermediate Rust programmer in one day

Edward Li
3 min readDec 24, 2018

--

As an Amazonian, writing 6 pagers is what I do almost every day. The beauty of 6 pagers is it allows you to focus on problems you are going to solve with a neat structure. So within this blog, I’m gonna leverage a typical 6 pagers template to explain how to become an intermediate Rust programmer in one day. Read this blog to know more about 6 pagers.

Problem Statement

#1 I was told Rust has a steep learning curve even for people have C/C++ programming experience like me. Is that true?
#2 If it’s not true, how to become a Rust programmer in a short time?

Tech Proposal

Step#1 Watch intro_rust() videos and do exercises (~1 hours)

intro_rust() is a fantastic website for Rust beginners to understand what make Rust different with other programming languages e.g. C++, Java and Python.
Takeaways:

  1. Rust is a systems programming language with a focus on safety, especially safe concurrency.
  2. Concept of ownership, shared borrows and mutable borrows

Step#2 Dive deep into Rust syntax (~2 hours)

By watching videos in Rust Programming Tutorials presented by decode will give you basic understanding on how Rust code looks like. You can quickly map Rust syntax to programming languages you are familiar with. Feel free to speed up when watching the videos.
Takeaways:

  1. cargo and package management
  2. OOP with leveraging struct, impl and traits in Rust
  3. scopes & lifetime
  4. match
  5. option
  6. I/O basics

Step#3 Rust Concurrences (~3 hours)

Watch this video(Rust Concurrency Explained) to familiar yourself with concurrency programming in Rust which is most important feature Rust brings. Rust provides library-based concurrency features. All the language provides are ownership and borrowing.
Takeaways:

  1. std::thread allows a thread spawn child threads. Read manual to understand move closure.
  2. ARC (Atomically Reference Counted) allows program to share read-only memory between threads.
  3. std::sync::Mutex uses Mutex to explicitly acquire lock before mutating shared memory.
  4. std::sync::automic provides a bunch of lock-free functions which is way light-weight than using Mutex
  5. std::thread::mpsc is a memory FIFO queue which allows multiple senders and one single receiver
  6. rayon A 3rd-party data parallelism library for Rust
  7. crossbeam epoch-based garbage collection
  8. tokio — A run time for writing reliable, asynchronous, and slim applications with the Rust programming language.

STEP#4 Enjoy programming Rust

Great! You are all set for practicing! Find some open-source projects to read and write!
I want high-light some:

  1. aws-lambda-rust-runtime
  2. rayon
  3. tikv

Conclusion

Based on my learning experience, I don’t think Rust has an extremely steep learning curve. I managed to understand Rust and do some exercises in one day. In my opinion Rust is way more developer friendly programming language than any other systems programming language. It offers confident, productive systems programming.

Trade-off between compiling efficiency and safety made within Rust is really smart. With the features Rust offered, compiling is relatively time-consuming than C++ and Java. It makes sense to me, all developers need to do is to have a powerful dev desktop to be more productive.

Based on 3 party libraries developed in the ecosystem, developers can leverage Rust for application software development as well.

Appendix

Reference

  1. rust API doc
  2. Rust Concurrency Explained
  3. Rust Programming Tutorials
  4. intro_rust()
  5. The book — Rust programming language

Versioning

  1. Sunday, December 23 Initial version

--

--