4 ms·
Running Racket CS on iOS
- ssivark 6y agoSo, does this mean that a library/module written in Racket can be called from an iOS application written in Swift? Out of curiosity, what other (popular) languages have similar support? Can someone coding an iOS app call snazzy ML/algorithms written in Python/Julia/C/Cpp? Would any language whose compiler is written on top of LLVM be a good candidate?
- watersb 6y agoI haven't worked through this yet, but it looks to me to be a technique to get ahead-of-time Racket compiler, rather than run a dynamic, interactive IDE on iOS. So you could build iOS apps using Racket on a host computer, then load those binaries onto an iOS device.
- Bogdanp 6y agoThe Racket runtime is also embedded so you can compile and run arbitrary code at runtime as well.
- dfgdghdf 6y agoWould this violate the App Store rules?
- Bogdanp 6y agoAs far as I know, no. I believe the restriction on language embedding that you might be thinking of was very short-lived.
- e12e 6y agoI'm not so sure - but it might be ok if the racket app is submitted as an interpreter. Less sure, if it is for example used to implement a game engine and game data (code) is downloaded? https://developer.apple.com/app-store/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 Application completely viewable and editable by the user.
- nickmain 6y agoOnly if code is downloaded/side-loaded after the app is installed. Racket code bundled with the app will be fine. The gray area is if the app allows the user to create new Racket code.
- saagarjha 6y agoAny language with a C API/ABI should work, really. You’d need to ship a working runtime but if you had that calling it from an app shouldn’t be hard.
- Bogdanp 6y ago> So, does this mean that a library/module written in Racket can be called from an iOS application written in Swift? Yup! There’s an example of just that at the very end.
- nickmain 6y agoDoes this allow AOT compiling of Racket code to native ARM or is everything interpreted ? Assuming that JIT is still not possible on iOS.
- jdmoreira 6y agoWhy wouldn't it be?
- nickmain 6y agoOK - apparently iOS 14.2 does allow JIT for side-loaded apps (not App Store) via the CS_EXECSEG_ALLOW_UNSIGNED flag. Maybe this will be allowed for store apps in some future version. Fingers crossed! All previous versions of iOS do not permit execution from writable memory. Via https://9to5mac.com/2020/11/06/ios-14-2-brings-jit-compilation-support-which-enables-emulation-apps-at-full-performance/ https://9to5mac.com/2020/11/06/ios-14-2-brings-jit-compilati...
- deleted 6y ago[deleted]
- saagarjha 6y agoVersions prior to iOS 14 allowed the equivalent via ptrace.
- Bogdanp 6y ago> Does this allow AOT compiling of Racket code to native ARM? Yes, there's an example of this in the section "Cross-compile Racket modules for iOS". > Assuming that JIT is still not possible on iOS. JIT on iOS is not possible for non-side-loaded apps, like you mentioned downthread. That's part of the caveats[1] I mention at the top of the article and the more complex part of the change: when compiling new code (eg. via `eval`), we flip the protection bits between W and X for the minimum set of memory segments necessary based on certain heuristics. [1]: https://github.com/racket/racket/blob/351c0047d6371e36cf422b4627e020d14e8853fe/racket/src/ChezScheme/c/segment.c#L578-L587 https://github.com/racket/racket/blob/351c0047d6371e36cf422b...