data Blog = Blog { me :: Programmer, posts :: [Opinion] }

Posts

Understanding the Strategy Pattern
Apr 3, 2022 programming concepts rust exercises
Conditionals (if, switch, and match statements) are usually the first tool programmers reach for when we need to vary the execution of a function. They’re easy to understand and convenient to use, as long as the variations are simple. As software grows, though, extensibility and comprehensibility begin to require that we create ways to “hook” new functionality into our functions. The strategy pattern offers a method to accomplish that: Define a family of algorithms, encapsulate each one, and make them interchangeable.

How Blockchains Work
Mar 6, 2021
Chances are, you know what Bitcoin is. After all, it’s valued at over $47,000 per Bitcoin right now. This post isn’t about the business side of things, though, or the BTC speculative bubble. I want to explain how it works.1 Foundations: Hashes and Ledgers First, a hash algorithm is a way to convert a given string into an unpredictable string of a fixed length, called a digest. Here’s a small Python program to demonstrate:

Abstraction is Okay, Magic is Not
Feb 26, 2021
You encounter a crusty old-timer who tells you how great programming used to be: the computer just did what you told it. Languages were simple and easy to understand. In awe, you ask: “Did you write FORTRAN? or assembly?” The old-timer laughs: he’s not that old. He started with C! It’s common to think of C and other “old” languages as being “close to the machine,” but that’s because the Unix abstractions have become so ubiquitous that we no longer think of them as abstractions.

Rust Needs Metaphors, Part 2: Traits
Oct 14, 2020 programming rust
When I began learning Haskell, typeclasses were confusing to me: at first, because I didn’t fully understand why they were needed, and later, because I didn’t understand the advantages they offered over Java’s interfaces. If you’re new to Rust but haven’t used Haskell before, you’ll likely be in the same boat, but moreso; traits are pervasive in the ecosystem. At heart, traits are very similar to interfaces in Java or C♯.

Rust Needs Metaphors, Part 1: Lifetimes
Sep 19, 2020 programming rust
I recently had a conversation with a friend who said: “I don’t trust most of what I hear about Rust, because it sounds like agitprop from the Rust Evangelism Strike Force, but people like you whom I trust and respect seem to like it. Can you help me understand why?” I tried to. I said things that make sense, in the abstract: it offers a very powerful type system, it allows me to feel more confident about my code in surprising ways, and so on.

Under the Rug: Hidden (but Essential) Complexity
Apr 23, 2020
I don’t like docopt. That makes me an outlier; most people I’ve talked to seem to think it makes command-line applications “easy.” They like its premise that, by writing documentation, you’re writing code. When you make a command-line application with docopt, you’ve automatically got the help text written and the module documented properly, right? Why bother with something verbose and object-oriented like argparse? My objection is that you aren’t writing code, but you’re also not writing documentation, despite the name of the package.

Loops and Recursion
Dec 22, 2019 programming concepts exercises
Recursion was a concept that took me a long time to understand. It wasn’t until years after I’d started programming that I felt I really understood it, and it wasn’t until years after that that I felt confident reaching for it as a tool. Like almost everyone, the first way that I learned to think of iteration was with loops. If you wanted to add something together, for example, you would create a “bookkeeping” variable and modify it inside the loop.

The M-Word: The Culture of Programming
Dec 14, 2019 programming learning teams
In addition to [the monad] being useful, it is also cursed and the curse of the monad is that once you get the epiphany, once you understand—“Oh, that’s what it is!"—you lose the ability to explain it to anybody. — Doug Crockford. I had a problem, once. I was working on a Rails application which generated integration files to be consumed by external partners. They were generated every night in a dozen formats and shipped around the Internet to populate sites you’ve probably used.

Mind the Gaps
Dec 12, 2019 programming learning
“If you truly accumulate effort for a long time, then you will advance.” Xunzi. It’s no secret that many programmers are self-taught. Some of us, myself included, lack formal credentials related to computer science. I’ve worked with good programmers who didn’t graduate high school. It’s a strange profession, with the skills often acquired simply as a side effect of tinkering. You don’t hear about many civil engineers or corporate attorneys who do what they do because they enjoyed playing Zork on their dad’s office computer.

On Symbolic Logic
Nov 20, 2019 programming math logic
I went to public school in the United States, and I was always “bad at math.” I hated homework and tests, and it never got better: as I went through the grades, the problems got longer and more intricate, and I inevitably would make a calculation error—misplacing a decimal or flubbing an easy sum—halfway through. I got used to seeing $\color{red}{-\frac{1}{2}}$ on my papers. Those add up! In college, the first thing I did when planning my path through general education was look for a way to avoid Calculus.

The Danger of “Simplicity”
Nov 16, 2019 simplicity trust
There are a few tendencies among programmers that involve the totem of “simplicity.” There’s the ancient concept of KISS, of course, but there’s also the much-abused YAGNI, the insistence that we “Choose Boring Technology," entire languages that base their elevator pitch around the idea that they’re “simple,” and the concept in object-oriented design that “every class should have a single responsibility.” The problem with these approaches is that “simplicity” never gets a rigorous definition.

“Parsing” in Python
Nov 10, 2019 programming python trust types

I recently read “Parse, Don’t Validate,” shared it with my coworkers, and let it bring me out of retirement on lobste.rs. It captures a concept that I’ve struggled to explain, leading to cases where I couldn’t say why I thought something was better beyond a vague “It’s a matter of taste.” That’s not very satisfactory as a justification when you’re trying to explain to someone why they should rework a piece of code in a review.