5 ms·
Interesting, this means you can theoretically run Clojure code on the iPhone: http://jlongster.com/legacy/scheme-iphone-apps.html http://jlongster.com/legacy/s
by julian37 15y ago
Interesting, this means you can theoretically run Clojure code on the iPhone:
http://jlongster.com/legacy/scheme-iphone-apps.html http://jlongster.com/legacy/scheme-iphone-apps.html
- jlongster 15y agoThat's my old blog, and looks like I broke the link to the newer page with more concise installation instructions. Yikes. I tried to keep those pages around. I'll see if I can fix that soon.
- gukjoon 15y agoThis is awesome, but what gives me pause is the part where you have to write a foreign function interface for every single Carbon API call. Also, I would assume that Cocoa is completely unavailable when going to C. Is that correct? I'm very happy to see the multi-platform vision of Clojure becoming closer to reality. I'm not in the "write once, run everywhere" camp. That goal is a bit ridiculous, but the choice of VM and the choice of language should be independent decisions. I like Erlang's VM a lot, but the language itself is not very nice. When writing iPhone code, I don't want to be forced to use Objective C.
- jlongster 15y agoEvery new language/environment has the problem of needing interfaces into the lower-level system. If this takes off, you can expect the people to build the FFIs and share them. If not, usually it's not too difficult to only wrap the calls that you need. There are also methods for automatically generating FFIs, although that only works with certain APIs. Cocoa is definitely accessible from C. Objective-C is just a superset of C, so if you compile all the generated C files as Obj-C you can write any Cocoa code you want.
- chc 15y agoI think you have it backwards what subsets and supersede are. The subset (C) by definition does not have everything in the superset (Objective-C), and one of the crucial features missing is Objective-C's object model and message passing. This is not intractable (BridgeSupport and the runtime API should be sufficient), but it will definitely be more work than writing Objective-C directly.
- jlongster 15y agoThat's what I said, Objective-C is a superset of C. C is a subset of Obj-C. You can simply do this (the actual FFI call might be wrong, it's been a while): (c-lambda (ptr) void "[___arg1 sendThisMessage:1];") You can literally code Obj-C straight into it.
- neutronicus 15y agoIt's (a lot) more work, but there's a C interface to Cocoa (just use objc_message_send). I know that this is how Clozure Common Lisp interfaces with Cocoa.
- takeoutweight 15y agoNo longer just a theory! The Gambit iOS repl is quite happy to run the scheme files generated by clojure-scheme. There has just recently been a port of the iOS Gambit repl to Android (using NDK and JNI I think)--I'm looking to try that out next.
- keithflower 15y agoInfo on the Android port is here: http://apps.keithflower.org/?page_id=152 http://apps.keithflower.org/?page_id=152 I'm about to release an update to match the iOS version accompanying Gambit v4.6.5 (as close as I can get).