TWiR quote of the week

Coincidentally, I just started writing some rust… I find this sentiment strange; people don’t look to other languages because you can’t do something in c++, but more often because you can.

John Carmack


From the discussion of this quote:

I actually found C++ very expressive. const functions and const generics are great. I don’t have problems with C++ in saying what I want to say. The problem is to avoid saying what I don’t want to say.


From irlo: [Idea] Improving the ergonomics when using rc (emphasis added):


(This is not the case; Rust attempts to be implicit or explicit based on a valuation of the reasoning footprint and being implcit/explicit where that helps more than hurts… This quote is controversial and doesn’t fit QotW)


Everyone here is very aware of what C++ has become, so this fate is considered and actively avoided.


** bheisler **

Rust is kind of nice in that it lets you choose between type erasure and monomorphization, or between heap-allocation and stack-allocation, but the downside is that you have to choose.


From DeltaPHC on (unofficial) community Discord server:

Pollution is what happens when everyone mutably borrows the air at the same time


Because it’s not something the standard library has to include
. . . .
Rust is not trying, and has never tried, to be “batteries included”.


Two potential quotes from the same Reddit thread:

The borrow checker breaks you down so that it can build you back up, stronger and more resilient than you once were. It also had me do all sorts of weird things like catch flies with chopsticks and scrub counters to a polish.


I always think of borrowck as an angel sitting on your shoulder, advising you not to sin against the rules of ownership and borrowing, so your design will be obvious and your code simple and fast.



Also it seems (to me!) that, because of this, the for loop is a lonely orphan to all the iterator chaining oodness in rust.

I’d say he’s the elder in this family. One of those who can finish every dispute by listening to all involved and deriving the conclusion on every step of the whole chain, without need of the collect 's pet (you know who I’m referring to).

Source: Why is rust's for loop not an expression


I love Rust because it reduces bugs by targeting it’s biggest source… me.



Response to John Carmack saying “writing Rust code feels very wholesome”.

If you code in rust, you know what he means.
It’s an overwhelming feeling of completeness pouring out of your being through your brainwaves and into the global human consciousness, causing a positive net shift and reducing human suffering globally. This newly generated positive energy’s existence is only possible from bringing order to chaos and reducing the entropy of the universe, increasing the time for all conscious beings to experience it in all of its beauty before its eventual heat death. Only the truest programmers who take the rust pill and follow its guidance will know this feeling: the feeling of mastering your physical domain to the point where you can wrangle with its fundamental laws at the just the right macroscopic scale that allows for you to achieve the exact results you want in the least time, efficiently using as much of your conscious effort as possible without going past the breaking point. I never could have written a comment like this until programming in rust… Since then I’ve been a more creative, intelligent, more enjoyable person to be around and it’s all thanks to rust. I’ve even begun borrow checking my own thoughts now and have a much safer thought process because of it, as well as a deeper intuitive understanding of what exactly the creation of thoughts is in the mind.


They forgot the part where they were euphoric, not because of the approval of any thought leader, but because they were enlightened by their own intelligence.

About code using immediately-invoked closure like if let Err(e) = (|| -> io::Result<()>{…})():

Haskell has do notation; we have don’t notation


From, comparing Rusts safety guarantees with seat-belts.

Say the same thing about seatbelts in a car. If you don’t plan to have accidents, why do you need seatbelts?

Car accidents, like mistakes in programming are a risk that has a likelihood that is non-zero. A seatbelt might be a little bit annoying when things go well, but much less so when they don’t. Rust is there to stop you in most cases when you try to accidentally shot yourself into the leg, unless you deliberately without knowing what you are doing while yelling “hold my beer” (unsafe). And contrary to popular belief even in unsafe blocks many of Rust’s safety guarantees hold, just not all.

Just like with the seatbelt, there will be always those that don’t wear one for their very subjective reasons (e.g. because of edge cases where a seatbelt could trap you in a burning car, or because it is not cool, or because they hate the feeling and think accidents only happen to people who can’t drive).


TWiR 273 had some good reads again!

This one aptly summarizes just how much our consolidation work has paid off!

… the experience I had in 2019 was dramatically better than the first time I touched the language. After a month I’m feeling very comfortable, and looking forward to writing more.

Ryan Ragona on his blog post: Learning Rust in 2019


/u/Quxxy on Reddit:

Can you eli5 why TryFrom and TryInto matters, and why it’s been stuck for so long ? (the RFC seems to be 3 years old)

If you stabilise Try{From,Into}, you also want implementations of the types in std. So you want things like impl TryFrom<u8> for u16. But that requires an error type, and that was (I believe) the problem.

u8 to u16 cannot fail, so you want the error type to be !. Except using ! as a type isn’t stable yet. So use a placeholder enum! But that means that once ! is stabilised, we’ve got this Infallible type kicking around that is redundant. So change it? But that would be breaking. So make the two isomorphic? Woah, woah, hold on there, this is starting to get crazy…

*new person bursts into the room* “Hey, should ! automatically implement all traits, or not?”

“Yes!” “No!” “Yes, and so should all variant-less enums!”

Everyone in the room is shouting, and the curtains spontaneously catching fire. In the corner, the person who proposed Try{From,Into} sits, sobbing. It was supposed to all be so simple… but this damn ! thing is just ruining everything.

… That’s not what happened, but it’s more entertaining than just saying “many people were unsure exactly what to do about the ! situation, which turned out to be more complicated than expected”.


mikesu9: What is the ! type?
LousyBeggar: The never type for computations that don’t resolve to a value. It’s named after its stabilization date.

LousyBeggar, on reddit


A quote on the topic of trust, and by extension, security.


Nobody contributed. Rust started writing itself to avoid human bugs.

Asimov needs a 4th law to #![forbid(unsafe_code)] .

– rat9988 and CUViper on Reddit.