TWiR quote of the week

Thanks to the borrow checker, you can’t generally tell the difference between shallow and deep copies in rust unless the type happens to have interior mutability. This makes shallow copies the clear winner for the majority of use cases in rust, and so it’s simply not something the average rust author thinks about every day.

@ExpHP in Contracts of the Clone trait?

(Long, but I found it insightful.)

4 Likes

Python and Go pick up your trash for you. C lets you litter everywhere, but throws a fit when it steps on your banana peel. Rust slaps you and demands that you clean up after yourself.

Nicholas Hahn in One Program Written in Python, Go, and Rust

15 Likes

Imagine Rust failed, why did it fail?

A team developing a key piece of security infrastructure decided to use Rust, but due to the unforgiving nature of the compiler, the team ended up relying on “unsafe” too often, and the resulting released product had more flaws than the previous release. One specific version had an uninitialized memory bug which could cause spurious apparent USB messages. A USB-connected sensor affected by the bug was being used in a defense installation, and the incorrect message triggered an ML-based pattern recognition system to infer a higher-than-tolerable probability of an imminent attack. The team at the installation determined that such an attack was going to happen too quickly to allow for the normal queries up the chain of command, and instead took it upon their own initiative to launch countermeasures. The subsequent chain of events: strikes, counterstrikes, desperate reactions, etc, led to the eradication of all mammalian life from the surface of the planet. Eons later, the follow-up reptilian intelligence never developed strong static typing, and used Reptile-Perl to write their launch control software, resulting in their rockets always exploding before making it into orbit.

/u/steven807 on Reddit

7 Likes

Are we trying to steal the JVM’s “compile once run everywhere” concept?

No, we just borrow it mutably.

/u/llogiq re: Stabilization of wasm-wasi target announcement on Reddit

18 Likes

This post by @rubberduck203 should be the Mantra of Rust and Open Source:

https://internals.rust-lang.org/t/allow-external-crate-to-use-unnecessary-feature-on-stable/10517/36

2 Likes

Rust is 5 languages stacked on top of each other, except that instead of ending up like 5 children under a trenchcoat, they end up like the power rangers.

15 Likes

You can write safe C++, but you can not accidentally write unsafe rust.

6 Likes

So he went from 1000$ a month to 0 a month, by rewriting a script with Rust.

‘Rhymes’ on dev.to summarises the economical value of writing performant code, in An example of why performance matters (with Python and Rust).

“He” is André Arko, lead dev of Ruby’s Bundlr, who got a 230x speedup in rewriting his bundlr log-parser in rust.
I’d recommend mr. Arko’s piece to anyone: it really captures that incredulous feeling of empowerment people get from Rust :blush:

7 Likes

Yes, of course we don’t call Python an “unsafe language” - but if we don’t call Python an unsafe language, it’s unfair to conclude that Rust is unsafe, since Rust actually does a better (imo) job of segregating and controlling unsafety.

/u/NoraCodes in https://old.reddit.com/r/rust/comments/ccdiup/what_is_rusts_unsafe/etn4sbg/

2 Likes

“[that unsafe function] might actually be safe for all I know. Feel free to investigate further!” – Lokathor, on writing a Rust wrapper for SDL

2 Likes

You shoot yourself in the foot. Nothing happens to the foot because it wasn’t declared mutable #rustlang

Elena Nadolinski on Twitter.

Originally suggested by @SenojEkul.

8 Likes

Roses are red,
Rust-lang is fine,
cannot borrow `i` as mutable more than once at a time

7 Likes

@drXor from internals engaging in UB poetry.

4 Likes

Perhaps a better way to explain this is: you cannot ever get a function pointer to an intrinsic.

The compiler will just throw a block of ice in your face.

nagisa on Zulip

3 Likes

Rust isn’t training wheels, it’s a containment vessel and some minimal failsafes.

/u/yawpitch - on reddit

5 Likes

Rust clearly popularized the ownership model, with similar implementations being considered in D, Swift and other languages. This is great news for both performance and memory safety in general.

Also let's not forget that Rust is not the endgame. Someone may at one point find or invent a language that will offer an even better position in the safety-performance-ergonomics space. We should be careful not to get too attached to Rust, lest we stand in progress' way.

-- llogiq

9 Likes

-- @H2CO3: Println! - use named arguments from scope?

6 Likes

H2CO3 on whether Rust is an OOP language:

Rust is…

…a language whose main goal and promise is to bring compile-time-proven memory safety and thread safety together with runtime performance, ideally without compromising either;
…which is achieved via a unique combination of half-century-old and novel good ideas from the history of programming language design; drawing heavily on
…interface-/protocol-/typeclass-/trait-/whatever-you-call-it- based programming complementing real, parametric polymorphism aka "generics" aka "type-level functions";
…making the strong static typing easier to digest for the programmer via extensive and smart type inference;
…mixing in the basics of algebraic type systems found in traditional statically-typed so-called functional languages, such as Haskell and its family;
…as well as the superb pattern matching abilities of said languages;
…allowing as syntactic sugar for function calls what many consider "THE object-oriented syntax";
…although the latter was never the essence of object-oriented programming – according to some, myself included, it is instead encapsulation, which Rust also provides via the simple concept of visibility modifiers;
…while it also cleverly manages mutable state, allowing for the so-called procedural-imperative paradigm to be embedded into the language without undermining its safety.

@H2CO3 in Is Rust OOP? If not, what is it oriented to??

5 Likes

@kornel about blocking Tokio threads:

If you want to block threads, get your own threads.

7 Likes

@dholroyd in How are you using rustfmt and clippy?.

6 Likes