Translating User Interfaces Is Way Harder Than You Think (And You’re Probably Doing It Wrong)
Don’t Write Exploding Streams
Suppose you have a Stream
of values that you want to insert into the database. You can do this easily in many modern programming languages, but here’s what it might look like in Elixir:
Refactoring Toward Algorithms in Elixir
Algorithms give a name to a kind of data transformation. They’re the building blocks of programs, and they’re fractal: a program as a whole can be seen as an algorithm, and it’s made up of many smaller algorithms; those algorithms are in turn made up of smaller ones.
Continue reading…Oakland, CA
Write More Pure Functions
Let me begin by saying: you probably shouldn’t read this. You have a limited amount of time, and you’re probably better served reading John Hughes’ seminal Why Functional Programming Matters. But this is my perspective on why pure functions are important—the stuff I feel viscerally day to day, not academically. It’s my exhortation to think about this stuff constantly in the course of programming, even in languages that don’t strictly enforce it—maybe especially in those languages.
Continue reading…What You Need to Know as a New Team Lead
So you’re becoming a software team lead. If this is your first foray into the management track (as it was for me), you probably have a lot of questions about what you’re, um, supposed to do. This is a brain dump of some of the stuff a new team lead might need to know—things I wish I’d known when I started.
Continue reading…Shooting Yourself in the Foot with GenServers
Elixir’s GenServers are great. Their fault tolerance makes them a natural choice for situations where you need to store some state over time in a resilient way. They’re not without their gotchas, though. In particular, it’s quite easy to fall into traps with respect to scheduling work within the GenServer’s process.
Continue reading…Enum.slide/3 is coming in Elixir 1.13
Earlier this week, José Valim merged my first PR to the Elixir standard library. (Woohoo!) I figured it was worth creating a blog post to explain what a “slide” is, and why it might be valuable.
Continue reading…Fall at Red Barn Farm
Rogers, AR 2021
Architecting GenServers for Testability in Elixir
This post is an attempt to lay out my philosophy on how we should be designing GenServers in Elixir. It says “… for testability” in the title, and we’ll focus on that, but there’s also a lot here on deciding what and how to test, as well as thinking about what the testing can tell us about how the rest of the system will use our module.
Continue reading…San Diego 2021
Iterating Over a Generic Sequence in Swift
Here’s a goofy bit of generic programming I do all the time in Swift—ironically, it’s one thing C++ makes easier than Swift!
Continue reading…A look inside X-Plane’s massive multiplayer server
This morning I published a blog post on the X-Plane Developer blog titled “Have You Heard the Good News About Elixir?.” It’s a look at the requirements and goals that drove me to choose Elixir for X-Plane’s massive multiplayer game server, with a look at both the pros and cons of that choice.
Continue reading…Missing SwiftUI Preview Window in Xcode
This is no doubt obvious if you’ve dutifully watched all the WWDC sessions on SwiftUI, but if you’re like me and just diving in and hacking the hell out of it, you might be baffled that the much-renowned preview pane isn’t showing up when you create your SwiftUI View
.
Creating a SwiftUI Window in an Objective-C AppKit App
I’ve been “rehabbing” a legacy Objective-C app (the Unbound photo browser), trying to make up for a couple years of neglect, and I wanted to start building new views in SwiftUI. There are a lot of good tutorials online for hosting SwiftUI views in UIKit apps (either iOS/iPadOs or macOS + Catalyst), but not much on how to do this for Mac and AppKit… and especially not when you’re still mostly Obj-C!
Continue reading…Warning: std::numeric_limits::min() > 0
Here’s a baffling design choice (which I’m reliably informed C++ inherited from older C limits.h
).
std::numeric_limits<int>::min()
is roughly -2 billion (assuming 32 bit ints, etc.).
But std::numeric_limits<float>::min()
is smallest positive floating point value… something like +0.00000000000000000000000000000000000001.
CppReference warns this is the case for all floating point types with denormalization (thus it applies to double
and long double
as well on vaguely x86-like platforms).
What you’re probably looking for (the actual opposite of std::numeric_limits<float>::max()
) is std::numeric_limits::lowest()
.
Default Capacity & Growth Rate of C++ std::vector
If you’re creating a lot of small vectors in C++, you should probably consider using a small-size optimized vector instead. But, if you can’t do that for some reason, you might wonder if there is any win to be had by reserve()
ing a small size in advance.
Warning: __attribute__((const)) does not mean function purity
Clang and GCC (and others) support function attributes __attribute__((const))
and __attribute__((pure))
. These had always been explained to me thus:
The fastest way to iterate a Map’s values in Elixir
Say you have an Elixir Map
. What’s the fastest way to iterate the values?