A framing prompt, basically “Respond with Mad Libs, formatted so I can process them,” and
Some text substitution from inputs.
A framework can really help. This app uses Vercel’s AI SDK, a TypeScript library specialized for building interactive web applications. Another good one, which has both Python and JavaScript versions, is LangChain / LangGraph — for building “Applications that can reason”.
So simple it’s embarrassing. A good place to start, right?
Bugs
Sometimest the streaming response gets cut off. That may be because of bugs in OpenNext. It never fails in development — I should really see how it does when hosted at Vercel instead.
For Thanksgiving each year our family (my wife’s family really) gives small gifts, and this year we decided to make them handmade. What can I hand-make? Well, software. I decided to make an app for each person, but I ended up getting through only the first one.
Hexerals uses immutable.js for its game state — could it switch to JavaScripts native collections? That would make the code more readable, but how would effect performance?
Summary: In Chrome, object operations are much faster than immutable Map — just don’t freeze() them. But in Firefox and Safari, immutable Map still wins. Chrome’s advantage might come from Hidden Classes.
The strengths of immutable.js are:
Memory — immutable.js only duplicates sections that are changed, which saves memory. It makes keeping a full history of a game especially efficient.
Speed — it’s fast! For example, Hexerals robots use the game state to make decisions, and if it slows down, it limits their intelligence.
For example, its board is represented using a Map, matching each location (a Hex) to contents (a Tile) — the hexagon in upper left might be Hex (0, 6), with a Tile whose owner is Red, population 8, and no special terrain.
So how expensive would it be to switch from those Maps and Lists to JavaScript’s built-in Objects and Arrays?
To the Benchmarks!
These are run in your local browser (click the gear to change settings & run again):
What are these benchmarks doing? Something that resembles the internal state transitions in a single turn of Hexerals. See BenchWorkers.ts for actual code.
Collection Size: Create a collection with that many simple items in it.
Iterations: Copy it this many times.
Mutation Fraction: Each time it’s copied, also randomly replace a fraction of its contents. For example, if Collection Size is 1000 and Mutation Fraction is 0.1, then 100 entries will be modified at random during each Iteration.
You can see why developers might prefer the object — its syntax is simpler.
Surprises
Object.freeze() is slow for objects but practically free for arrays!
Immer (which uses Object.freeze) is slow if you use it inner loops. But it’s very safe! And almost nobody needs it to be inside inner loops anyway.
Structura is an interesting alternative to Immer. It “freezes at compile time” which … is not quite freezing, but relying on TypeScript’s Readonly<T>. Anyway it looks like that’s the key to performance in JS — and it’s what the winning benchmark is doing with object.
JavaScript’s built-in Map is slow for this kind of operation, compared to plain old objects — which is too bad because Map is more flexible than objects. It turns out that copying a map is slow. There is another slightly faster way (using an iterator to insert one by one) but it’s not enough faster to close the gap. Probably worth revising the benchmark to include it tbh.
In short, Safari and Firefox both really like Immutable.js Map, and Chrome likes object.
For 1000 x 1000 x 0.1, on an M1 laptop, in milliseconds:
object
Map
immutable Map
Chrome
4.1
44
19
Firefox
55
57
20
Safari
114
82
18
Immutable.js Map has the best-worst-case on my desktop, with 20ms on Firefox.
Chrome loves object, but everybody does well with immutable.js.
How about some older mobile devices?
object
Map
immutable Map
Pixel 4a 5G (2020 Chrome
21
105
64
Samsung A50 (2019) Chrome
33
170
79
iPad (2018) Safari
178
101
42
Immutable.js Map wins here too, with 79ms on an old Samsung phone.
So, what’s the best choice? The widest bottleneck is clearly Immutable.js’s Map. The object spread operator (and object.assign) is too dang slow on Safari, and so is Map on Chrome.
Proposal: Add that browser padlock to long-lived documents.
In an age of undetectable fakes, how do you know what is true? We can at least prove a source, and with a little work — and help from HTTPS — archive that proof for later reference.
Hint: We have never known for sure what is true. All we could do was ask:
What makes sense to me?
Who do I trust?
With convincing fakes, we’ve lost the second one. That convincing video or news story? It could be from anywhere. We don’t know who to trust, and we’re left with “What makes sense to me?” — and every one of us has biases about what we wish was true.
So can we bring back “Who do I trust?” Can we prove who said what?
Almost. On the web as it is today, you can tell in the moment whether you can trust content. That’s what the padlock in the address bar means. But if the page is changed in the future, or becomes inaccessible, you can’t go back in time and prove it to someone else.
So we need a little extra software: With those same padlocks, we could download and archive a signed copy of a web page. And the signature would come from the website’s own HTTPS credentials, so it’s publicly provable — even if the original page is modified or becomes inaccessible.
We can’t detect AI
One source we know we can’t trust is AI. Even its makers warn of its hallucinations.
If OpenAI can’t tell the difference between human-written and AI-generated text, then I don’t think anybody can. Images and video can’t be far behind — we have to assume that any media we see — text, audio, image, or video could be entirely synthetic.
This is not a new problem — that’s why we have bibliographies after all. But can you check sources? Can you read that article from Reuters, and double check a quote? What if content gets taken down?
You know what I think would be a great starting point? If you could save the content of a web page, along with its signature. That shouldn’t be too hard actually, since most web pages are already signed.
Can Signatures Save us?
C2PA is an emerging standard to add cryptographic signatures to files — in other words modern bibliographies. It is backed by Adobe, BBC, Sony, Intel, Microsoft, and others.
It aims to prove authorship of media, end-to-end, from its initial recording to its latest edits, with cryptographic signatures.
Of course, this is important for copyright and ownership — if AI-generated content can’t be copyrighted, then creators need to be able to prove authorship.
And it can help prove authenticity in critical situations:
Of course the Internet is full of warnings — dangers to privacy, fears of censorship and tyranny by those who control C2PA.
And that doesn’t address the loopholes. For example: Can I record a deepfake with a trusted camera? It will be a cat-and-mouse game between the fakers and the provers, and the outcome is not assured.
Who do you trust?
In the end, I don’t care about the provenance as much as about truth. And I trust certain sources a lot more than other sources.
What if the BBC (or your favorite source) vouched for something? Would it matter if they relied on an AI summary but then fact-checked it? I think that would be fine, because I trust their fact-checking.
A secure URL is a good start
It seems impractical to trace the provenance of every part of that article. Especially the text. Maybe a journalist wrote it, or maybe they re-typed it from ChatGPT? But I don’t need to know — just the fact that it’s from the BBC is a reputable starting point for me.
So we share URLs. Simple! And HTTPS makes them cryptographically secure. This one testifies that it is hot this summer, and you can really trust that it comes from the BBC: https://www.bbc.com/news/world-us-canada-66343133. US heatwave: Scorching heat strains US air conditioning capacity.
Sharing URLs is great, but it has two problems:
Permanence: What if the website goes down? Okay, the BBC is unlikely to. But a human rights activist’s blog post? That could happen.
Remix: What if I want to share just a piece of it? I can’t — any change at all would violate the digital signature. I would like to take that content as an input into a trusted editing process. C2PA-enabled tools seem like a good start! They would tell the consumer what editing was done.
Signed Webpage as Input
To solve permanence and remix-ability, we could do the following:
Support this signed content as an input to C2PA-enabled tools. It would provide a means to remix, with a chain of provenance back to trusted sources.
It’s not perfect
There are still some gaps.
What if the BBC retracts the article? Maybe they found a flaw in their fact-checking — unfortunately that signed copy from yesterday is still circulating.
What if someone ever gets a hold of their private cryptographic key? They could sign fake content, even retroactively.
Footnote: We really can’t trust AI
This goes almost without saying. Every major AI provider makes it very clear that they “hallucinate”. And we don’t know how to fix it.
But we can appreciate the work of AI.
Prompt: You have been listening to rock and roll and are really getting into it, rolling your hips as you talk, and speaking in rhyme and meter. You bring everything back to love and heartbreak. In this style, please write a poem about the heartbreak of discovering that your lover is an AI.
A digital currency with built-in universal income, minimal energy requirements, and a bias towards equality.
If you were designing a digital currency that could actually promote justice and equality, would would it look like? Here’s one approach. It is rather different. The main objection is likely to be that, in order to benefit all people equally, it embraces verifiable human identity, and therefore discards anonymity from the start.
Principles First
The goal of this design is a currency that:
Promotes justice and equality — by treating all participants equally rather than favoring founders or those who are already wealthy
Uses minimal energy — rather than requiring expensive and ongoing proof-of-work
Encourages economic activity — rather than rewarding buying and holding
Is stable and reliable — not subject to uncontrolled swings in valuation
Principle
Desired
BitCoin
Ethereum
Justice & Equality
Participants all equal
Reward proportional to hashing power
Reward proportional to stake
Energy
Minimal
High Energy
Minimal (proof-of- stake)
Encourage Activity
Inflationary
Deflationary
Deflationary
Stable
Regulated & Tunable
Unregulated & Fixed
Unregulated & Fixed
(Assuming the upcoming switch by Ethereum to proof-of-stake; there are other coins in this space as well.)
Design: Proof-of-Identity
Proof-of-identity can help with all of these desirable traits.
Each participant receives an equal increment of currency, at every time step.
Each participant has an identity verified by an external authority, determined by the currency administrators.
That’s it. That’s the basis of the currency’s operation. It has many implications:
It relies on verifiable identity, which is normally the province of governments and large institutions.
These regular increments of currency are uniform supplemental income for all people participating.
No proof-of-work is required, which reduces the energy needed. Its energy requirements are expected to be similar to Proof-of-Stake currencies.
Founders and early adopters do not necessarily receive a disproportionate share of initial currency. It could be designed that way, but that would defeat the purpose.
Inflation can be either a predetermined constant, or adjusted by a central authority based on live policy goals (for grass-roots quantitative easing).
Questions and Parameters
Storage: Immutable or Mutable?
Immutable (for example blockchain): Decentralized, redundant, and minimal trust, aside from the identity authority
Mutable (for example a traditional database): Faster but vulnerable to loss & attacks
Income / Inflation: Fixed or dynamic? It can be:
Fixed: Income and inflation are a predetermined portion of the total monetary supply or a fixed quantity per participant — a rate built into the currency’s code
Set dynamically as a fiscal policy — which would require a second authority, in addition to identity. A policy authority.
Identity: Can be a single external authority or one determined by a democratic process involving all registered participants.
Voting
It quickly becomes apparent that this is not just a currency, but has the potential for making decisions democratically. That will have to be a future subject.
Bahiyyih is making a quilt, and she was looking for someone to make a color sketch of her design. She said the word gradient, and had to do it. But I had to do it quickly because I was competing with how long it would take to draw it physically.
the colors — as long as you like diagonal gradients
the size — any rectangle you want
the color pickers … okay that was a diversion
It doesn’t let you change:
the pattern — Bahiyyih had already chosen Stars Ablaze
the direction of the gradient
what prints — it’s just the quilt
the default colors — resetting always takes you back to the colors Bahiyyih ended up choosing (although it does save any changes you make, until you hit Reset)
There are so many directions it could go next. I’m not used to working this way — make something quick and dirty, and then call it done and move on. It’s probably therapeutic.
Publishing negative results helps everyone learn. Here’s my negative result: Instacart didn’t work out in the end. I had a great time there, but the combination of legacy code, a 3-hour timezone difference, and an on-site team of 200 programmers with just a handful remote meant that I was just not productive enough — even with many weekly video conferences — and they let me go after 6 months, back in March.
I think it was a learning experience for Instacart as much as for me. The FAANG prefer onsite teams, with exceptions for specialists, and now Instacart’s job openings reflect that. But I’m a generalist.
On the bright side
I’ve been doing contract work in agriculture software since April, and it’s been a good match. Hourly discipline has been good for my mental health, and I’m fortunate to have a spouse whose job provides benefits. If it weren’t for that, self-employed life would be much harder! Thank you Bahiyyih & Purdue, and hurry up US with affordable health care for all!
Join the Middle Class. Have a life that’s good enough. This morning I was just sitting at my dining room table, playing Threes, when the concept of the Middle Class poked its elephant head in through a window and explained its radical nature. “I’m not just a pleasant compromise,” elephant-middle-class said, “I’m an essential foundation for a peaceful planet.”
It went on, “Think about it. You keep ranting to anyone who will listen that we need to move on towards post-scarcity thinking. Run on love and planning instead of fear and coping. People are already doing that, and we call them Middle Class.“
This elephant had a point.
I looked at the elephant, excited to talk with it but a little afraid it would grab me with its trunk and practice juggling.
Instead it used its trunk to pull a bundle of grass out of some kind of saddle bag on its back that had a red and yellow diamond pattern. I think it was made of wool.
It rested its head on the windowsill and munched.
“Wait, why are you telling me this?” I asked it, “Don’t you have important things to do? Don’t elephants have to eat, like 20 hours every day to avoid starving?”
It shrugged with its ears while its mouth kept working on the grass. Elephant eating involves a lot of chewing. I drank some coffee and looked down at Threes but wasn’t interested in my game for the moment.
It swallowed, licked its lips, and spoke up again, “Maybe it would help to call it something more than middle class.” Its dark eye blinked slowly. “For example, what is this place you live in?”
“A kitchen.” I looked around. “I mean a house.”
“Yes,” it nodded slowly. “And its spiritual significance? Isn’t it also a sacred environment where neighbors come to celebrate their companionship and have elevated discussions? And where children can develop and flourish as spiritual beings?”
“Yeah, it is — on a good day at least.” I looked around. It helped that the kitchen was in decent shape this morning because (just to brag a little) I did dishes last night.
“And all that is easier if the roof doesn’t leak and it doesn’t freeze indoors in the winter.”
The elephant — again — had a point. I offered it coffee and cantaloupe rinds (they still had some of the orange part on them) that I had gotten out for the guinea pigs. It took some cantaloupe and made quick work of it.
“The middle class is the same.” It lifted its head and ran its trunk along the window frame, then started to amble away.
In an earnest talk with the Rector of a Parish, ‘Abdu’l-Bahá said: “I find England awake; there is spiritual life here. But your poor are so very poor! This should not be. On the one hand you have wealth, and great luxury; on the other hand men and women are living in the extremities of hunger and want. This great contrast of life is one of the blots on the civilization of this enlightened age.
“You must turn attention more earnestly to the betterment of the conditions of the poor. Do not be satisfied until each one with whom you are concerned is to you as a member of your family. Regard each one either as a father, or as a brother, or as a sister, or as a mother, or as a child. If you can attain to this, your difficulties will vanish, you will know what to do. This is the teaching of Bahá’u’lláh.”
“The supreme need of humanity is cooperation and reciprocity,” said ‘Abdu’l-Bahá. “The stronger the ties of fellowship and solidarity amongst men, the greater will be the power of constructiveness and accomplishment in all the planes of human activity.” In the same way that the human being is more than the sum of the individual cells which comprise its body, so too the powers of a unified community far exceed the combined powers of its individual members.
“A new life,” Bahá’u’lláh proclaims, “is, in this age, stirring within all the peoples of the earth; and yet none hath discovered its cause, or perceived its motive.” “O ye children of men,” He thus addresses His generation, “the fundamental purpose animating the Faith of God and His Religion is to safeguard the interests and promote the unity of the human race… This is the straight path, the fixed and immovable foundation. Whatsoever is raised on this foundation, the changes and chances of the world can never impair its strength, nor will the revolution of countless centuries undermine its structure.” “The well-being of mankind,” He declares, “its peace and security are unattainable unless and until its unity is firmly established.” “So powerful is the light of unity,” is His further testimony, “that it can illuminate the whole earth. The one true God, He Who knoweth all things, Himself testifieth to the truth of these words… This goal excelleth every other goal, and this aspiration is the monarch of all aspirations.” “He Who is your Lord, the All-Merciful,” He, moreover, has written, “cherisheth in His heart the desire of beholding the entire human race as one soul and one body. Haste ye to win your share of God’s good grace and mercy in this Day that eclipseth all other created days.”
“Wait, isn’t the Middle Class founded on unsustainable consumption that is eliminating natural environments and causing catastrophic climate change?” I called after its diminishing form.
It called back over its shoulder, “You’re pretty good engineers — I’m sure you can figure it out if you work together.”
I plan to start working for Instacart, in San Francisco, in a couple of weeks — my first day will be September 10. I’ll still live in West Lafayette — for the first three weeks I plan to fly out Sunday night and come back Thursday overnight. Eventually I’d like to get that down to one week a month. So really it will be mostly remote work. Eventually.
How many people macro-commute? How do you make it sustainable?