reading/how_not_to_learn_rust
how_not_to_learn_rust
dz /
reading /
how_not_to_learn_rust
Summary
Reading: How not to learn rust
Node Tree
Nodes
not_prepared_high_step
|
content
|
mistake 1: not prepared for first high step. stop trying without trying, and put in the time. Lots of new things to learn.
|
make_a_graph
|
content
|
mistake 3: start by implementing a graph algorithm. this is a variation on "don't make a linked list" the language makes it very hard to do build these kind of structures.
|
dont_read_compiler_errors
|
content
|
mistake 4: don't read compiler errors. Rust's compiler is a good teacher and precisely explains problem. Newbies should use "cargo check".
|
children
|
reddit_cargo_check (follow-up on cargo check)
|
rust_functional
|
content
|
insist to make it functional. Rust solves problems that functional programming tries to solve in different ways. Ownership isn't just about memory safety: one mutable reference means most sources of data inconsistencies are removed, without going functional.
|
parents
|
best_practices_other_languages
|
rust_dynamic
|
content
|
try to make it dynamic. Instead of writing functions that take in one trait A and return trait B (uses dyn box, some overhead), take advantage of generics. Use dyn sparingly.
|
parents
|
best_practices_other_languages
|
getters
|
content
|
fine-tune privacy and data protection with getters. Rust fixes this with ownership. Rust most often reaches this goal by letting your types be essentially consistent.
|
parents
|
best_practices_other_languages
|
build_lifetime_heavy_API
|
content
|
mistake 7: build lifetime-heavy API. When designing structs of a new library, prefer to own the data. Don't prematurely optimize with reference-based structs.
|
remarks
|
author learned lesson hard way with library termimad
|
hyperlink
|
https://github.com/Canop/termimad
|
use_unsafe_abuse_unwrap
|
content
|
mistake 9: use unsafe. abuse unwrap. Intermediate solution: use expect. Pick one of the error libraries.
|
design_everything_at_start
|
content
|
mistake 11: design everything at start. Rust will surprise you, and compiler makes it easy to refactor because it will guide you to consistency.
|
learn_wrong_rust
|
content
|
If you're using these keywords in your program, you might be learning rust the wrong way: Rc, dyn, unsafe, Deref
|