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:
- Rust is a systems programming language with a focus on safety, especially safe concurrency.
- 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:
- cargo and package management
- OOP with leveraging struct, impl and traits in Rust
- scopes & lifetime
- match
- option
- 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:
- std::thread allows a thread spawn child threads. Read manual to understand move closure.
- ARC (Atomically Reference Counted) allows program to share read-only memory between threads.
- std::sync::Mutex uses Mutex to explicitly acquire lock before mutating shared memory.
- std::sync::automic provides a bunch of lock-free functions which is way light-weight than using Mutex
- std::thread::mpsc is a memory FIFO queue which allows multiple senders and one single receiver
- rayon A 3rd-party data parallelism library for Rust
- crossbeam epoch-based garbage collection
- 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:
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
- rust API doc
- Rust Concurrency Explained
- Rust Programming Tutorials
- intro_rust()
- The book — Rust programming language
Versioning
- Sunday, December 23 Initial version