You’ve probably seen this Python 101 thing before: @memoized def fib(n): if n 1: return n return fib(n - 1) + fib(n - 2) Leaving aside the absurdity of computing Fibonacci numbers recursively, it’s a common first introduction to Python decorators and higher-order functions. fib is just a function, and memoized takes that function and returns a...
The reason I discovered an ancient blog post the other day was that I had something new to say about Nix for the first time in over two years. The thing I want to say is this: nix-direnv is great. It fixes roughly every problem that I’ve had with nix-shell, and does so in a much nicer way than my previous ad-hoc solutions. This is important...
Note: I wrote the vast majority of this post on August 24, 2022, but I decided that it was a whiny rant that I didn’t want to publish. I came across the draft in January 2024, remembered that this entire series is a whiny rant, and decided to publish it anyway. I’ve been a happy Nix user for about 18 months now, and– well, not happy happy, but...
When you think about the Fibonacci sequence, you probably imagine a swirling vortex of oscillating points stretching outwards to infinity: Okay, no, obviously you don’t. Yet. When you think about the Fibonacci sequence, you probably flush with a latent rage when you remember that it is, more often than not, the way that we introduce the concept...
I want to tell you about an idea that has had a huge influence on the way that I write software. And I mean that in the literal sense: it’s changed the way that I write software; it’s re-shaped my development workflow. The idea is this: you can write programs that modify themselves. And I don’t mean macros or metaprogramming or anything fancy...
I’ve been writing a lot of Janet lately, and I’ve been especially enjoying my time with the macro system. Janet macros are Common Lisp-flavored unhygienic gensym-style macros. They are extremely powerful, and very easy to write, but they can be pretty tricky to get right. It’s easy to make mistakes that lead to unwanted variable capture, or to...
I never thought it could happen to me. I mean, parentheses? In this day and age? But for the past couple years, my go-to programming language for fun side projects has been a little Lisp dialect called Janet. (print "hey janet") I like Janet so much that I wrote an entire book about it, and put it on The Internet for free, in the hopes of...
I wrote a book. It’s called Janet for Mortals, and it’s free, and it’s on the internet, and you can read it right now. And you should read it right now, instead of reading this blog post, because this blog post is not very interesting if you haven’t read the book. Heck, this blog post is not very interesting even if you have read the book. This...
Take a look at this: This is a triangulation of a set of random points, such that all the points are connected to one another, all of the faces are triangles, and the edges include the convex hull of the points. I would like to claim that this is not a very “good” triangulation. This algorithm tends to produce lots of long, slivery triangles, and...
Earlier this year I wrote zsh-autoquoter, a little zsh extension that automatically quotes arguments to commands of my choice. (asciinema demo) I’ve been using it for a few months now, and I’ve gotta say: it’s pretty nice! I wish I’d written this a long time ago. Here are a few use cases I’ve found for it so far: 1. commit messages git has a neat...