How we built an interpreter for Swift
In this technical retrospective (2025), @jacobx shares practical architectural lessons learned from running, scaling, or migrating production software under lean constraints.
HN engineers debated the tradeoffs between cloud convenience and raw server economics, database indexing strategies, and resisting premature architectural complexity.
Bitrig dynamically generates and runs Swift apps on your phone. Normally this would require compiling and signing with Xcode, and you can’t do that on an iPhone.
To make it possible to instantly run your app, we built a Swift interpreter. But it’s an unusual interpreter, since it interprets from Swift… to Swift.
I can't understand what they're talking about, and I don't know if it's because I know too little about programming languages or if it's because they're using unusual semantics.
"a compiled language" makes no sense to me because the language itself doesn't determine whether it's compiled or interpreted. It's just a function of what compilers/interpreters exist. I could write an interpreter for C or a compiler for Python, but the languages themselves aren't compiled or interpreted.
I also don't understand what it means to "interpret" Swift to Swift. Do they mean they compile Swift to Swift (or the more modern "transpile" which means the same thing)? But it sounds like they're doing something dynamically at runtime, so it sounds more like decompiling machine code back to Swift, but the rest of the post doesn't match that interpretation.
It looks like it is in the App Store, so I guess my question is already answered - but I wonder if they had trouble or concerns getting it accepted.
Section 2.5.2 in "App Review Guidelines" (https://developer.apple.com/app-store/review/guidelines/):
``` 2.5.2 Apps should be self-contained in their bundles, and may not read or write data outside the designated container area, nor may they download, install, or execute code which introduces or changes features or functionality of the app, including other apps. Educational apps designed to teach, develop, or allow students to test executable code may, in limited circumstances, download code provided that such code is not used for other purposes. Such apps must make the source code provided by the app completely viewable and editable by the user. ```
This is fascinating work, amazing job to the team!
Does SwiftUI have properties that uniquely make this type of interpreted system possible, or could it also use UIKit under the hood? On the surface, it seems like UIKit might be more difficult since you’d probably need to parse all of the obj-c header files in addition to the .swiftinterface.
Very cool stuff, excited to follow along how you all develop the product!
Swift can already be used in REPL mode, not sure if it's accurate to say Swift is a strictly compiled language that a interpreter was developed for (see 'swift' command line executable). Seems misleading that this is not mentioned anywhere in the article.
This is really cool, will definitely try it out. Does it allow you to move this to your computer later and actually publish the apps? What’s the end goal here?
Hi HN! Since we launched Bitrig (https://news.ycombinator.com/item?id=45041185), we've gotten questions about how it's able to run dynamically generated Swift code. I wrote up this post to answer that. Let me know if you want to know more about any aspects of it.