Evan Hahn's blog

https://evanhahn.com/blog/

My blog, mostly about programming.

フィード

記事のアイキャッチ画像
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
5日前
記事のアイキャッチ画像
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
12日前
記事のアイキャッチ画像
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.
19日前
記事のアイキャッチ画像
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
23日前
記事のアイキャッチ画像
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
25日前
記事のアイキャッチ画像
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
25日前
記事のアイキャッチ画像
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 listClimatebaseDigital Rights community (Mattermost and job board)Fast Forward job boardfossjobs.netNTEN 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 recommending three additional job boards here.
1ヶ月前
記事のアイキャッチ画像
Things I wish I knew about Ring Fit Adventure
Evan Hahn's blog
I’ve played a lot of Ring Fit Adventure, the fitness game for Nintendo Switch. Here are some things I wish I knew when I got started.Jump over battles to skip themYou can jump over enemies to avoid fighting them!I first discovered this when watching a speedrun of the game. If you see some enemies in a level, you can use your (double) jump to avoid the battle completely. This is useful if you want to get to the end of a level faster, or if you don’t want to stop running.Sometimes this is a little tricky and I miss, and I believe some fights can’t be skipped. And skipping too many fights seems to defeat the purpose of the game!Jiggle the Ring-Con to delay an exerciseRing Fit typically waits for you to be in position for about three seconds before it starts an exercise, but sometimes it guesses wrong and starts before you’re ready!To avoid this, I jiggle the Ring-Con. That way, the game doesn’t think I’m standing still ready for the excercise.Remove the leg strap during static stretchingR
2ヶ月前
記事のアイキャッチ画像
Notes from April 2025
Evan Hahn's blog
A roundup of my notes from April. I’ve done this for the last few months:MarchFebruaryJanuaryThings I publishedI published a small UI tip about rounding percentages. In short, I don’t think you should show “100%” to the user unless it’s truly done, or “0%” unless it truly hasn’t started. Though this is a bit of a lie, I think it’s clearer to users.I posted clippings from Life in Code: A Personal History of Technology, a book of essays by Ellen Ullman. The book criticizes Silicon Valley (where I was born and raised!) and the modern tech scene. Yet Ullman seems to retain hope that these tools can be part of a better world. Perhaps I’m projecting, because that’s basically how I feel.I read the Economist’s style guide book and published my main takeaways. I think my writing is better after reading!Not something I published, but I was featured on DWeb’s social media and they chose a truly dreadful photo of me. Also, an old post of mine was featured on Remember The Milk’s blog.Things I wrote
2ヶ月前