HN Books @HNBooksMonth

The best books of Hacker News.

Hacker News Comments on
Programming Rust: Fast, Safe Systems Development

Jim Blandy, Jason Orendorff · 3 HN points · 10 HN comments
HN Books has aggregated all Hacker News stories and comments that mention "Programming Rust: Fast, Safe Systems Development" by Jim Blandy, Jason Orendorff.
View on Amazon [↗]
HN Books may receive an affiliate commission when you make purchases on sites after clicking through links on this page.
Amazon Summary
Rust is a new systems programming language that combines the performance and low-level control of C and C++ with memory safety and thread safety. Rust’s modern, flexible types ensure your program is free of null pointer dereferences, double frees, dangling pointers, and similar bugs, all at compile time, without runtime overhead. In multi-threaded code, Rust catches data races at compile time, making concurrency much easier to use. Written by two experienced systems programmers, this book explains how Rust manages to bridge the gap between performance and safety, and how you can take advantage of it. Topics include: How Rust represents values in memory (with diagrams) Complete explanations of ownership, moves, borrows, and lifetimes Cargo, rustdoc, unit tests, and how to publish your code on crates.io, Rust’s public package repository High-level features like generic code, closures, collections, and iterators that make Rust productive and flexible Concurrency in Rust: threads, mutexes, channels, and atomics, all much safer to use than in C or C++ Unsafe code, and how to preserve the integrity of ordinary code that uses it Extended examples illustrating how pieces of the language fit together
HN Books Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this book.
Yep. Although in my opinion Programming Rust [0] is better even though dated. The word goes that the 2nd edition will be out by the end of the year.

[0]: https://www.amazon.com/Programming-Rust-Fast-Systems-Develop...

hobos_delight
I read v1 of The Book and then Programming Rust, and I found the latter to be better suited to the way I absorb things.

Both are great and I still refer to The Book (and Programming Rust) from time to time.

I'd be really keen to pick up v2 of Programming Rust.

I know everyone says how good Rust's documentation is but I tried learning Rust with The Rust Book and found it frustrating: too long and wordy on the easy bits and without useful insight on the hard bits. I ended up buying Programming Rust by Jim Blandy [0] on a recommendation from HN comments and found it must easier to learn from. I'm already familiar with several other languages, which that book assumes, so your milage may vary.

[0] https://www.amazon.co.uk/Programming-Rust-Jim-Blandy/dp/1491...

fold_left
> I know everyone says how good Rust's documentation is but I tried learning Rust with The Rust Book and found it frustrating: too long and wordy on the easy bits and without useful insight on the hard bits. I ended up buying Programming Rust by Jim Blandy [0] on a recommendation from HN comments and found it must easier to learn from. I'm already familiar with several other languages, which that book assumes, so your milage may vary.

> [0] https://www.amazon.co.uk/Programming-Rust-Jim-Blandy/dp/1491....

Thanks for tip, the Rust Book is working well for me so far but it's good to know of other good options.

bschwindHN
> everyone says how good Rust's documentation is

I don't know about everyone else, but when I say that I'm mostly referring to the auto generated documentation you get from Cargo. One of Rust's greatest strengths is having uniform documentation for every project.

indemnity
You’re not alone. I found the Rust book very hard going, whereas Programming Rust was just the right amount of rigor and interesting examples for me.
Boulth
Seconded. I read Programming Rust and it was excellent. Too bad there is no second part. I didn't get too far in the Rust book though.
steveklabnik
This is why I'm glad we have both; I don't think one resource could ever satisfy everyone. Pumped to see Rust in Action getting closer to publication too!
crispinb
I remember mentioning in a thread here a while back that I so enjoyed flicking through your/Carols' book online that I wished I was learning Rust, though I was unlikely for practical reasons to do so. Well now I am, and that exposure via a pleasurable read was what seeded the idea.

