Can we use Clojure like a general library in Java?

Showing 1-7 of 7 messages
Can we use Clojure like a general library in Java? Solomon 6/1/12 5:53 PM
Hi,the Thoughtworks technology radar mentioned below:


Functional programming continues its slow but steady ascent into developer mind share and, increasingly, code bases. New languages like Clojure, Scala, and F# offer great new features. Now libraries such asFunctional Java, TotallyLazy and LambdaJ are back porting some functional language capabilities, particularly around higher-order functions and collections, into Java. We like this trend because it previews common capabilities of future languages yet allows developers to stay in their comfort zone. 

So I am interested,if Clojure can be used like a general library in Java,it will beat above libraries and be awesome !

--
Solomon
Google+: Qihui Sun



Re: Can we use Clojure like a general library in Java? Sean Corfield 6/2/12 1:55 PM
On Fri, Jun 1, 2012 at 5:53 PM, Qihui Sun <qihu...@gmail.com> wrote:
> So I am interested,if Clojure can be used like a general library in Java,it
> will beat above libraries and be awesome !

Yes, you can instantiate clojure.lang.RT inside your Java code and
load, compile and invoke Clojure code, directly from Java. You can
also write code in Clojure, compile it to .class files, package it as
a JAR and use it like a regular Java library.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
Re: Can we use Clojure like a general library in Java? Philip Potter 6/2/12 2:00 PM

Yes it can! It's just a jar file after all, so you can use the classes in your java program if you like.

However, clojure data structures typically do not use static typing as java uses it. For example, PersistentVector is a collection of Objects and not genericized. Getting things out of such a vector will no doubt require typecasting, just like the old 1.4 days.

Phil

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
Re: Can we use Clojure like a general library in Java? Solomon 6/2/12 7:31 PM
Thanks above two reply.
As Sean Corfield said,it is a bit complex.If there is a command option,ONE TIME do this,it will more convenient.
For example: 
java -jar clojure-1.5.0.jar -genclasses,will produce clojure-lib-1.5.0.jar,and it is  genericized as Philip Potter mentioned!

Maybe Clojure as a general/regular Java lib will get more widely to adopt,be more successful than a language :).


2012/6/3 Philip Potter <philip....@gmail.com>
Re: Can we use Clojure like a general library in Java? Sean Corfield 6/2/12 8:40 PM
On Sat, Jun 2, 2012 at 7:31 PM, Qihui Sun <qihu...@gmail.com> wrote:
> For example:
> java -jar clojure-1.5.0.jar -genclasses,will produce
> clojure-lib-1.5.0.jar,and it is  genericized as Philip Potter mentioned!

Sounds like what you want is Leiningen, to generate an uberjar,
optionally with compiled classes.
Re: Can we use Clojure like a general library in Java? Krukow 6/3/12 5:43 AM
Regarding those... 

Some time ago I created a project containing only the persistent data structures for use with Java et al. 


It is the data structures only so no bootstrap penalty. There are also Java'ish "improvements" like basic Generics and improved performance on the iterator pattern.

It's still on Clojure 1.3 (As far as I recall), but I am planning on taking another iteration.

TODO:

- better Generics support
- more data structures  (tries, RRB-trees)
- include the reducers library support for parallelism

given this is a spare time project, I welcome everyone interested to contribute.

/Karl
Re: Can we use Clojure like a general library in Java? Solomon 6/7/12 7:42 AM
Thank you! It seems a good begin.

2012/6/3 Karl Krukow <karl....@gmail.com>