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. There are two things you need: … Continue reading Missing SwiftUI Preview Window in Xcode

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 … Continue reading Creating a SwiftUI Window in an Objective-C AppKit App

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. While the standard doesn't require vectors to have … Continue reading Default Capacity & Growth Rate of C++ std::vector

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 … Continue reading Warning: std::numeric_limits::min() > 0

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: __attribute__((pure)): The function may read, but doesn't modify any global state. [This is true!]__attribute__((const)): The function neither reads nor modifies global state. [This is MASSIVELY OVERSIMPLIFIED to the point of being a lie!] The gigantic asterisk … Continue reading Warning: __attribute__((const)) does not mean function purity

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? The candidates to consider are: Use Enum.map/2 and just pick out the values, ignoring the keyUse Map.values/1 and pipe the resulting list into Enum.map/2 I put together the following Benchfella microbenchmark: defmodule BasicBench do use Benchfella @test_map Map.new(1..10_000, fn k -> … Continue reading The fastest way to iterate a Map’s values in Elixir

Go ahead, call yourself a software engineer.

Ian Bogost writes for The Atlantic that programmers should stop calling themselves engineers. It's a good article, and he's right about software devs cheapening the word "engineer" with their Wild West practices. This is a sentiment that's been echoed for years. At the same time, though, there's a worthwhile distinction to be drawn between "I … Continue reading Go ahead, call yourself a software engineer.

Automated Testing Process Roundtable

Notes from a roundtable discussion moderated by Andrew Fray at GDC 2019 For more, see autotestingroundtable.comFirst steps getting started with testingFirst decide what you want out of testing; if you want a rock-solid engine, need unit tests (despite it being hard on a legacy engine)Unit testingAnalyze how long it takes you to go through a … Continue reading Automated Testing Process Roundtable