logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·03.11.26
← Back to news

Bringing Swift to the Apple ][

Original article
yeokhengmeng.com|44 points|2 comments|by LucidLynx|Jun 25, 2026

Porting Swift to the Apple II

By Yeo Kheng Meng — Maker, Coder, Private Pilot, and Retrocomputing Enthusiast Date: June 25, 2026 | Read Time: ≈33\approx 33≈33 minutes

Swift is the powerhouse language driving modern Apple ecosystems. I wondered: could a taste of this modern syntax be brought back to Apple's origins? Specifically, the Apple II, the company's first mass-market hit released in 1977, powered by a 1 MHz MOS 6502 CPU.

The result is SwiftII, a specialized, Swift-flavored development environment designed for the original Apple II through the IIe.

A Note on Process: I'll be honest—this was built in my spare time with significant assistance from AI. I intend to be transparent about that workflow later, as the intersection of LLMs and retro-coding was just as fascinating as the project itself.

The Scope of SwiftII

It is impossible to fit the entire Swift standard library into such a limited machine. Therefore, SwiftII is a full-scale deliberate subset of the language. It is closer in philosophy to Embedded Swift than the massive SDKs used for macOS or iOS.

My primary objectives were:

  • Ensure the code looks and feels like Swift at a glance.
  • Maintain a high-quality developer experience (DX).
  • Implement a functional interpreter.
  • Build supporting tools (launcher, file selector, and text editor) to bypass Apple II hardware limitations.

🗺️ Project Roadmap

Because this is an extensive deep dive, here is a guide to the technical sections:

CategoryKey Topics Covered
The BasicsMotivation, Target Hardware, Language Features
Technical ConstraintsThe 40,704-byte limit, Memory Banking, 64K+ RAM
The PipelineCompilation flow, Bytecode structure, Binary families
The UXREPL behavior, Keyboard digraphs, Display issues
The ToolingFile browser, Text editor, Disk distribution (9x disks)
The ProcessAI collaboration, Claude vs. Codex, Documentation

🖥️ The Application

Upon booting the correct disk, you are greeted by a launcher. From here, you can access:

  1. An interactive REPL (Read-Eval-Print Loop).
  2. A file browser to execute .swift programs directly from disk.
  3. A built-in full-screen editor.

Visuals and Demos

The project is fully functional on an original Apple II Plus. Because the II Plus keyboard lacks lowercase letters and the \ key, the system utilizes digraphs for input.

Featured Capabilities:

  • xsnake: A playable "light-cycle" style game.
  • xgrdemo: A showcase of lo-res color graphics using gr, color, and vlin.
  • Full-screen editing (optimized for the IIe 80-column display).

GitHub Repository: https://github.com/yeokm1/swiftii


💡 Motivation

Having previously squeezed a ChatGPT client into DOS and a Slack client into Windows 3.1, I wanted to see if I could port a modern language to vintage silicon.

I looked back to 1979 and Apple Pascal, which utilized the UCSD p-System. Instead of compiling directly to 6502 machine code, it used a Virtual Machine (VM) to execute bytecode. I adopted a similar architecture for SwiftII:

By avoiding native code generation, I could implement a REPL—a staple of the modern Swift SDK—allowing users to test logic interactively.


🛠️ Target Hardware

The baseline is the 1977 Apple II. If it works there, it works everywhere. My specific testbed is an Apple II Plus with the following specs:

  • CPU: MOS 6502 @ 1 MHz1 \text{ MHz}1 MHz
  • RAM:
    • 48 KB Main RAM
    • Clone Saturn 128K card (acting as a 16K Language Card)
    • Total Addressable: 64 KB64 \text{ KB}64 KB
  • Video: Clone Videx Videoterm (80-column support)
  • Storage: Yellowstone universal disk controller →\rightarrow→ Floppy Emu
  • OS: ProDOS 2.4.3 (The modern ProDOS 8 revival)

Hardware Compatibility Note: The original 1977 model is supported provided it has 48 KB RAM and a 16 KB language card. On machines without Autostart, use C600G or PR#6. The Apple IIe is highly recommended for a better experience due to its native lowercase and ASCII keyboard.

CPU Architecture Detail

The MOS 6502 is an 8-bit processor. Its primary registers are:

  • A (Accumulator): 8-bit
  • X (Index): 8-bit
  • Y (Index): 8-bit

free hit counter


⚙️ Technical Implementation (Preview)

The system operates by transforming human-readable Swift into a compact bytecode.

Example of the conceptual logic flow:

// SwiftII Source
let x = 10
print(x)

↓\downarrow↓ [OP_PUSH_CONST 10] [OP_STORE_VAR 0] [OP_LOAD_VAR 0] [OP_CALL_PRINT]

This approach allows the language to exist within the tight constraints of the Apple II's memory map, specifically managing the critical 40,704 bytes available for the core engine.