Swift and Objective-C: An Ouroboros

For the release of Swift 3, I have created an ouroboros program using Swift, and that old language dear to my heart, Objective-C. This is a program that is a type of quine: starting as a Swift program, running it will print out an Objective-C program. Running this resulting Objective-C program will print out the original Swift program, which of course prints out the Objective-C program again, on and on forever.

I wanted to make something celebrating my relationship with Objective-C and Swift, and their relationship with each other. The Objective-C version uses Foundation, but I thought it was appropriate to write the Swift code using only native Swift objects. If you're unfamiliar with quines, the code should provide a decent example of the basic technique. Either way, I hope you enjoy this small program that links the past and the future.

The code and instructions for running it are here on GitHub.

Leave A Comment

Your email address will not be published. Required fields are marked *