Evan Hahn's blog

https://evanhahn.com/blog/

My blog, mostly about programming.

フィード

記事のアイキャッチ画像
Notes from June 2025
Evan Hahn's blog
A roundup from my June 2025.See also: my notes from last month, which links to every previous month this year so far.Things I published this monthI finished Empire of AI and wrote up some takeaways. In short: best book I’ve read this year. I highly recommend it to anyone interested in AI and/or tech ethics.I’ve disliked the periodic table since high school chemistry. It never made any sense to me! But after reading The Periodic Table: A Very Short Introduction, my grudge has softened. Read “Getting over my grudge against the periodic table” for more.I’ve long wondered when, if ever, JavaScript arrays are more memory-efficient than their byte-buffer counterpart, Uint8Arrays. I ran a simple experiment and wrote up my findings. My post is far from exhaustive, but I was satisfied with my answer.I saw a beautiful rainbow and got inspired to doodle a little rainbow of my own.I released the aesthetically-pleasing version 3.33 of HumanizeDuration.js, adding Latin writing support to the Serbian
3日前
記事のアイキャッチ画像
Notes from "Empire of AI: Dreams and Nightmares in Sam Altman's OpenAI"
Evan Hahn's blog
I just finished Empire of AI: Dreams and Nightmares in Sam Altman’s OpenAI by Karen Hao, and…wow! What a read! Best book I’ve read all year!Empire of AI covers the history of OpenAI, from before ChatGPT to early 2025. It profiles CEO Sam Altman and several other executives. It also discusses the broader AI industry.Hao does this with a critical eye. I wasn’t an OpenAI fan before I read it, but I’m even less of a fan now! If you’re looking for a book to excite you about generative AI, this is not it.I’ve collated a few themes that stood out to me, but I recommend reading it for yourself. There are so many goodies.On Sam AltmanOpenAI is a reflection and extension of the man who runs it.The book describes Sam Altman as duplicitous. He tells people what they want to hear rather than the truth. The book quotes Geoff Ralston, who says, “Sam can tell a tale that you want to be part of, that is compelling, and that seems real, that seems even likely.”It also highlights, without confirming or d
10日前
記事のアイキャッチ画像
An unfinished post: "Compressing short Unicode strings with BOCU-1"
Evan Hahn's blog
This post is not finished. As you can see, several sections are unwritten, and it may contain errors.Even though I don’t intend to finish it, I thought it could be useful to publish anyway. If you’re interested in taking it over, let me know, and I can send you all the notes I have.With that out of the way, here’s my draft post.In short: BOCU-1 is a character encoding focused on compression. It’s not great for longer strings but works well if you have short amounts of text in non-Latin alphabets. However, it has a number of issues and you probably shouldn’t use it.BOCU-1, short for “Binary Ordered Compression for Unicode”, is a character encoding. You probably shouldn’t use it.As its name suggests, it is primarily focused on compressing text. It usually does a worse job than generic compressors like gzip, but can do a better job for short strings containing non-Latin-alphabet characters.This post aims to explain BOCU-1 well enough that you could write your own implementation, as well a
14日前
記事のアイキャッチ画像
Getting over my grudge against the periodic table
Evan Hahn's blog
I recently read The Periodic Table: A Very Short Introduction by Eric Scerri. It’s a book about the history of the periodic table, the poster child of chemistry education.Before I share my thoughts, I want to talk about my personal problems with the periodic table.My grudgeI’ve long held a grudge against the periodic table.In school, I struggled with chemistry more than any other subject. It felt beyond my understanding, as if someone designed a class to confuse me. It seemed like the world was telling me that the sky is green, which I could not understand.For years, I felt bewildered by the entire subject of chemistry. But over time, I began to blame my confusion on one part of my education: the periodic table.The periodic table, as I recall learning, was a rigid arrangement of the chemical elements. An elegant distillation of hard truths in a neat presentation.My classmates seemed to be able to read the periodic table like tea leaves. They could predict similarities between, say, lit
21日前
記事のアイキャッチ画像
Rainbow "code doodle"
Evan Hahn's blog
Yesterday, I saw a beautiful rainbow. (So did everyone else in Chicago, it seems.) I think it was the best rainbow I’ve ever seen.It inspired me to doodle this little rainbow visualization:Click here to see it in full screen.
1ヶ月前
記事のアイキャッチ画像
When Array uses less memory than Uint8Array (in V8)
Evan Hahn's blog
In short: in V8, Uint8Arrays have some overhead that makes them larger than equivalent Arrays. But after about 150 elements, they start to be much more compact.Sometimes, I have a JavaScript array of integers between 0 and 255. Like this:[1, 2, 3]I thought, in theory, using Uint8Array should use less memory. Like this:1new Uint8Array([1, 2, 3])After all, Uint8Arrays know every element is exactly one byte large. Arrays, with their flexibility, can’t guarantee that. What if the array has strings or objects inside? But modern JS engines are full of optimizations. Maybe they do something clever.Of course, Arrays and Uint8Arrays have different uses. You probably shouldn’t use an Array to store large amounts of binary data, and you can’t use a Uint8Array to store an array of objects. But let’s take a very narrow view:Assuming you’re storing a list of byte-sized integers, when, if ever, does using an Array use less memory than a Uint8Array?The testI wrote a simple script that spawns Deno proc
1ヶ月前
記事のアイキャッチ画像
Notes from May 2025
Evan Hahn's blog
A roundup of my notes from May 2025. I also did this last month, the month before, the month before that, and so on…Things I did this monthThe world is in a lot of trouble right now. Many of us techies are asking: how can I help? I published a list of tech jobs for good, which I hope helps someone find a gig doing a good thing.(I also wrote a simple script to help with the Markdown in that post, which is a lot less interesting.)I explored the cultural legacy of Zelda II: The Adventure of Link, along with a few other articles over on Zelda Dungeon. Also in video games, I listed things I wish I had known about Ring Fit Adventure, a fitness game I’ve been playing for years.I added my name to the “DWeb Principles”, which “define the values of a decentralized web based on enabling agency of all peoples”. I encourage you to give it a read and, if you agree with the values, add your name!I started writing an explainer about BOCU-1, an obscure character encoding…but I don’t think I’ll finish t
1ヶ月前
記事のアイキャッチ画像
Simple script to sort Markdown lists
Evan Hahn's blog
Sometimes (like in my recent blog post about tech jobs for good), I want to sort a Markdown list. But I can’t use normal tools like Vim’s :sort because the lists have formatting. For example, take this Markdown:- Badgers- **Crocodiles**- [Aardvarks](https://aardvark.example)It should get sorted like this:- [Aardvarks](https://aardvark.example)- Badgers- **Crocodiles**But all the tools I tried will sort this incorrectly because of the Markdown formatting…so I wrote a simple Deno script.Run this with something like deno run sort-markdown-list.ts < list_to_sort.md:import { toText } from "jsr:@std/streams/to-text";import { remark } from "npm:remark";import strip from "npm:strip-markdown";const cleanLine = (markdown: string): string => remark() .use(strip) .processSync(markdown) .toString() .trim() .toLowerCase();(await toText(Deno.stdin.readable)) .trim() .split("\n") .sort((a, b) => cleanLine(a).localeCompare(cleanLine(b))) .forEach((line) => console.log(line));This script has a few issue
1ヶ月前
記事のアイキャッチ画像
List of "tech for good" job boards
Evan Hahn's blog
The world is in a lot of trouble right now. Many of us are asking: how can I help?This is a short list of “tech for good” job boards I’ve found:80,000 Hours job boardAll Hands job boardAll Tech Is Human job board (requires signup)AltProtein.Jobsapply.coopClimate tech company listClimatebaseDesign Gigs for GoodDigital Rights community (Mattermost and job board)Fast Forward job boardfossjobs.netIdealist (not tech specific)NTEN job boardOpen Source JobHubOSdev job boardTech Jobs for GoodUnited Nations job boardVegan Hacktivists requests boardWords of Mouthlocal civic tech groups’ job boards, like Chi Hack Night in Chicago or SF Civic Tech in San FranciscoNot all of these boards are great. In fact, a few of them list tech jobs that I think are bad! But I’ve found these lists useful, and hope they’re useful to you.If you know more job boards or have any feedback, please reach out.Thanks to Joanie Weaver for 3 additional resources, and to Andrew for “Design Gigs for Good”.
1ヶ月前