← All questions

Raku++ in an iOS or Android app

Yes, an app can carry the engine. It runs as native code, built for the phone's processor and called through the same C ABI any other host uses, not as WebAssembly in a web view. This page answers the questions that come first; the build flags, the source changes and the host-side details are in EMBEDDING.md.

The short answer #

The Learn Raku app, the Course of Raku for iOS and Android, works this way: the course's examples have Run buttons, and there is a playground.

Native, or Raku.js in a web view? #

Both run Raku++. Natively, Raku code gets what the browser build cannot give it:

native libraryRaku.js in a web view
start, await, hyperwork: real threadsno: the WebAssembly build is single-threaded
recursion depthas deep as the stack you give itabout 200 nested calls
speedthe rakupp interpreterthe same interpreter, as WebAssembly
between the UI and the enginea C callJavaScript and a message bridge
added size16–20 MB per architectureabout 7 MB of .wasm, plus the web view

Neither has a JIT. Both platforms forbid an app to map executable memory, and the browser build has none either.

What can a program do on a phone? #

Most of the language is unaffected, and nearly every example in the Course of Raku runs unchanged. The differences are about the platform:

Can the app stop a runaway program? #

Not with the 5.4.1 ABI alone: there is no rk_interrupt yet, and an interpreter cannot be freed while it is running. Learn Raku adds one with a small patch: a flag checked at each statement, block entry and loop iteration, which ends the program with X::AdHoc "Interrupted". It also caps the output it buffers, so a loop { say 1 } stops at a megabyte instead of filling memory.

Will the App Store and Google Play accept it? #

Apple's App Review guideline 2.5.2 allows an educational app to run code that the user writes, provided the app does not download code to run. Google Play restricts downloading native code; an interpreter running programs typed into the app is not that. In both cases the interpreter has to be inside the app as submitted, which a native library is.

Where do I start? #

EMBEDDING.md has the source list, the compiler and linker flags for both platforms, the four source changes 5.4.1 needs on them, and how the host side handles threads, output, input and stopping.