It's true it's not a terse breakneck intro for advanced programmers. But as an experienced developer, I'm enjoying it no less for that. In any field I've been involved in, I've always enjoyed revisiting fundamentals, and in the context of learning a new (and let's be honest, not very easy or familiar) programming language this seems even more appropriate.

Perhaps if I were learning Rust for work I'd want something more distilled to get me started. Even there I'm sure I'd read TRPL at some point. But right now I'm finding it an enjoyable way to get underway for my own interest.

steveklabnik
Thanks!
indemnity
Ah, awesome, another Rust book. I'll keep an eye out for it.

Thanks!

AlchemistCamp
I just bought Rust in Action a couple weeks ago (after having gone up to chapter 11 in the No Starch book). It's definitely good to have both. I'll probably do 1/2 the new book, finish the 1st one and then finish the new one.

I did pretty much the same thing with Dave Thomas's Programming Elixir book, bailing halfway through, using a 2nd resource to consolidate, and then returning to finish it.

I like learning Rust so far. The main thing I wonder is what kinds of projects are good to do while learning. I went from Node to Rails to Phoenix and normally I just rewrite web apps I've previously created in the language I'm learning. With Rust, it feels like I should build something different, something lower-level like a tool, an emulator or a 2D game.

steveklabnik
This is a common issue. You don’t have to go low level; you can build anything, including web apps.
jasondclinton
> I like learning Rust so far. The main thing I wonder is what kinds of projects are good to do while learning. I went from Node to Rails to Phoenix and normally I just rewrite web apps I've previously created in the language I'm learning. With Rust, it feels like I should build something different, something lower-level like a tool, an emulator or a 2D game.

If your experience is web apps, I would stick with that; Rust has a great web app story in the form of at least two mature frameworks.

Somewhat agreed... If I hadn't started with the O'Reily book[1], would probably order. If the eBook were half the price, would get it anyway.

Edit: looks like it's a few bucks less on Amazon

[1] https://www.amazon.com/Programming-Rust-Fast-Systems-Develop... [2] https://www.amazon.com/Rust-Programming-Language-Steve-Klabn...

Apr 23, 2019 · integricho on Rust's 2019 Roadmap
Off-topic, but I'll just ask, is the book Programming Rust: Fast, Safe Systems Development 1st Edition [1] still relevant / worth reading (given the book is based on an older, although stable? version of Rust)? If it isn't, does anyone know maybe if a 2nd, updated edition can be expected?

[1] https://www.amazon.com/Programming-Rust-Fast-Systems-Develop...

steveklabnik
It covers Rust 1.17. It is almost entirely still accurate; you’d need to set the edition back to 2015 in your Cargo.toml for some examples to work, but the foundations are still very solid. You’d have to adjust some import paths to get them to work in Rust 2018 thanks to the module system improvements. It won’t tell you about new features, but the big picture is still fully accurate, you might just need to tweak some details, and read some newer release notes to learn about some new things. It’s still a great book.
integricho
Thanks, that's quite reassuring, I wasn't sure whether it's a good investment of time or not.
kod
It's still probably the most well-written Rust book.
nobleach
That whole module system change really took me for a ride a few months back. After a "routine" rustup, none of my code worked. I have to be honest here that I still don't think I have a good grasp on how files/packages are imported in Rust....
>the borrowing/ownership semantics of rust (at the time I looked at it) felt needlessly over complicated.

Taking a wild guess here, but it sounds like you maybe referring to issues addressed by Non-Lexical Lifetimes (NLL)?

Reference: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll....

NLL are a part of Rust 2018 Edition.

Three complementary books are the best resources:

- The Official book: https://doc.rust-lang.org/book/

- The Rust By Example book : https://doc.rust-lang.org/rust-by-example/

