Approachable Concurrency
// In '-default-isolation MainActor' mode
struct Image {
// The image cache is safe because it's protected
// by the main actor.
static var cachedImage: [URL: Image] = [:]
static func create(from url: URL) async throws -> Image {
if let image = cachedImage[url] {
return image
}
let image = try await fetchImage(at: url)
cachedImage[url] = image
return image
}
// Fetch the data from the given URL and decode it.
// This is performed on the concurrent thread pool to
// keep the main actor free while decoding large images.
@concurrent
static func fetchImage(at url: URL) async throws -> Image {
let (data, _) = try await URLSession.shared.data(from: url)
return await decode(data: data)
}
}
By running async functions in the caller’s execution context concurrency is more approachable now with Swift 6.2
posts/2025/10/09/swiftWhen should you use an actor?
You need a) non-Sendable state that requires b) atomic mutations which c) cannot be done on the main thread. If you are missing any one of these qualities you should be looking at other options. And if you cannot tolerate asynchronous accesses, then you must.
– Matt Massicotte on when to use actors
posts/2025/10/05/actorBrain Rot Dot Com
Pay attention to The Sirens’ Call by Chris Hayes.
An ambitious analysis of how the trivial amusements offered by online life have degraded not only our selves but also our politics.
— New York Times
posts/2025/10/03/brainWhat drives you nuts?
Clutter, dirt, noise, wasting time, being bored, uncertainty, people standing too close, being looked at, having to do things, sitting still, not knowing when something will end, high noon, meetings, surprises, fascism.
– Liane Finck, who drew the cover of the August 2025 issue of The New York Review of Books
posts/2025/08/21/nutsCraftsmanship in the 21st Century
Knowledge and execution, science and technique, depend on the skills acquired by hand through the repetition of motions and their assimilation into the mind; the aim is a close connection between art and craft.
– Richard Sennett, The Troubled Craftsman
posts/2025/06/06/troubled