Evan Hahn's blog

https://evanhahn.com/blog/

My blog, mostly about programming.

フィード

記事のアイキャッチ画像
UI tip: maybe don't round percentages to 0% or 100%
Evan Hahn's blog
In short: maybe don’t round to 0% or 100% in your UI.I am not a UI expert. But I sometimes build user interfaces, and I sometimes want to render a percentage to the user. For example, something like “you’ve downloaded 45% of this file”.In my experience, it’s often better to round this number but avoid rounding to 0% or 100%.Rounding to 0% is bad because the user may think there’s been no progress. Even the smallest nonzero ratio, like 0.00001%, should render as 1%.Rounding to 100% is bad because the user may think things are done when they aren’t, and it’s better to show 99%. Ratios like 99.9% should still render as 99%, even if they technically round to 100%.For example, in your UI:Ratio (out of 1) Rendered 0 0% 0.00001 1% 0.01 1% 0.02 2% 0.99 99% 0.99999 99% 1 100% Here’s some Python code that demonstrates the algorithm I like to use:def render_ratio(ratio): if ratio <= 0: return "0%" if ratio >= 1: return "100%" if ratio <= 0.01: return "1%" if ratio >= 0.99: return "99%" return f"{
1日前
記事のアイキャッチ画像
Takeaways from The Economist's style guide book
Evan Hahn's blog
I’ve been trying to improve my writing so I read Writing with Style, the Economist’s style guide book.Here were my main takeaways:Use short sentences. They’re more memorable. They’re easier to read. They’re generally easier to write.Colons are for setup and delivery. They describe them as “dramatic”.One thought per paragraph. The paragraph is a “unit of thought”, according to this book and to H.W. Fowler. Sometimes, you have a one-sentence paragraph because the thought fits into a single sentence.Prefer simpler terms. Use “get” instead of “obtain”, “make” instead of “manufacture”, or “give up” instead of “relinquish”. Ask if you ever use the word when talking to friends. And don’t soften difficult topics: “a poor person has no more money, opportunity or dignity when described as ‘deprived’, ‘disadvantaged’ or ‘underprivileged’.”The right word can eliminate others. More specific words let you “dispense with adjectives and adverbs entirely. Consider the difference between ‘walk’ and ‘str
4日前
記事のアイキャッチ画像
Notes from "Life in Code: A Personal History of Technology"
Evan Hahn's blog
Life in Code: A Personal History of Technologyis a book of essays by Ellen Ullman.In the book, Ullman laments the bad parts of computers and the internet. Thesesystems eroded privacy, deepened income inequality, and enabled the rise ofmodern fascism. And they were built by a tiny subset of people—young men, mostlywhite and Asian, mostly wealthy—to the exclusion of almost everyone else.Despite all this, she maintains a hopeful fascination with technology. Perhapshumanity can use these tools as part of a better world.I share this sentiment, I think.Many of the stories are old by Silicon Valley standards, but they feelprescient. The book is filled with ideas that could be written today, if youmodernized a few incidental details.These are my notes and quotes from the book.“Outside of Time” (1994)Ullman on the idea that low-level development is more respected: “If you wantmoney and prestige, you need to write code that only machines or otherprogrammers understand.” Oh, and these prestigious
11日前
記事のアイキャッチ画像
Notes from March 2025
Evan Hahn's blog
Here’s a little roundup of things I’ve done in March. Also see my entries from February and January.Words I wrote in MarchI published a few blog posts this month:“Why ‘alias’ is my last resort for aliases” explains why I prefer defining scripts over shell aliases. I’ve been doing this for years and finally wrote about it.Response to this post, at least on Lobsters and Hacker News, was mixed. It was on the front page of Lobsters for awhile, but only briefly peeked into the bottom of the HN front page. Some people agreed with my idea and some did not.I also learned a few things about aliases from comments and emails, and have a few edits to my dotfiles I’d like to make.“Filling in the gaps of the internet” describes a philosophy of mine: if I ask a question, can’t easily find the answer, and then eventually find the answer, it’s my duty to publish something. I’ve done this many times on my blog. Some of those posts have gone nowhere, but others are very popular, and others have even been
19日前
記事のアイキャッチ画像
Cheatsheet for Rink, the unit-aware calculator
Evan Hahn's blog
Rink is a unit-aware calculator for the command line and your browser. I’ve been wanting something like it for years!Here’s a Rink cheatsheet I made for myself. I hope it’s useful to others!Basic conversionsRink can do a bunch of basic conversions, such as converting Fahrenheit to Celsius or kilometers to miles.Basic unit conversions:> 10 pounds to kilogramsapprox. 4.535923 kilogram (mass)> 32 degF to degC0 °C (temperature)Byte conversions:> 1 KB to B1000 byte (information)> 1 KiB to B1024 byte (information)See “How big is a kilobyte?”.Work with ratios:> 0.25 -> percent25 percent (dimensionless)> 25 percent0.25 (dimensionless)> 100 meters * 25 percent25 meter (length)Convert currenciesTo convert euros to Indian rupees:> 1 EUR to INR94.5045 INR (money)By default, conversion rates update from the internet once an hour. You can configure this feature, including disabling it.Numeric suffixesYou can avoid typing a lot of extra zeroes with helpers like “billion” and “thousand”:> 1 billion /
1ヶ月前
記事のアイキャッチ画像
Everything we know about the next Zelda game, as of March 2025
Evan Hahn's blog
In short: it’ll probably emphasize player freedom, not be a “dungeon editor” game, and won’t reuse the same map of Hyrule. See my post at Zelda Dungeon for more.I enjoyed rounding up all pre-release information about The Legend of Zelda: Tears of the Kingdom. I’m back to do this for the next Zelda title.I researched everything we know about the game so far and published a long post on Zelda Dungeon. Spoiler: we don’t know much, but we know a few little details:The new game is probably well under way, but it’ll be awhile before we see it.The classic Zelda formula, from games like Ocarina of Time, probably isn’t coming back. Breath of the Wild charted a new direction for the series, emphasizing player freedom and an open world.A “Zelda Maker” is also unlikely. We probably won’t see a game based around a dungeon/level editor.Tears of the Kingdom reused Breath of the Wild’s world. The next game will probably not do this, and will feature a new setting.This is just a quick summary of what w
1ヶ月前
記事のアイキャッチ画像
Filling in the gaps of the internet
Evan Hahn's blog
Here’s a small philosophy I have about the internet:I believe that it’s my duty to publish the answer to previously-unanswered questions. That way, the next person who comes along has an easier time.For example, I was once trying to figure out how to skip the first line of a CSV file in Python. When I did a web search for “python skip first line of CSV”, I couldn’t find the answer.After a few minutes, I figured it out myself. Then, I wrote a quick blog post explaining my solution…and now it’s one of the most popular posts on my site! Even though the post only took a few minutes to write, it’s been one of my most viewed over the last decade, (presumably) because so many people are trying to do the exact same thing.Another post, showing how to disable ESLint for a single file, has been comparably visited. Same story: I figured out how to do something and wrote a few words about it. And now, a few times a year, someone DMs me telling me they came across my blog when trying to disable ESLi
1ヶ月前
記事のアイキャッチ画像
Notes from "Beyond Measure: The Hidden History of Measurement"
Evan Hahn's blog
I just finished James Vincent’s Beyond Measure, a 2023 book about the history of measurement and its impact on our lives.The book reveals how the meter’s length is tied to the French Revolution. It highlights many scientific discoveries linked to advances in measurement. It links land surveying and the genocide of Native Americans. It even explains why the US and UK stubbornly refuse to adopt the metric system!I took some notes while reading and thought I’d share them here.Introduction: Why measurement mattersThe metric system is perhaps the most significant side-effect of the French Revolution.Numbers can lie, and that includes measurement.Chapter 1: The kindling of civilizationThere are three main properties of a good measurement: accessibility, proportionality (“no one wants to measure mountains with matchsticks”), and consistency.Old measures of distance included “how much tobacco will I smoke on this journey” or the distance you can hear a dog’s bark.Chapter 2: Measure and the soc
1ヶ月前
記事のアイキャッチ画像
Why "alias" is my last resort for aliases
Evan Hahn's blog
Aliases were one of the first things I added when customizing my dotfiles. For example, here’s a very early alias I defined:alias g=gitNow, I can run g instead of git, which saves me a little time for a command I run dozens of times a day!# These two commands are now equivalent:git statusg statusI used to define these aliases with alias. After all…I’m defining an alias!But over time, I think I discovered a better way: a script in my $PATH.How it worksIn my home directory, I have a folder of scripts called bin. For example, here’s a simplified version of ~/bin/g:#!/usr/bin/env bashexec git "$@"Running this script basically just runs git.I add this folder to my $PATH. (See Julia Evans’s guide on how to do this.) In my .zshrc, I have a line like this:export PATH="$HOME/bin:$PATH"Now, when I type g, it runs that script.This behaves just like an alias. As before, g status and git status are equivalent.# These two commands are still the same:git statusg statusThis is a lot more verbose than
1ヶ月前
記事のアイキャッチ画像
An ode to my favorite mobile game
Evan Hahn's blog
I can’t stop telling my friends about Forward: Escape the Fold and now I’m telling you. I bought it more than two years ago and it’s my favorite mobile game by a mile.Forward describes itself as the “perfect bitesized roguelike dungeon crawler”. You control a character trying to escape a dungeon, and there’s just one way out: keep going forward.It’s a game about making lots of small decisions as your character gets repeatedly pummeled on the path to freedom. Do I attack this monster and hope it gives me treasure, or do I walk through a poison cloud to get a better position? Do I take the weaker powerup that will help me now, or the one that might later turn me unstoppable if I’m lucky? Over time, you develop an intuition for the best moves to make, but every run is still a challenge.The game is easy to pick up, the sessions are the perfect duration, and the controls are satisfying on a touchscreen. All of that adds up to a perfect mobile game.The game’s vibe is another standout. The mu
2ヶ月前