AppKit State Restoration on macOS 14 Sonoma AppKit state restoration behaviour changed on macOS 14 Sonoma in a subtle way that can lead to apps not restoring their state correctly. The change can lead to silent breakages which can be hard to debug. Behavioural Changes The AppKit release notes for macOS 14 state: Secure coding is automatically enabled for restorable state for applications linked on the macOS 14.0 SDK. Applications that target prior versions of macOS should implement NSApplicat...| milen.me
Windows XP I have a lot of fond memories of Windows XP and after feeling nostalgic, I was happy to find out that it’s relatively easy to take it for a spin on an ARM64 Mac using QEMU. I decided to install XP and an assortment of classic software one final time, taking screenshots of the whole process. This included Firefox, Winamp, WinZip, mIRC, Borland Delphi and Visual C++ 6.0.| milen.me
Auto Linking Explained When object files get linked at the final build stage, the linker needs to know which libraries to link against. For example, if you add #import to an implementation file, you need to also add -framework AppKit to the linker flags. Auto Linking aims to remove the latter step, i.e., it aims to derive the library linker flags from the import statements in your code. Developers do not need to add any framework/library linker flags anymore, they can just start using any fr...| milen.me
TL;DR Determinism plays an important role in the ability to cache output of compilation. Distributed caching and compilation enable quick iteration on large scale software. Computation of distributed cache keys is non-trivial as not all inputs are explicit. A suitable distributed cache fill strategy is required for consistently fast local builds. Deterministic Builds Deterministic builds can be defined as: A build is called deterministic or reproducible if running it twice produces exactly th...| milen.me
TL;DR Universal deterministic builds require that all paths in artifacts must be repo checkout independent. On Apple platforms, the linker will insert absolute paths to object files in executables. In Xcode 11, Apple added a new linker option, -oso_prefix, that can relativise OSO absolute paths. Another source of non-determinism in object files are the OSO timestamp entries. Deterministic Builds One of the requirements for universal deterministic builds is that they are independent of the sou...| milen.me
“Premature Optimization” You might have come across the famous software optimisation quote popularised by Donald Knuth: Premature optimization is the root of all evil. – Sir Tony Hoare It has been commonly interpreted as “don’t think about performance in the beginning, you can fix any performance problem later”. This interpretation is completely and categorically wrong. Original Quote It’s very common for statements to lose their original meaning when context has been stripped a...| milen.me
AppKit vs SwiftUI: The Question When writing a native macOS app, developers need to decide which UI framework to write new code in. AppKit, whose origins date back to 30yrs+ ago, feels like a dinosaur soon to be retired with the shiny SwiftUI waiting around corner to take over. Ghostty vs SwiftUI Mitchell Hashimoto has been working on a new cross-platform terminal written in Zig and posted a update on the project’s progress.| milen.me
Why? A lot has changed since I’ve last updated my website. The current design dates back to July 2012, more than 10yrs ago. Not only has technology moved on since then, what I value and how I approach engineering has changed as well. While Jekyll has served me well, it was time to move to a more robust and actively maintained ecosystem that will hopefully last for another 10yrs. Simplicity An overarching theme in my life for the past decade has been the pursuit of simplicity over complexity...| milen.me
TL;DR When describing the performance of systems, always prefer terms which are unambigious. Use “as fast as” speed ratios and “as long as” time ratios. Always use “faster” or “slower” when referring to speed, never time. When referring to time in percentage delta terms, explicitly state “time increased/decreased by X%”. Time ratio is time_new / time_baseline and speed ratio is time_baseline / time_new. Performance Language & Ambiguity As part of my work on the Buck2 build...| milen.me
TL;DR Getting accurate network metrics on macOS is possible using sysctl() with NET_RT_IFLIST2. Traffic metrics are exposed in units of 1KiB to prevent fingerprinting (only for 3rd party programs). As of macOS Ventura 13.2.1, there’s a kernel bug which truncates traffic values at the 4GiB mark. Using getifaddrs() only exposes 32bit fields, so it’s not a viable API on modern systems. Updates Mojo_66 pointed out that IFMIB_IFDATA does not suffer from truncation (code).| milen.me