graydon2: (Default)
A long time ago I wrote on twitter (now erased): "surprising how much computer stuff makes sense viewed as tragic deprivation of sum types".

Sum types (a.k.a. disjoint unions a.k.a. tagged unions a.k.a. safe variant types) are of course wonderful and nice and everyone should have them. ML and Haskell have them, and now Rust has them, as does Swift, and Scala with case classes, and C++ kinda with std::variant, and .. lots of modern languages are growing them. Great, hurrah.

But there is just a little bit of subtlety to doing them right. The subtlety is that you have to build the language to couple together two pieces of data -- a tag (or "discriminant") and an unsafe union -- with mandatory syntactic constructs (switch or match expressions) so that you only get to access the unsafe union elements when you've already checked the tag, and the type system and name resolution systems know you're in a given case-block, and so only let you access to the union-fields (properly typed) corresponding to the tag case. It's not a hugely complex thing to get right, but you have to get it right.

There are three main degenerate ways you can fail to get it right.

  1. You can give users syntactically unguarded access to union members, say by using container.field syntax, in which case all you can do if the tag doesn't match that field at runtime is to raise a runtime error, which you can at least do systematically, but the ergonomics are lousy: it's inefficient (you wind up checking twice) and it doesn't help the user avoid the runtime error by statically forcing cases to be handled.

  2. You can do #1 but then also fail to even raise a runtime error when the tag is wrong. At which point the tag is basically "advisory", so then...

  3. You can even go a step further than #2 and not even require users to declare a tag. Just let the user "know the right case" using some unspecified method, an invariant they have to track themselves. They can use a tag if they like, or some bits hidden somewhere else, who knows.


Ok so .. Casey Muratori gave a great recent talk on the origin of, well, certain OOP-y habits of encapsulation, which is mostly about Entity-Component-System organization, but .. also a bit about sum types. He spent a lot of time digging in the PL literature and reconstructing the history of idea transmission. I just watched it, and it's a great talk and you should go watch it, it's here:



One of the things he discusses in here is that safe and correctly-designed disjoint unions aren't just an ML thing, they were around in the early 60s at least. Wikipedia thinks Algol 68. Muratori places their origin in Doug Ross and/or Tony Hoare talking about amendments to Algol 60, linking to this Tony Hoare paper but of course Hoare references PL/I there and I'm honestly not sure about the exact origin, it's somewhere around there. Point being it predates ML by probably a decade.

But another thing Muratori points out is that is that Dahl and Nygaard copied the feature in safe working form into Simula, and Stroustrup knew about it and intentionally dropped it from C++, thinking it inferior to the encapsulation you get from inheritance. This is funny! Because of course C already had case #3 above -- completely unchecked/unsafe unions, they only showed up in 1976 C, goodness knows why they decided on that -- and the safe(ish) std::variant type has taken forever to regrow in C++.

I was happy to hear this, because it mirrors to some extent another funny story I have reconstructed from my own digging in the literature. Namely about the language Mesa, a Butler Lampson project from PARC, very far ahead of its time too. There's far too much to discuss about Mesa to get into here -- separate compilation, interface/implementation splits, etc. -- but it did also have safe variant types (along with a degenerate form called "computed" which is unsafe). Presumably it picked them up from Algol 68, or Simula 67, or one of probably dozens of languges in the late 60s / early 70s it emerged from. No big deal.

Where that relatively unremarkable fact turns into a funny story is during a "technology transfer" event that happened during Mesa's life: Niklaus Wirth took a sabbatical to PARC, and became quite enamoured with Mesa, and went back home to work on what became Modula and eventually Modula 2. But Modula 2 had only degenerate variant types! He copied them not from Mesa, but in the same busted form they existed in Pascal, completely missing that Mesa did them correctly. Modula 2 variants are degenerate case #1 above (if you turn on a special checking compilation mode) otherwise case #2: tags declared but no checking at all! He even writes it up in the report on Modula 2 and Oberon, criticizing its lack of safety while simultaneously citing all the ways Mesa influenced his design. Evidently not enough.

Anyway, all this is to say: language features are easily broken, mis-copied, forgotten or intentionally omitted due to the designer's pet beliefs. Progress is very circuitous, if it exists at all!

(no subject)

Jul. 17th, 2025 07:04 am[personal profile] madbaker
madbaker: (disgruntled clown)
I buy a transit pass every month. SF Muni had an easy program where they charged my credit card with no input from me, until 2023 when they shut it down. I complained at them because their list of alternate programs
  1. hadn't been updated since 2021, and half of the ones I looked at were no longer offering a transit program;
  2. the ones that were still active were general HR programs, and mainly wanted to provide health insurance with transit a distant second.  Oh, and they were geared towards 20 employees or more.  I am doing this for me only.
