Programming Rust - Jim Blandy

Programming Rust

Jim Blandy

出版时间

2016-08-25

ISBN

9781491927281

评分

★★★★★

标签

编程

书籍介绍

This practical book introduces systems programmers to Rust, the new and cutting-edge language that’s still in the experimental/lab stage. You’ll learn how Rust 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.

Author Jim Blandy—the maintainer of GNU Emacs and GNU Guile—demonstrates how Rust has the potential to be the first usable programming language that brings the benefits of an expressive modern type system to systems programming. Rust’s rules for borrowing, mutability, ownership, and moves versus copies will be unfamiliar to most systems programmers, but they’re key to Rust’s unique advantages.

This book presents Rust’s rules clearly and economically; elaborates on their consequences; and shows you how to express the programs you want to write in terms that Rust can prove are free of a broad class of common errors.

AI导读
核心看点
  • 深入解析所有权、借用与生命周期
  • 对比C++,强调内存安全与零成本抽象
  • 系统讲解并发模型与底层类型系统
适合谁读
  • 有C++或系统编程经验的开发者
  • 希望深入理解Rust底层机制的读者
  • 对内存安全与并发编程感兴趣的程序员
读前提醒
  • 建议优先阅读第二版,避免API过时
  • 部分Trait语法已变更,需留意版本差异
  • 适合配合官方TRPL作为进阶参考书
读者共识
  • 核心概念讲解清晰,优于官方文档
  • 内容详实但部分API已弃用,需甄别
  • 适合有经验者,零基础建议先看入门书

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

精彩摘录
  • "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,根据定义,它们会就地修改文本并且只影响单字节字符。"
作者简介
Jim Blandy has been programming since 1981, and writing Free software since 1990. He has been the maintainer of GNU Emacs and GNU Guile, and a maintainer of GDB, the GNU Debugger. He is one of the original designers of the Subversion version control system. Jim now works on Firefox’s web developer tools for Mozilla.
目录
Preface
1. Why Rust?
Type Safety
2. A Tour of Rust
Downloading and Installing Rust

显示全部
用户评论
Rust 是一门系统编程语言,也是许多区块链底层编程语言,不论是旧欢 Parity,还是新贵 Libra;不论是微软还是 Linux 的核心开发者都对它青眼有加。 Rust 有一些很迷人的地方,比如:AOT,内存安全性,空指针安全性,还是丰富的类型系统,异或是庞大的社区生态。这些别的语言也有,但是都没有这么彻底。 Rust 的特点也十分突出,Ownership 和 borrow、references 还有 shadow,令人眼花缭乱,最最有趣的就是你写一段程序,编译器会 blame 你很多,你就感觉是在和编译器搏斗。 学习 Rust 不只是一时兴起(早在2015年我就听闻过),也是一种拥抱变化的态度,重要的是可以让你在看众多区块链代码时不会那么心慌。 语言的趋势反映了未来的主流开发群体
Programming Rust
还是去看官方那本吧
当枕边书读完了,除了中间有些地方介绍API比较枯燥,对核心概念的讲解、对不同做法的利弊分析都非常清晰,娓娓道来的风格读起来也很舒服
很棒的书,主要面向有经验的程序员(特别是 C++ 程序员),有些地方没有官方的书讲得详细。其实最后一章 Unsafe Code 没看完,以后再看。。。600页不到的书为了公司培训做了200多页PPT,熬了不少夜,也是醉了。。。
我读过官方2018的书. 两本书都没读完. 我这样评价两本书. 官方那本书the rust programming language, 会给人可读性更高的错觉, 论清晰和透彻, 这本书好得多, 会感觉作者想得非常清楚, 讲得也非常清楚. 只是前两章难, 以及引用讲得很深. 我觉得这是我读过关于rust入门书中最清晰的一本. 我更推荐这本书. 建议: 如果读前两章觉得难, 可以跳过. 因为前两章对初学者就有很多rust知识点了, 同样, 关于引用也讲得有点深. 一句话, 不爽就跳. 说实话, 泛型引用我都没学懂, 未入门的水平..
比官网的《The rust programming language》易懂详细
可以分得清&String 和&str了,,
这本书很不错啊,例子和rust的一些特性解释都还可以,不过rust还是有点门槛,我总觉得这门语言要是不想花很多精力就不要碰。
收藏