Programming Leftovers
-
What is a Matrix? A Miserable Pile of Coefficients!
Linear algebra is undoubtedly the most useful field in all of algebra. It finds applications in all kinds of science and engineering, like quantum mechanics, graphics programming, and machine learning. It is the “most well-behaved” algebraic theory, in that other abstract algebra topics often try to approximate linear algebra, when possible.
For many students, linear algebra means vectors and matrices and determinants, and complex formulas for computing them. Matrices, in particular, come equipped with a fairly complicated, and a fortiori convoluted, multiplication operation.
This is not the only way to teach linear algebra, of course. Matrices and their multiplication appear complicated, but actually are a natural and compact way to represent a particular type of function, i.e., a linear map (or linear transformation).
This article is a short introduction to viewing linear algebra from the perspective of abstract algebra, from which matrices arise as a computational tool, rather than an object of study in and of themselves. I do assume some degree of familiarity with the idea of a matrix.
-
How to check something isn't an email address?
So determining whether or not your user has entered a valid email address becomes an ever-increasing challenge.
But what if you have the opposite issue? Suppose you have a form which takes something which mustn't be an email address?
-
Toolchains adventures - Q3 2023
This is the eighth post in my toolchains adventures series. Please check the previous posts in the toolchains category for more context about this journey. There was no Q2 2023 report as there wasn't really anything worthwhile to write about.
-
Racket Beyond Languages
Chris Krycho, a person I really respect, is learning Racket to build programming languages. Racket is generally slotted as a language to build languages. The popular books focus on Racket innovations related to constructing Domain Specific Languages. This include hygienic macros, the Racket loading and evaluation phases and the module system. While it is uniquely suited for creating languages 1, Racket is also a research vehicle for a large body of programming language research. I wanted to call out other powerful abstractions that Racket offers, most of which aren’t present in main stream languages. This is a survey post, so I haven’t spent time showing examples 2. However, I’ve tried to link to other people that demonstrates the power of these abstractions with some examples. This focuses only on features available in the Racket runtime or standard library, not third-party packages.
Note that while I’ve been programming for a long time, I’ve only messed around with Racket for about a year. I am likely still in the honeymoon phase. However, I still think I’ve seen enough cool things to add another voice shouting from the rooftops.
-
YAML config file? Pain? Try Lua
Several articles about using YAML for configuration have been making the rounds, yet rarely do I see Lua being mentioned as an alternative for configuration files.
Yes, it's a language, but it started out life as a configuration format. It's also small for a language, easy to embed, and easy to sandbox for the paranoid. Here's an example: [...]
-
A classic blunder, like getting involved in a land war in Asia
If you look close, you'll see there's a missing comma after the THEN token, and in C, two literal strings separated by whitespace are concatenated into a single string. Thus, all the THENNOTs I was seeing. And a bunch of incorrect code because most of the BASIC keywords were then off-by-one (a classic mistake of C programming).
-
Things I’ve learned about building CLI tools in Python
I build a lot of command-line tools in Python. It’s become my favorite way of quickly turning a piece of code into something I can use myself and package up for other people to use too.
My biggest CLI projects are sqlite-utils, LLM, shot-scraper and Datasette—but I have dozens of others and I build new ones at the rate of at least one a month. A fun recent example is blip-caption, a tiny CLI wrapper around the Salesforce BLIP model that can generate usable captions for image files.
Here are some notes on what I’ve learned about designing and implementing CLI tools in Python so far.