Delightful Multiplayer Editing in Phoenix
This is the video and slide deck from my conference talk at ElixirConf 2022.
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…Taking Hashrocket’s “Ultimate Elixir CI” to the Next Level
Over on the Felt blog I wrote about how we pushed our continuous integration (CI) system for Elixir to enable devs to be more productive. The examples are all in GitHub Actions, but you can probably translate it to whatever CI system you’re using.
The highlights:
- Deploy a staging environment (a complete reproduction of our production environment) for every PR, and update it as new commits get added
- Run most CI jobs in parallel so that you get the fastest feedback, and make the jobs never “fail fast,” so you’ll know all the things you need to fix on the first run
- Refactor boilerplate for setting up and caching the project into shared “composite” actions
- Clear the build cache when a human asks for a retry, neatly resolving mistrust of build caches
- Report code coverage in the GitHub PR description, and update it as new commits are added
- Run as much static analysis as we can
- Use Dependabot to get PRs to update our dependencies
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
[Post-publication update: This post turned into a conference talk at ElixirConf 2021, embedded here for posterity.]
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.
This post (and the feature itself!) was a long time in coming. It’s cool to be able to talk about it publicly.
On a related note, we open-sourced the Elixir implementation of the networking protocol we use for MMO. The README there gives a pretty good overview of the architecture of our MMO server—long story short, we go to great lengths to minimize shared state.
This won’t be of use to many people, but I do hope it’s useful to the next poor soul who needs to build a server around RakNet. ☺️
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.