←back to thread

82 points jacobx | 1 comments | | HN request time: 0s | source
Show context
mtlynch ◴[] No.45131147[source]
>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.

replies(2): >>45131434 #>>45131746 #
1. nxobject ◴[] No.45131746[source]
> 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.

My understanding is that this system walks the syntax, creates autogenerated wrappers to API structures/functions, and simply invokes them as the syntax directs – as it says, a "glorified FFI". It is not a full free-standing Swift runtime, but it's a very clever hack.