I did not expect a response but actually got a helpful one - I was pointed to a website I could upload an invoice every month to reload my transit card.  Slightly more work, but only very slightly so that's what I did.

Two days ago, I repeated the process I've been following since 2023.  Unlike all the other times, I got a "rejected" notice.  WTH?  I tried a couple different things (checking the upload file to make sure it was in the right format, making sure the credit card hadn't expired, etc.) and finally, called the transit help desk yesterday.

I got bounced around several times.  Each time the person asked "So the problem is you can't log on?"  No, the problem is that your system is rejecting my invoice.  Finally I was transferred to the apparent coding firm - which is based in London.

I got a call at 3 AM this morning telling me it was resolved ("and now I can log in successfully").  When I got into work I tried again.  Same result.  It's before 5 PM there, so I called and told them "No, it bloody well is not resolved."  Oh, and please note I am in California and there's an 8 hour time difference.

Links: Collections of info

Jul. 16th, 2025 09:19 pm[personal profile] sonia
sonia: Quilted wall-hanging (Default)
Covid-Safe Scouts Research Repository. A massive collection of links to info about Covid. Studies, graphics, links, zines, newsletters, blogs. A bit overwhelming, but also reassuring that there's so much info available if you know where to look.

For example, Threat Model is a weekly newsletter about the latest on Covid. With beautiful drawings of people in masks, and the June ones are in Pride colors.

The Menopause Wiki. "The official menopause wiki for Lemmy's c/menopause community, and its Reddit siblings, r/menopause and r/perimenopause." Lots of info and opinions about perimenopause and menopause.

Media and Democracy Project local journalism directory.
We created this directory to help you find local journalism in your area worth supporting. By donating or subscribing to the newsrooms on our list you’ll be paying towards the advancement of quality, community-focused journalism and contributing to a better informed citizenry, the bedrock of a strong democracy.


For example, StreetsBlog San Francisco with local bike and transit news.

RestoredCDC.org via Archivists Recreate Pre-Trump CDC Website, Are Hosting It in Europe by Jason Koebler.

Links: Queer as in Fuck You

Jul. 16th, 2025 09:10 pm[personal profile] sonia
sonia: Quilted wall-hanging (Default)
Strategic Resistance: Mass Demonstration by Karawynn Long. "Why organized nationwide rallies are an excellent use of your time and energy right now"
To overcome that fear, to begin to embolden potential defectors and peel off some of Trump’s key support, will require huge numbers of people pushing back, in organized, strategic ways. So our goal — the one goal, to which everything else is secondary if not irrelevant right now — should be to grow a bigger organized resistance movement.


“Even God Cannot Hear Us Here”: What I Witnessed Inside an ICE Women’s Prison by Rümeysa Öztürk, the Tufts University doctoral student whom ICE abducted from campus for co-authoring an op-ed in the campus newspaper.
No one deserves to live in cramped, unsanitary, inhumane conditions and have their medical needs ignored. No one deserves to have their religious needs ignored. And no one deserves to lack access to nutritious food. I am free, but my true freedom is interlinked with the freedom of many women I lived alongside in ICE prison. As a “detainee,” I not only endured my struggles but also had the privilege of connecting with remarkable women who shared their stories with me. Their experiences opened my eyes to a new realm of humanitarian crisis, expanding the circle of grief and compassion in my heart.


When The U.S. Government Tried To Replace Migrant Farmworkers With High Schoolers (in 1965) by Gustavo Arellano.
"These [high school students] had the words and whiteness to say what they were feeling and could act out in a way that Mexican-Americans who had been living this way for decades simply didn't have the power or space for the American public to listen to them," she says. "The students dropped out because the conditions were so atrocious, and the growers weren't able to mask that up."


Queer as in Fuck You by Aiden Grace Smith, via [personal profile] cosmolinguist. Powerful essay about being trans and genderqueer.
Having that conversation reminded me of nothing more than being told, in kindergarten, that we were to line up every day by gender to go to the playground. I wanted desperately to go to the playground, and I did not know which line to join. I remember having a kicking, screaming meltdown at recess time for the first week of kindergarten because I could not in any other way articulate my rage that there were different lines, maybe any lines, at all.

Stew For Science

