TWiR quote of the week

When chatting about using async in an internal project my colleague shared a funny quote over chat:

2021 is supposedly the year of the async Rust desktop

For context, we were fighting with getting blocking code integrated with non-blocking since we wanted to do it incrementally.

5 Likes

Whoa there, you mean there is effort underway to solve the "red function / blue function" problem?
"What Color is Your Function? – journal.stuffwithstuff.com

That sounds truly awesome.

2 Likes

Taken from io_uring presentation by Tyler Neely:

I can accept code in pull requests with a small fraction of the mental energy as I would need in auditing C/C++ due to compiler's strictness

8 Likes

The consistency angle really shouldn’t be overlooked. Performance is nice, but slow and consistent can still be planned for much more easily than inconsistent.

That was the big aha moment about Rust for me when I pushed out my first project using the language. Being nervous about it I had added way too much instrumentation so that I could know how every bit of it was responding to real traffic. But as soon as I started seeing the data, I was convinced that my instrumentation code was broken. The graphs I was seeing were just so...boring. Straight lines everywhere, no variation...after 24hrs, the slowest response (not P99...literally P100) was within 75ms of the fastest response.

-- tablair @ Reddit - Dive into anything

(Especially that "But as soon as I started seeing the data, I was convinced that my instrumentation code was broken.")

9 Likes

Rust developers, on the other hand, are used to taking a lot of coffee breaks (or tea, cigarettes, sobbing, or whatever as the case may be — Rust developers have the spare time to nurse their demons).

-- @brson's tongue-in-the-cheek reference to Rust's compile times in The Rust Compilation Model Calamity | PingCAP

5 Likes

Rust's predictable performance lands another strike for the team! :grinning:

Even with just basic optimization, Rust was able to outperform the hyper hand-tuned Go version. This is a huge testament to how easy it is to write efficient programs with Rust compared to the deep dive we had to do with Go.

[..] After a bit of profiling and performance optimizations, we were able to beat Go on every single performance metric . Latency, CPU, and memory were all better in the Rust version.

Discord Engineer Jesse Howarth, in the blog post
"Why Discord is switching from go to Rust" (emphasis in original)

This Discord Blog documents tangible productivity benefits, improved performance, as well as platform maturity for Rust, great things for our community to show in 2020!
Also, the more predictable behaviour allowed them to increase cache-sizes without suffering catastrophic GC-spikes, leading to a factor-5 to factor-200 improvement, depending on the metric (the graphs are a bit too low-res to get more accurate numbers).

12 Likes

go [or Rust] style package management tools are designed to build programs that work. Not programs that work on Debian if you have the right libs installed, or on Windows 7 or newer, or whatever, but “if you compile it on an OS, it works on that OS”.

https://wiki.alopex.li/LetsBeRealAboutDependencies

8 Likes

It's a safe system programming language which just happens, unlike something like Ada, to have a critical mass of hipsters and webdevs behind it.

-- RAKtheUndead on why Rust is so popular @ Reddit - Dive into anything

(You've gotta at least grin at reading that.)

13 Likes

That is encouraging. Back in the day C and Unix were said to be promoted and spread by "hippies" from Berkeley. Sounds like Rust in on the right track then.

1 Like

Another thing we should remember when talking to other-language folks:

16 Likes

Some time later the tax man comes by. He asks to see my tally sticks from last year. Oops, now I have a problem! I need records, databases, immutable data structures, extra book keeping work. Incidental complexity.

What am I missing in my shepherds tale?

Your analogy is quite good, but I don't think it unambiguously supports mutable data structures.

The abacus will let you count faster, but is a bad medium for long-term storage. A stick with notches isn't exactly immutable, since you can cross over notches, so in a sense they're mutable but only additively. If you glue the beads of the abacus it becomes better than a stick with notches for bookkeeping but worse for counting.

You can evaluate data structures outside of computers perfectly fine like this. I would even say that this isn't figurative speech or metaphor: We're actually analysing the time and space complexity of real-world data structures. Once we get to von Neumann-style computers, the materials (RAM, CPU, etc.) just have a different cost profile which make some analogical comparisons break down a little.

A very strong property of immutable data is that you can refer to it from other data and know that it won't eventually become invalid. So immutable data can be used to annotate other immutable data (or other mutable data, for that sake, but then this recursive property is instantly lost). This is the bookkeeping part.

The radical idea of using functional or otherwise declarative programming for general purposes (rather than very domain-specific ones) comes from the observation that often the cost of immutable data structures is well within acceptable limits of our materials. And because computer programs often do a mixture between counting and bookkeeping, you get the benefits of persistency at more levels.

When the cost of immutability is too high, Haskell has come up with the ST monad, which is a type-safe way to mutate a value locally. When the cost of mutability is too high, Rust has come up with borrowed types. These notions may essentially express the same machine-level operations.

Whether you decide to complicate your program with "pure data" or "linear types", the justification is in both cases that more constraints will provide for more efficient compilation and execution strategies, at the cost of mental overhead to the programmer. So if you think e.g. linear types are worth pursuing, you're probably closer in mindset to a purely functional programmer than you think, sans the extremist attitude. :slight_smile:

2 Likes

So, Rc<RefCell<T>> is "Shut up, I don't care", while unsafe is "Shut up, I know what I'm doing"?

5 Likes

I wouldn't say that.

Sometimes it really is the right tool for the job, but it often gets abused by people used to having a GC where it's okay to hand out references like candy.

unsafe on the other hand can be thought of as the pragmatic escape hatch you sometimes need to use when doing things which are, well, unsafe... That doesn't roll off the tongue nearly as nicely as you put it though...

3 Likes

most of the quotes in this thread are very positive and sometimes funny, but looking at the original post from feburary 2015 above, we're supposed to also submit "insightful" stuff. so i guess the following one qualifies, even though it's kind of sad.

The number of crates which can be charitably described as a " barely functional list of the author's opinions wrapped around a project's c-api " is mind numbing. Picking a crate for a new problem domain is like walking through a mine-field. It feels like (when official options are not available) I need to dedicated ~3-4 weeks to just selecting and patching the dependencies I'm going to use for a project so I can be responsibly confident in them.

-- valarauca14 on reddit thread titled What do you miss about other languages when working in Rust?

10 Likes

on a more ironic note, there's also

& * 'a &'a Box || macro! mod crate extern crate #[...] String vs &str &self unwrap expect ? Rc Arc

by new community member @yjoking on this thread

src

6 Likes

"nau pli us : the first larval stage of many crustaceans, having an unsegmented body and a single eye."

At last, the proper term for a new Crustacean! (emphasis added)

25 Likes

I like "Nauplius"! :heart:
Obligatory Wikipedia link (after digging through a handful of redirects): Crustacean larva - Wikipedia
Several larval stages were apparently originally mistaken for separate species, and even today we don't know the match-up between all larvae and all adults. (Much like how Rust-the-language is still figuring things out!)

Plural is apparently Latin-style: "nauplii".

6 Likes

(emphasis added to last sentence)

13 Likes

Summoning a Rust djinn, @alice:

3 Likes