Skip to content

Commit a8caf40

Browse files
committed
feat: blog
1 parent fa9293c commit a8caf40

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/blog/specificity.typ

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#import "../../templates/blog_post.typ": conf
2+
#import "../../templates/utils.typ": sidenote
3+
4+
#show: conf.with(
5+
page-title: "Case studies in specificity: API docs and boolean choices",
6+
date: "2026-01-30",
7+
)
8+
9+
I was doing a coding assignment recently, and noticed the provided package's `unique` function didn't specify whether it kept only the first item in every consecutive region of equal items. Instilled with a healthy wariness of Undefined Behavior#sidenote[nasal demons!!], I didn't want to assume it did so, even though that's the usual interpretation of that function. It was even more eye-raising because this was a library for parallel operations, so there could have presumably been some weird out-of-order shenanigans going on#sidenote[Divide and conquer doesn't consider items sequentially.] that cause it to take arbitrary items in every consecutive region. Equality is associative, after all---maybe something could cook wrt that?
10+
11+
After some tests and double checking the source code, it turned out to keep the first, anyway. Neat.
12+
13+
I remembered this being a problem when I browsed the corresponding Rust documentation before. So, since I'm getting nerd sniped, here's a lit review:
14+
- C++: specified (#link("https://en.cppreference.com/w/cpp/algorithm/unique.html")[`std::unique`])
15+
- Rust: not specified#sidenote[This sent me forum hunting/testing at least once before] (#link("https://doc.rust-lang.org/std/vec/struct.Vec.html#method.dedup")[`Vec::dedup`])
16+
- R: doesn't specify the default behavior, but has a parameter that lets it keep the rightmost item instead, which implies the default is to keep the leftmost, LMAO, hilarious secret third option (#link("https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/unique")[`base::unique`])
17+
- Python (and a few others): doesn't... seem to exist? The internet keeps saying "roll your own"
18+
19+
The R specificity issue in particular reminded me of a hot take blog post I read on never using checkboxes: #link("https://www.teamten.com/lawrence/programming/checkboxes/"). It's pretty good. I recommend reading it.#sidenote[I ran into this myself when using an #link("https://momijizukamori.github.io/bookbinder-js/")[imposer] and got confused by a "Alternate Page Rotation (AKA Flip on Long Side)" checkbox. Applying the post's principles, I would've been theoretically less confusing if it was phrased as "printer page rotation: #sym.ballot Flip on short side (standard page rotation) #sym.ballot Flip on long side (alternating page rotation)"]
20+
21+
While trying to find the article again, I also found this similar post on toggle buttons: #link("https://axesslab.com/toggles-suck/"). Toggles and checkboxes both represent boolean states, but toggles might worse, it seems.

0 commit comments

Comments
 (0)