I took a different tack with clojure-scheme by compiling via Gambit Scheme, which can target Objective-C. https://github.com/takeoutweight/clojure-scheme. This approach made it easier to provide self-hosted compilation, enabling niceties like an on-device repl.
I recently wanted to try out clojure-scheme for a simple Mac OS X or iOS app, but I couldn't easily find an example app that shows how to set up a project to target Objective-C and compile correctly, and what to import to call the Apple frameworks.
Is that even possible? If yes, is there some sort of sample that I didn't see?
I would be very curious to understand the runtime implications of imposing immutability on an Objective-C program. Presumably porting that was a lot of work.
Many Cocoa classes are immutable (NSString, NSDictionary, NSArray). You can use the mutable versions (i.e. NSMutableString, NSMutableDictionary, NSMutableArray) but there's no reason to if the immutable versions are a better fit for clojurem.
If by runtime implications you mean speed, I think it'd be ok. Objective-C makes heavy use of immutable data structures already, and iPhone apps just don't have that much data, anyway.
I haven't looked at the source, but the avoidance of full copy-on-write, laziness and instrumentation of immutable structures when returning from functions that update / assoc them will be non-trivial to get right. Not even to mention software transactional memory Clojure supports at all.
Immutability in general isn't that big of a deal. The problem is that Clojure uses persistent trees for all datastructures, which will trigger alot of retain/release calls. Other than some RC overhead, it should work just fine. A GC would be ideal however.
Implementations already exist for the CLR as well as Python, C, Scheme, and of course JavaScript. LLVM appears to be in the thinking stage still: https://github.com/halgari/clojure-metal
The only dependency to the JVM would be the advantage of integrating with the Java ecosystem.
When compiling Clojure to native code, you won't be able to use Java libraries, unless the native compiler can also generate native code for .class files.
Clojure's one real advantage is Java interoperability and it is its biggest single selling point.
You just can code nice and quick in a language much nicer than Java, but easily access all that code from our_stalled_corporate_crap.jar, and package/deploy it the way they do it in their Java EE world.
Persistent datastructures, STM, CAS concurrency primitives and hygenic macros make no sense outside of the JVM? Please...
Clojure has host language interop, this isn't necessarily the same as Java interop. It would be very nice to write an iOS app using Clojure for instance.
Targeting another popular platform, Objective-C with the Apple libraries, makes a lot of sense to me. That, and C#/.NET (which is already a thing with clojure-clr) seem like the obvious candidates.
[+] [-] takeoutweight|12 years ago|reply
[+] [-] terhechte|12 years ago|reply
Is that even possible? If yes, is there some sort of sample that I didn't see?
[+] [-] dgellow|12 years ago|reply
[1] https://github.com/joshaber/clojurem/tree/refactor-fns
[+] [-] javajosh|12 years ago|reply
[+] [-] robterrell|12 years ago|reply
[+] [-] MaxGabriel|12 years ago|reply
[+] [-] nickbauman|12 years ago|reply
[+] [-] Skinney|12 years ago|reply
[+] [-] gvickers|12 years ago|reply
[+] [-] adambard|12 years ago|reply
[+] [-] trentmb|12 years ago|reply
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] elwell|12 years ago|reply
[+] [-] AlexanderDhoore|12 years ago|reply
I would really like to see a Clojure on LLVM project though. Maybe speed won't be better, but memory usage and boot times might.
[+] [-] phaedryx|12 years ago|reply
[+] [-] markc|12 years ago|reply
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] pjmlp|12 years ago|reply
When compiling Clojure to native code, you won't be able to use Java libraries, unless the native compiler can also generate native code for .class files.
[+] [-] rbanffy|12 years ago|reply
I saw the Xcode requirement but I had hopes it would work on Linux.
[+] [-] melling|12 years ago|reply
[+] [-] dschiptsov|12 years ago|reply
You just can code nice and quick in a language much nicer than Java, but easily access all that code from our_stalled_corporate_crap.jar, and package/deploy it the way they do it in their Java EE world.
Clojure outside Java ecosystem makes no sense.
[+] [-] Skinney|12 years ago|reply
Clojure has host language interop, this isn't necessarily the same as Java interop. It would be very nice to write an iOS app using Clojure for instance.
[+] [-] dkersten|12 years ago|reply
At the very least, ClojureCLR and ClojureScript most certainly do make sense.
[+] [-] zephjc|12 years ago|reply