Jul. 16th, 2025 10:20 am[personal profile] madbaker
madbaker: (Chef!)
This week's Resolution Recipe: Chicken Stew with Dumplings.
"We simplified this recipe dramatically with ground chicken - which can dry out a bit under pressure. To compensate, we've upped the broth to make sure that the stew is moist, even a little soupy, as it will reduce a bit as the dumplings cook."
Read more... )
sonia: Quilted wall-hanging (Default)
The Back Room by Alicia Adams. A rock shop with a magic back room, and a teenager aching to find her way in.

Negative Scholarship on the Fifth State of Being by A. W. Prihandita. A doctor struggling with corporate control as she tries to treat a patient who is a member of an isolated minority.

Funerary Tea by Anne Leonard. Magical gifts can have unexpected consequences.
fresne: Circe (Default)
Here I am meaning to post more here, and didn't post this bit I posted over on Tumblr.

And so, before I watch episode 10 of Murderbot and wrap the season, what I wrote two weeks ago about episodes 7, 8, 9.

I had so many thoughts.

Most of which I verbally cracked like so much & many eggs immediately after with my watching cohort. Only fitting because that's what one needs to break to make a protein rich meal. But then again, that's not how the saying goes.

And yet, and yet, if a person understands what is meant, then maybe it is…

Read more... )
graydon2: (Default)
somewhat contrary to the previous post: another pet peeve is people (some classic libertarians, others paleoconservatives) saying that "there is no free lunch".

there are certainly zero-sum, no-win situations that occur in life sometimes. and the phrase is often also used in some fatalistic, eschatological, broad heat-death-of-the-universe sense. sure sure, second law.

but as the great MC hawking put it: the earth's not a closed system, it's powered by the sun. there's an effectively unlimited massive fusion reactor in space we literally all live off of, and for all practical purposes we always have and always will. it is very much a free lunch! concretely: every lunch you have ever eaten and will ever eat is a free lunch given to earth by the sun.

also like .. any technological improvement that increases efficiency of some work is a metaphorical free lunch. if there were no free lunches to be had from R&D we may as well be banging rocks together as using any later developments.

also any positive-sum games or interactions, social relationships, political organization, economic cooperation .. the list of free lunches goes on and on.

enjoy your free lunches!

flywheels, again

Jul. 13th, 2025 10:01 pm[personal profile] graydon2
graydon2: (Default)
reading some technology reporting today and they're using the term flywheel, a pet peeve of mine. I have written about this before on some ephemeral social media, but I am moved now to repeat my objection in a place of greater posterity.

the word "flywheel" seems to have entered the business-writing lexicon with a book about amazon called "good to great". I have not read this and have no intention of reading it. perhaps the metaphor was used sensibly there. it is no longer used sensibly. here are a couple representative samples I just found via google of the way it is used nowadays (emphasis mine):

By definition, a flywheel is a heavy revolving wheel that is used in a machine to increase momentum and therefore provide greater stability to the machine. Given its weight, the flywheel is difficult to push from a standstill, but once it starts moving it gradually builds momentum, which eventually enables the wheel to turn by itself and create even more of its own momentum through a self-reinforcing loop.

or:

A flywheel is a massive metal disk, or wheel, that often weighs over 2,000 kgs. It takes a lot of effort to get it started, but once it starts to turn there are counterweights around the outside of the wheel that start to take effect and it starts to build momentum almost by itself. From that point, the same effort can be placed on the flywheel and it will start to turn faster and faster.

this is characteristic of the way people use the term now. they talk about "getting the flywheel going" on their business, because once you're over some kind of threshold the flywheel will somehow magically start spinning faster and faster on its own.

that is not what a flywheel is or what it does at all.