- Programming Rust (O'Reilly) : https://www.amazon.com/Programming-Rust-Fast-Systems-Develop...

est31
NLL only modes aren't available on stable Rust atm. What edition 2018 has right now is migrate mode NLL. In order to fully enjoy NLL, you'll have to use Rust nightly and do #![feature(nll)] or -Z borrowck=mir -Z two-phase-borrows, both flags being independent of the edition you're using.

Edit: removed outdated behaviour of migration mode.

TheCoelacanth
The only difference between migration mode and NLL-only mode is that errors produced by the NLL checker are downgraded to warnings if the old borrow checker doesn't produce any errors on that code[1]. This is strictly more permissive than NLL-only and completely equivalent if you treat warnings as errors.

You can completely take advantage of any NLL feature, you just might be able to write code that should be an error but is instead a warning if you hit an edge case (I think this would be considered a bug in one of the borrow checkers since NLL is supposed to allow anything that the old borrow checker allows).

[1] https://github.com/rust-lang/rust/issues/46908

steveklabnik
This is incorrect. NLL is on for Rust 2018 code.

The transition mode is for Rust 2015 code.

est31
Please see the code: https://github.com/rust-lang/rust/blob/68650cacf23c60ee2f346...

In edition 2018, migration mode is turned on.

I learned myself about this today btw, after I saw this PR: https://github.com/rust-lang/rust/pull/58342

I think I was mistaken about one point though which is that migration mode is erroring if one of the two errors. IIRC migration mode was introduced that way but it seems to have been changed to be a bit more tolerant than AST borrowck.

Anyways, more NLL fun is to come, and it's to come to both editions.

burntsushi
> What edition 2018 has right now is migrate mode NLL which emits an error if either NLL borrowck or AST borrowck think there is an issue with your code.

If that were true, then this example would fail to compile, since it fails with the old AST borrowck: https://play.rust-lang.org/?version=stable&mode=debug&editio...

See: https://rust-lang-nursery.github.io/edition-guide/rust-2018/...

est31
Oh right, seems it got a bit more tolerant. The mode's still called migration mode though, full NLL is to be unleashed later on: https://github.com/rust-lang/rust/issues/57895
pjmlp
NLL still doesn't cover all use cases, for example common GUI patterns with callbacks having references to internal fields.
Mar 15, 2018 · AlexeyBrin on Learning Rust
There are two books with similar titles and I'm under the impression that you don't talk about the one the OP had in mind:

https://www.amazon.com/Rust-Programming-Language-Steve-Klabn...

https://www.amazon.com/Programming-Rust-Fast-Systems-Develop...

I think both are good books, I already have the second one and preordered the first.

None
None
rayascott
I assumed he’d misnamed the book, switched the words around, as your first link points out (“The Rust Programming Language”), there isn’t actually a book called “Rust Programming”, and “Programming Rust” seemed like the closest approximation.
Feb 06, 2017 · gcp on Rust's 2017 Roadmap
There's several external books. I started from this one (via Safari):

https://www.amazon.com/Programming-Rust-Fast-Systems-Develop...

Animats
"This title has not yet been released."
gcp
You can get early access to it via various places, e.g. http://shop.oreilly.com/product/0636920040385.do
Aug 14, 2015 · aturon on Rust in 2016
There's an O'Reilly book in the works: http://www.amazon.com/Programming-Rust-Jim-Blandy/dp/1491927...

And The Rust Programming Language (https://doc.rust-lang.org/book) is on its way to paper publication.

The newly minted Rustonomicon (https://doc.rust-lang.org/nightly/nomicon/) that covers deeper aspects of Rust is hopefully destined for the same.

DominikD
All of these are great (really, not being smug) but FWIW neither TRPL nor the Rustonomicon address my needs (Rust by example is probably the closest). It may be related to the weird set of skills and needs I have but hey, I'll post about my experience anyway in case someone shares my POV. ;)

My background includes OS development (Windows COM), driver development (C for kernel mode driver and C for HW firmware development), web development (C#/ASP.NET and JavaScript - both in browser and Node.js), and most recently HW simulation using C++/SystemC. Mixed bag, I know. What I want to use Rust for is desktop app development. I could go C, but that's a lot of manual labor. I could go C# but I don't like paying cost of the runtime on desktop. I could go C++ but I don't like getting my soul crushed. I tested viability of Node (and Python, actually) for desktop apps but it just didn't fit my needs.

So I want to love Rust. And I kinda do. Initially I didn't like certain things (bits of syntax mostly) but I've learned to love them. The problem is: none of the resources tell me interesting stuff all the way through the system. I feel like knowledge could be laid out with all the details from "this is syntax" to "this is what happens" to "this is what you can/cannot do" to "this is why this happens" to "this is what this means to the compiler" to "this is what happens under the hood/in asm".

I'd also[1] love to have something that roughly maps rust to C and gives me clear explanation of pros/cons of various approaches. It wasn't immediately obvious to me if I can have static methods. Of whether it's important to have self mutable (or not) as a method param. Or how to organize structures now that I have to keep mutability in mind. I know this comes with time but I'd love a kick of sorts. :) Best ideas tend to come from reading existing pieces of code but rarely knows if author is worth mimicking. :S

Either way - I'm invested and I like what I'm seeing. Great work guys!

[1] or these could become one thing, dunno

therockhead
I had a conversation with two developers at work were trying to convince me that C++ 11/14 feels like a totally different language and a lot more enjoyable to work with. While I wasn't sold I did make a mental note to take look with an open mind.
DominikD
It's true. But bad stuff is still there for you to (ab)use. I don't like C++ because (at this point at least) it's not opinionated enough. 10 ppl can write 10 completely foreign (in terms of feel) pieces of code and all of them would be correct in some sense of the word.
Gankro
Fundamentally Rust just doesn't define things well enough to be able to answer the "this is what it compiles to" issue.

There's some things like `Option<&T>` which we guarantee but really it's a lot of "man, if the compiler was smart enough...". Even then, a stray annotation can wall LLVM and kill any chances of perf (e.g. if the function is not a candidate for cross-crate inlining).

DominikD
The "doesn't define things well enough" thing bothers me a little bit. I actually care in my real job what happens after compilation and why. Not being able to guesstimate what happens in machine by looking at source is no deal breaker for what I want to use it for but I'd imagine this to be an issue for stuff like OS/driver/firmware development.

But I don't think this is the most important thing I want to know. What I want Rust to be is the opinionated low cost, higher level language. "Do things this way, dummy!" is what I need the most (at this point of my familiarity with the language at least).

DominikD
Oh and on an a semi related note - I get sad every time I find an interesting looking link just to end up with 404 on the other side. This - for whatever reason - happens far too often with Rust related resources. Trying to get to "The Advanced Rust Programming Language Book Draft" - no dice. Page 404s, so does repo. Lifetime of links does matter, guys. ;(
dbaupp
That book is now https://doc.rust-lang.org/nightly/nomicon/ . It was published at .../adv-book/ for approximately 1 day, but then was quickly moved.
mrec
It's probably a niche interest, but do you know if anyone's working on a Rust equivalent of Stroustrup's Design and Evolution of C++? I found that book a huge help in grokking the "why"s behind the language, and gaining some degree of mechanical sympathy with it.

I appreciate that the vast majority of Rust's D&E happened in the open, so most of it's probably still available, but it's been a long and twisty road since Graydon's initial public post and picking out a coherent narrative from umpteen separate slowly-linkrotting fora would be no small task.

steveklabnik
I dream of doing such a thing someday. I'm not aware of anyone that's actively working on it.

I did a talk at FOSDEM 2015 along these lines, which apparently got lost with a lot of them :/

May 16, 2015 · 3 points, 0 comments · submitted by onderkalaci
HN Books is an independent project and is not operated by Y Combinator or Amazon.com.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.