TWiR quote of the week

"The cost of zero-cost abstractions". Looks like a title for some sci-fi...

4 Likes

Writing code in Rust makes me feel like I have an obligation to make code as fast as possible in a way other languages don’t, just by surfacing the costs better. Sometimes I need to remind myself that actually it’s fast enough already.

http://thume.ca/2019/04/18/writing-a-compiler-in-rust/

20 Likes

I used to think of programs as execution flowing and think about what the CPU is doing. As I moved to rust I started thinking a lot more about memory: how the data was laid out in memory, and how ownership of different parts of memory is given to [different parts of the program] at run time.

-- Oliver Gould

(slightly edited from spoken to written style)

https://www.youtube.com/watch?v=FYGS2q1bljE

Time of the quote: https://youtu.be/FYGS2q1bljE?t=280

10 Likes

– zeroexcuses
from https://users.rust-lang.org/t/can-a-struct-that-own-an-instance-of-a-struct-also-maintain-a-reference-to-this-instance-without-a-generic-lifetime/28542/9

10 Likes

I like that one since it's in some ways a modern take on a classic:

Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious.
– Fred Brooks, The Mythical Man-Month (1975)

18 Likes

why doesn't 'static, the largest lifetime, not simply eat all the others

https://twitter.com/Gankro/status/1133435497806815232?s=09

'static is biggest but actually,, weakest of lifetimes, becuase it is subtype of every lifetime

'static is big soft friend

pls love and protect it

11 Likes

This is also an incredibly important shift when trying to write performant software. See also this great C++ talk: https://youtu.be/rX0ItVEVjHc

3 Likes

https://twitter.com/mountain_ghosts/status/1134739348593827841

apparently I wrote Building Git to explain a complex problem to rust devs who could then help me build it in rust

1 Like

&mut obj as *mut *mut c_void :metal:
i just hear scandinavian death metal reading that

Nick Gideo via Rust VST chat

6 Likes

it's true that the more i look at other people's unsafe code the more i relax at people questioning how much i use unsafe code

@Lokathor on the community discord

5 Likes

What does it mean to be an expert in Rust?

Understands lifetimes

u/aesamattki on reddit.

1 Like

Lol, my initial reaction was "It does. That's why it outlives all the other lifetimes" :joy:

10 Likes

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? - #4 by ExpHP

(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

18 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

8 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

20 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.

17 Likes

https://www.reddit.com/r/rust/comments/cb49lb/coworker_rust_doesnt_offer_anything_c_doesnt/etdb7c5?utm_source=share&utm_medium=web2x

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

8 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:

8 Likes