Small programming tricks: why tiny pieces of knowledge pay off
Will Keleher argues that much of day-to-day engineering productivity comes from small, self-contained nuggets of knowledge — from git pickaxe searches to logarithmic metric buckets.
Why small pieces of knowledge matter
Will Keleher argues in a new blog post that a surprising share of everyday engineering productivity comes from small nuggets of knowledge: being aware that a language feature exists, knowing that an unexplained TCP delay is probably related to Nagle's algorithm, remembering the right git command to get out of a pickle, or knowing a trick for rewriting a file. You don't need to know any Python to run python3 -m http.server in a directory, and it still makes the work marginally easier.
In the shell and in Git
His examples start at the terminal. Ctrl+R searches command history, and installing fzf turns that into a fuzzy search; atuin replaces shell history with a searchable SQLite database; per-directory-history lets you switch between searching commands run in the current directory and searching all previous commands. In Git, git log -S pattern — the pickaxe — lists every commit that added or removed a given string, which he calls amazingly useful on older codebases; git log -G is similar but also shows when a line was moved. And git checkout - returns to your previous HEAD, much like cd - returns to the previous directory.
He also argues that you probably don't need find: many find commands can be replaced with globs such as **/*.md, which most shells support out of the box — bash needs shopt -s globstar first. zsh's advanced autocompletion, he notes, is not switched on by default and takes a short snippet to enable.
Databases, metrics and JavaScript
Several tricks are about getting an answer faster. A SELECT without a FROM works in SQL and is a quick way to check how a function behaves, or to remind yourself how SELECT TRUE <> NULL evaluates. PostgreSQL and MySQL both support explain analyze, which really runs the query and returns far more about its performance than a plain explain. For metrics, logging a logarithmic bucket such as Math.floor(Math.log10(count)) gives a sense of the distribution of a value instead of only an average.
On the JavaScript side he points to Array.flatMap, Object.entries and Promise.withResolvers as newer features worth knowing, creating an https.Agent and passing it to your fetch calls keeps a connection open to an external resource.
Company knowledge is made of the same material
Inside a company, Keleher notes, even more knowledge takes this shape: which data source to use when debugging a given problem, who knows a lot about an area and is happy to help, where the good documentation lives, what signal means a service should be scaled out manually, the command for a rolling restart, the utility that makes a tedious problem scriptable. At a previous company he shared one trick a day with the engineering team on Slack, technical and company-specific alike. Even people who knew nine of ten tricks found the tenth useful, and a single trick a day was the right dose to avoid overwhelming anyone.
SiTech — AI-powered web development
We build fast, modern websites and bring AI into real business workflows. Have a project or a question? We'd love to help.