a flywheel is a kinetic battery. you put angular momentum into it when you have a surplus and you can take some back out when you have a deficit (assuming friction hasn't lost it all yet). other metaphors that have a similar effect are account balances, or warehouse inventory, or queues. or taking an average of something noisy over time. take your pick.

a wheel that somehow went faster of its own volition would be a perpetual motion machine. a fantastical solution to all the world's energy needs. but also fairly prohibited by .. physics. there is no such thing.

people using the metaphor this way seem to be getting it confused with positive feedback phenomena. which do exist! even in business! here is a classic one: sales volume up => unit production cost down => sale price down => customer demand up => sales volume further up. a.k.a. "economies of scale". great stuff, bravo capitalism. it has some other positive feedback loops that are not so great like "overproduction crisis" or "market panic" but we need not dwell on those.

there are also lots of other non-capitalism examples of positive feedback phenomena. population growth, cytokine storms, even the digital flip-flop circuits storing this post are positive feedback systems.

but: a flywheel is not a positive feedback system. not at all. please, I beg you: for pity sake stop using it as a muddled metaphor for one.

Boost: Uncle Bill's Tweezers

Jul. 13th, 2025 11:27 pm[personal profile] sonia
sonia: Quilted wall-hanging (Default)
Soon after I moved to the Bay Area, probably recommended by my knowledgeable housemate, probably at the then-independent Bill's Drugs which is now a CVS, I purchased small metal needle-sharp tweezers in a small plastic tube with a metal cap.

Thirty-mumble years later, the plastic tube is somewhat cracked, but the tweezers were recently as useful as ever to extract first a ceramic splinter from my hand, and then a wood splinter from my foot.

I got curious and looked it up, and there is an old-style website unclebillstweezers.com with testimonials, and they come up as available for purchase on various sites, including Amazon. The Chamber of Commerce says that Uncle Bill's Tweezer Co is located nearby in Albany, CA.

Highly recommended! I don't use them often, but when I do, they are exactly what I need.

More Murderbot Articles

Jul. 13th, 2025 11:41 am[personal profile] marthawells
marthawells: Murderbot with helmet (Default)
A really thoughtful essay on Murderbot: ‘Even If They Are My Favourite Human’: Murderbot Just Explained Boundaries

https://countercurrents.org/2025/07/even-if-they-are-my-favourite-human-murderbot-just-explained-boundaries/

“I Don’t Know What I Want”: The Line That Changed Everything

In the final moments of the season, Murderbot says: “I don’t know what I want. But I know I don’t want anyone to tell me what I want or to make decisions for me. Even if they are my favourite human.”

This is not a dramatic declaration. It is confusion wrapped in clarity. A sentence that holds discomfort and self-awareness in equal measure. It reflects a truth often ignored in stories about intelligence and emotion: that it is okay to not know, as long as that unknowing belongs to the self. In a world that constantly demands certainty, this line opens up space for uncertainty without shame.



* And a great interview with Alexander Skarsgård!

https://collider.com/murderbot-finale-alexander-skarsgard/

So, it just wants to start fresh and get away, and figure out who it is and what it wants. It doesn't really know that. I quite enjoyed that Murderbot didn't end up having answers to all the questions or knowing exactly what it wants. It's more messy and complicated than that. But it definitely knows that it needs to find its own path and make its own decisions, to make its own mistakes, and not have the Corporation or anyone tell it who it is or what it wants.

twenty years

Jul. 12th, 2025 05:32 pm[personal profile] graydon2
graydon2: (Default)
I just noticed this post from around when I first learned the term "substructural type system" is (almost) 20 years old. That sure was a while ago.

(I knew the space of ideas already but was working my way through more legit treatments of it. amusingly none of the research links in that post are live anymore -- back then arxiv.org was still "xxx.lanl.gov" haha)

Murderbot Interview

Jul. 12th, 2025 03:05 pm[personal profile] marthawells
marthawells: Murderbot with helmet (Default)
Here's a gift link for the New York Times interview with Paul and Chris Weitz, who wrote, directed, and produced Murderbot:

https://www.nytimes.com/2025/07/11/arts/television/murderbot-season-finale-chris-paul-weitz.html?unlocked_article_code=1.V08.exvw.M_qE37ROOT58&smid=url-share

New Murderbot Short Story

Jul. 10th, 2025 09:33 pm[personal profile] marthawells
marthawells: Murderbot with helmet (Default)
The new Murderbot short story is up at Reactor Magazine:

Rapport: Friendship, Solidarity, Communion, Empathy

https://reactormag.com/rapport-martha-wells/

Edited by Lee Harris, art by Jaime Jones.


And Murderbot was renewed for a second season!

https://deadline.com/2025/07/murderbot-renewed-season-2-apple-tv-1236453764/

“We’re so grateful for the response that Murderbot has received, and delighted that we’re getting to go back to Martha Wells’ world to work with Alexander, Apple, CBS Studios and the rest of the team,” Chris and Paul Weitz, said in a statement Thursday.

Naturally

Jul. 8th, 2025 07:19 am[personal profile] madbaker
madbaker: (disgruntled clown)
This week and last I have been missing the early bus by 30 seconds or less - I am up the street from the bus stop as it pulls away. Most of those times I might have made it had I jogged quickly or dashed, but I have not wanted to.

This morning I made a specific effort to get up 5 minutes early. I made sure I would get out the door a couple minutes earlier. Aaaaand... the early bus was 5 minutes late.

Profile

tshuma: (Default)
tshuma

March 2018

S M T W T F S
     123
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 21st, 2025 05:24 pm
Powered by Dreamwidth Studios