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

programming

Understanding the Strategy Pattern
Apr 3, 2022 programming concepts rust exercises
Conditionals (if, switch, and match statements) are usually the first 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.

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.

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 it begin 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.

“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.