TWiR quote of the week

The amount of careful thought I've seen put into [Rust's] design – crafting async/await to work in no_std environments, or the new inline assembly syntax – has produced a language that is not only better than what I could have designed, it's better among axes I was not even aware existed prior to reading the Rust RFCs.
-- First impressions of Rust

16 Likes

This is not a commentary on the actual issue that triggered this response. Rather, I just liked the response.

9 Likes

Whoop whoop, this feels like being knighted, and all the work totally paid off. Iteration after iteration after iteration, and it really was just Rust pushing me into doing "what's right", which also happens to be fast as a freebie.

-- Sebastian Thiel in [performance] beating git in `git verify-pack` ✅ 🚀 · Issue #1 · Byron/gitoxide · GitHub

1 Like

There is a more technical term for "wrong", too - maintaining invariants is maintaining "soundness". Code that breaks invariants is called "unsound".

-- Frustrated? It's not you, it's Rust

You're smarter than Rust - and you may need to rethink your design a bit, so it's possible to tell the compiler about it.

And when you do, you'll discover mistakes you never knew you could make.

-- Reddit - Dive into anything

6 Likes

“macros are for when you run out of language”. If you still have language left—and Rust gives you a lot of language—use the language first.

-- https://twitter.com/pcwalton/status/1294676975575896064

13 Likes

Not only is our new Rust code simpler and cross-platform, but it’s faster to boot!

~ Why We’re Bringing Astropad Cross-Platform | Astropad

1 Like

Programming's always been frustrating. Rust just makes the frustrations more likely to happen to you, and not your users.

/u/legowerewolf pointedly summarizes Rust's guiding principles in Reddit Discussion "Frustrated? It's not you, it's Rust"

16 Likes

Regarding alternatives to inheritance:

1 Like

Man, I love it when the #RIIR (“Rewrite It In Rust”) virus mania spreads like wildfire :slight_smile:

rggr on lobste.rs gitoxide: pure rust implementation of git | Lobsters

1 Like

Rust is a very different beast for me. It is a *much* bigger and *much* more capable language. However, I've found that it is, in many ways, a lot more restrictive in how you can approach problems. I frequently find myself being perplexed at how to eloquently solve a problem. When I discover the idiomatic way of doing it I'm usually both blown away by the brilliance of it and a bit disheartened by how difficult it would be to come up with that solution by myself :-).

-- /u/mikekchar @ Reddit - Dive into anything

6 Likes

"With great power comes difficult to read extremely-generic signatures.", as they say.

-- /u/Lokathor @ Reddit - Dive into anything

11 Likes

I wonder if quote of the week can be used to bust some myth.

But what's the point of a const function then?

It makes code like this compile:

const FOO: i32 = my_const_fn(13);

That code is rejected unless my_const_fn is a const fn .

That is the only effect const has on fn . And AFAIK we never say anything else anywhere in the docs, so I do not comprehend where all these extra assumptions come from that you have been making. I'd really like to know as I'd like to avoid people making such false assumptions. :slight_smile:

I always thought that const means all of these happens in compile time and none of it goes to runtime except those called in non-const places.

Code in const "places" (usually called const contexts) must run at compiletime. So this statement is true but I don't think it means what you think it means. In particular, format is impossible to use in const contexts:

const FOO: String = format!("abc"); // does not compile

Since format! can only be used in non-const-contexts, that means it never happens at compiletime. Or rather, it is never guaranteed to happen at compiletime -- optimizations can do whatever they want, but there's no guarantee they ever happen.

-- @RalfJung github comments https://github.com/rust-lang/rust/pull/75894#discussion_r477192216

1 Like

I like the idea, but it's there's not really a pointed quote in that comment I think.^^ Maybe except for this part.

But what's the point of a const function then?

It makes code like this compile:

const FOO: i32 = my_const_fn(13);

That code is rejected unless my_const_fn is a const fn .

That is the only effect const has on fn . There is no effect on optimizations or runtime code.

(Slightly edited as well.) But still that's rather long. And we're starting to artifically construct a quote rather than take a real one.^^

I don't know if it qualifies for quote of the week but I'm glad it was posted here so I could read it

6 Likes

@zrk are you perhaps shocked by it like me and another member did, thinking that const can allow generating better code without side effects?

In response to In this mesh class, what's wrong with my use of lifetimes? - #4 by trentj

Many hours of discussion with the borrow checker leads me to concur with @trentj here.

8 Likes

Disappointed with Path

6 Likes

Advice by @alice, relevant to every Rust nauplius who attemps self-referential structs. (emphasis added)
From How to resolve "error[E0499]: cannot borrow ... as mutable more than once at a time" in this case - #3 by alice

7 Likes

Slightly OT here, but should that compile error say something about self-referential structs?

1 Like