TWiR quote of the week

Off-by-one error generally isn't a hard problem: most of the time there are between 2^n and 4^n ways to write the same program using different initial values and stop values for n counters.

Note that the off-by-one part is a joke; I wouldn't take it too seriously. See TwoHardThings for some attempts at sourcing.

7 Likes

From @blonk in Difficulty in inventing bugs.

11 Likes

This section can be skipped entirely if you know everything about computers.

From @Gankra in Rust's Unsafe Pointer Types Need An Overhaul - Faultlore

5 Likes

The nomination surprises me, as that article is full of like-minded arrogance, such as:

Unless you literally work on a C/C++ Standard Committee or are named Ralf Jung I will not be accepting your Umm Actually’s on these definitions and terms.)

7 Likes

Here's one that is quite enlightening. This is only part of the post and it's actually not the essence, but I'm not going to paste a huge Venn-diagram here. @Yandros' full post can be read here.

8 Likes

(from rust-lang Zulip)

7 Likes

!Send + Sync is "it's a long story".

@alice in A better term than "Thread safe"? - #7 by alice

9 Likes

I think Rust's beauty is that it allows you to do anything, as long as it is not dangerous. So you can afford to get as close to the fire as possible, knowing that you won't accidentally step too far and burn yourself.

-- /u/schungx @ https://www.reddit.com/r/rust/comments/tsf52g/design_pattern_problem/i2t2d3y/

(In reply to my comment about how Rust's approach to message-passing is more "share memory, guarded by using message passing on the access token" thanks to the internal heap pointers in things like Vec<T>.)

8 Likes

"A language that doesn't affect the way you think about programming, is not worth knowing." -- Alan J. Perlis, Epigrams on Programming

11 Likes

I think this is the opposite: a language that does affect how you think about programming is a language that fails to be intuitive (that shows as a steep learning curve). This is a disadvantage of Rust, one that I accept because I know there is no other way.

I've seen similar sentiments echoed before, elsewhere. The point it's making is the same one that's argued whenever people say you should learn LISP because it'll make you a better programmer.

There's no such thing as a perfectly intuitive programming language because algorithmic thinking isn't something that comes to us intuitively. That's why the first language is always the hardest.

It's helpful and mind-expanding to learn new paradigms and force yourself out of old cognitive ruts. Thus, from an "improving your ability to solve problems and function as a programmer" perspective, what makes Rust difficult is valuable because it's forcing you to learn to think about problems in new ways.

That's the distinction between necessary complexity and complexity due to ill-considered design. (Similar to how, in video games, there's a difference between genuine difficulty and difficulty caused by something like a crappy control scheme.)

27 Likes

I'd like to nominate @ssokolow's reply.

12 Likes

Another epigram from the source @glyn mentioned:

In a 5 year period we get one superb programming language. Only we can't control when the 5 year period will begin.

Alan J. Perlis, Epigrams on Programming, 1982

The prophecy fulfilled.

11 Likes

Why Rust mutexes look like they do - Cliffle

Relying on the programmer to always read, comprehend, and remember the documentation – and then do everything right, every time – is how we get bugs.

17 Likes

The Tower of Weakenings: Memory Models For Everyone - Faultlore

15 Likes

To be honest, I don't think this is possible (people tend to not care about what allowed in C and just do it), but striving to get there will definitely make Rust pointers better.

I think you are misunderstanding the quote. The implication is that Rust makes it easier to use raw pointers correctly than C. Of course doing things with the "whatever happens to compile" mindset unfortunately burnt into most C users is mechanistically easier in C (sometimes) than the equivalent would be in Rust, but the result is often UB so by definition incorrect, meanwhile confidently knowing what's correct and guaranteed (and staying in guaranteed-safe land) is much easier in Rust.

8 Likes

:joy:

4 Likes

If you haven't tried Rust, just grab it and work through the first couple of chapters of the rust book and do something wrong. Because the error messages in Rust is like a hug from the compiler.
"You did your best, yes, yeah. You see here, where you've done this ? No you can't do that, no it's bad. What you probably want to do is this."
It teaches you Rust. The compiler is lovely.

Mark Rendle - The Worst Programming Language Ever - Mark Rendle - NDC Oslo 2021 - YouTube

10 Likes