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

top
content top
children rust/crates/regex (mentioned in reading)

URL
content URL
hyperlink https://dystroy.org/blog/how-not-to-learn-rust/#mistake-1-not-be-prepared-for-the-first-high-step

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.

dive_in_without_book
content mistake 2: dive in without reading "the book"

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)

reddit_cargo_check
content reddit thread on cargo check
parents dont_read_compiler_errors
hyperlink https://www.reddit.com/r/rust/comments/qtn6vg/psa_dont_understand_an_error_in_your_ide_use/

ignore_compiler_warnings
content mistake 5: ignore compiler warnings. Also recommended: cargo clippy

best_practices_other_languages
content mistake 6: apply best practices from other languages
children getters, immutable_structures, dummy_values, rust_functional, rust_OOP, rust_dynamic, defensive_programming

rust_OOP
content try to make rust look OOP
parents best_practices_other_languages

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

immutable_structures
content build immutable structures and collections. Not needed due to rust ownership model.
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

defensive_programming
content Rust has things like Option and Result.
parents best_practices_other_languages

dummy_values
content Use dummy values.
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

ignore_non_standard_libs
content mistake 8: ignore non-standard libraries. try to find "kind of standard libraries".

use_unsafe_abuse_unwrap
content mistake 9: use unsafe. abuse unwrap. Intermediate solution: use expect. Pick one of the error libraries.

dont_look_at_sources
content mistake 10: don't look at the sources.

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