Programming Rust (2/e)

Leonora F.S. Tindall, Jason Orendorff, Jim Blandy

出版时间

2021-05-04

ISBN

9781492052593

评分

★★★★★
书籍介绍
The Rust programming language offers the rare and valuable combination of statically verified memory safety and low-level control. Imagine C++ but without dangling pointers, null pointer dereferences, leaks, or buffer overruns. With this practical guide, systems programmers will understand Rust’s rules clearly and economically. You’ll learn how to express programs that Rust can prove are free of a broad class of common errors. Rust brings the benefits of an expressive modern type system to systems programming. Authors Jim Blandy and Jason Orendorff demonstrate how Rust’s features put programmers in control over memory consumption and processor use, combining predictable performance with memory safety and trustworthy concurrency. You’ll learn: How to write fast, safe, concurrent programs in Rust Rust’s rules for managing memory efficiently, including ownership, borrowing, moves, and lifetimes How to design interfaces that fit well into the Rust ecosystem Rust’s all-purpose Cargo tool for building, testing, and managing Rust packages High-level features like traits, generics, closures, and iterators that make Rust productive and flexible
AI导读
核心看点
  • 深入解析Rust内存模型与所有权机制
  • 结合C++背景讲解系统级编程与性能控制
  • 清晰图示辅助理解并发、异步及类型系统
适合谁读
  • 具备C/C++等系统编程经验的开发者
  • 希望深入理解Rust底层原理的进阶者
  • 追求高性能与安全并重的系统程序员
读前提醒
  • 建议搭配官方The Book对照阅读
  • 务必重视内存布局与生命周期章节
  • 推荐直接阅读第二版以获取最新特性
读者共识
  • 配图极佳,一图胜千言,直观易懂
  • 比官方文档更进阶,适合有经验读者
  • 讲解设计考量,被赞为最佳参考书之一

本导读基于书籍简介、目录、原文摘录、短评和书评生成,不等同于全文精读。

精彩摘录
  • "You've heard that Rust lets you write safe, fase, concurrent programs. This is the chapter where we show you how it's done. We'll cover three ways to use Rust threads: 1. Fork-join parallelism 2. Channels 3. Shared muatble state"
  • "A panic is not a crash. It’s not undefined behavior. It’s more like a RuntimeException in Java or a std::logic_error in C++. The behavior is well-defined; it just shouldn’t be happening. Panic is safe. It doesn’t violate any of Rust’s safety rules; even if you manage to panic in the middle of a stan"
  • "Stack unwinding is the default panic behavior, but there are two circumstances in which Rust does not try to unwind the stack. If a .drop() method triggers a second panic while Rust is still trying to clean up after the first, this is considered fatal. Rust stops unwinding and aborts the whole proce"
  • "以上情况的共同点是他们都由(不客气地说)程序员的错误所导致。而行之有效的的一条经验法则是:“不要 panic”。"
  • "None of these compromises are acceptable for Rust:the programmer should havecontroovervalueslifetimes,and the language should be safe.But this is a prettywell-explored area of language design.You can't make major improvements withoutsome fundamental changes. Rust breaks the deadlock in a surprising "
  • "另一方面,元组只允许用常量作为索引,比如t.4。不能通过写成t.i或t[i]的形式来获取第1个元素。"
  • "你会看到用来声明固定大小缓冲区的语法:[0u8;1024],它是一个1KB的缓冲区,用0填充。Rust没有任何能定义未初始化数组的写法。(一般来说,Rust会确保代码永远无法访问任何种类的未初始化值。)"
  • "&mut str类型确实存在,但它没什么用,因为对UTF-8的几乎所有操作都会更改其字节总长度,但切片不能重新分配其引用目标的缓冲区。事实上,&mut str上唯一可用的操作是make_ascii_uppercase和make_ascii_lowercase,根据定义,它们会就地修改文本并且只影响单字节字符。"
用户评论
比 The Rust Programming Language 要更进阶一些的书,内容组织方式也比简单罗列所有语言特性稍微更有趣一点,对于已经有其他编程经验的读者更友好一些。
和官方的The Rust Programming Language 一起食用味道更加;比官方的更加详细
如果 Rust 的书只看一本的话,我选这本(2021)
比官方的 The Rust Programming Language 要深入很多,让你真正上手 Rust!
傻瓜式教程。。没有比这本更简单、清晰、透彻的了。。比官方的那本更深入浅出
读了不下4本rust书籍,如果让我推荐一本rust书,那么我会推荐这本。比官方的还要详细,还要深入。
收藏