Rust Unlimited Intro - Three Times Failed

Rust Unlimited Intro - Three Times Failed Introduction Rust has topped Stack Overflow’s “most loved language” survey for years, but its learning curve is equally famous. I started and quit learning Rust three times since 2023 before finally getting past the initial barrier. This is the story of that journey. Why Learn Rust? Performance & Safety: Memory safety without garbage collection — no more GC pause nightmares or segfaults Modern Toolchain: Cargo, rustfmt, and Clippy create a seamless build/test/lint experience that makes C++ tooling feel archaic Type System That Catches Bugs Early: The compiler catches an incredible amount of errors before runtime — fewer 3 AM on-call wake-ups Growing Industry Adoption: From Linux kernel modules to cloud infrastructure (AWS, Cloudflare), Rust is becoming the standard for systems-level work Three Attempts, Three Failures Attempt 1: Ownership sent me running The first three chapters of The Rust Book felt comfortable — modern syntax, immutability by default, elegant pattern matching. Then Chapter 4 on Ownership hit: ...

2026年4月14日 · CoderAmedal

三入三废的Rust的入门

三入三废的Rust的入门 前言 Rust 连续多年在 Stack Overflow 的"最受喜爱语言"调查中排第一,但同样有名的还有它的学习曲线。我从 2023 年开始,前后三次打开 The Rust Book,又三次关上——直到最近才终于摸到了一点门道。这篇文章记录我反复放弃又重新开始的过程,以及这次觉得终于"入门了"的几个关键点。 为什么要学 Rust 对我个人而言,有几个朴素的动机: 写过高并发服务被 GC 停顿坑过:Rust 无 GC 的内存安全保证,解决了"要性能还是安全"的两难 Cargo 生态太舒服了:一个命令搞定构建、依赖、测试、发布,比 C++ 的 CMake 地狱友好太多 类型系统的安全感:Rust 的类型系统让很多 bug 在编译期就被拦截,而不是半夜被报警叫起来排查 三次放弃的心路历程 第一次:所有权直接劝退 第一次翻开 The Rust Book,前三章还挺舒服——语法挺现代的,变量默认不可变,模式匹配很优雅。到 第四章 所有权那里,一切戛然而止。 fn main() { let s1 = String::from("hello"); let s2 = s1; println!("{}", s1); // 编译错误! } 我真的愣住了,心想"凭什么赋值一下就把原变量废了?"——后来才明白这是 Rust 所有权转移(move) 的核心,目的是在编译期就标记哪些内存只能有一个 owner。当时理解不了这套心智模型,就放弃了。 第二次:生命周期劝退 几个月后又鼓起勇气再读,这次咬着牙过了所有权。但到了生命周期标注,再次崩溃: fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { if x.len() > y.len() { x } else { y } } 'a 是什么?为什么需要手动标?编译器不是能推导生命周期吗?——实际上编译器有时候确实搞不清返回的引用到底来自哪个参数,需要人工标注来约束。但当时的我不理解背后的借用检查器逻辑,只觉得是在和编译器打架。 ...

2025年10月24日 · CoderAmedal