Grails And Clojure

67 views
Skip to first unread message

Jeff Brown

unread,
Jul 18, 2009, 11:58:42 PM7/18/09
to clo...@googlegroups.com
I have released version 0.1 of a plugin which provides support for easily accessing Clojure code in a Grails app.  There are some docs available at http://grails.org/plugin/clojure which describe how to use the plugin.  Those docs reference a brief video at http://s3.amazonaws.com/jeffscreencasts/grails_clojure_demo.mov which shows how the thing works.

The Grails framework is really flexible and it was very easy to add support for Clojure.  I hope that the plugin will make Clojure that much more accessible to some folks.

I welcome feedback from anyone in the Clojure community who may have an interest in this.

Thanks.



Jeff
--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

Mark Volkmann

unread,
Jul 19, 2009, 8:42:06 AM7/19/09
to clo...@googlegroups.com
On Sat, Jul 18, 2009 at 10:58 PM, Jeff Brown<jeffsco...@gmail.com> wrote:
> I have released version 0.1 of a plugin which provides support for easily
> accessing Clojure code in a Grails app.  There are some docs available
> at http://grails.org/plugin/clojure which describe how to use the plugin.
>  Those docs reference a brief video
> at http://s3.amazonaws.com/jeffscreencasts/grails_clojure_demo.mov which
> shows how the thing works.
> The Grails framework is really flexible and it was very easy to add support
> for Clojure.  I hope that the plugin will make Clojure that much more
> accessible to some folks.
> I welcome feedback from anyone in the Clojure community who may have an interest in this.
> Thanks.

Very cool Jeff! You did a great job on the video too!

Are there limitations on what can be passed from Grails to Clojure?
Can only primitive values be passed or can collections be passed? If
collections are supported, how are Groovy collections mapped to
Clojure collections?

--
R. Mark Volkmann
Object Computing, Inc.

Jeff Brown

unread,
Jul 19, 2009, 9:27:33 AM7/19/09
to clo...@googlegroups.com
Any object may be passed to a clojure function including primitives, objects, collections... anything.  Of course when you pass Java/Groovy objects into a clojure function and start manipulating it, you are giving up all guarantees that clojure can make in terms of concurrency and immutability.  That is just part of the deal with clojure.  Clojure can't keep you from mutating mutable Java objects because clojure allows you to call any method you like on a Java object.

More interesting than the ability to pass anything in to a clojure function, you can get anything back from a clojure function.  For example, the following returns a persistent list...

(defn getit []
    (list "jeff" "zack" "jake"))

If I call that function from Java or Groovy, I get back a clojure.lang.PersistentList.  I think this is really interesting.  Clojure has a great set of data structures.  Some Java developers who don't want to write Clojure code may use the clojure libraries just for the data structures.



jb

Wilson MacGyver

unread,
Jul 19, 2009, 12:23:02 PM7/19/09
to clo...@googlegroups.com
Great info. When I saw this my first reaction was to use clojure as a "blackbox" STM inside a grails app

You may want to include what you just posted in the plugin info page, since I imagine clojure will be new to most Grail developers.

Vagif Verdi

unread,
Jul 19, 2009, 12:40:02 PM7/19/09
to Clojure
Before creating clojure Rich Hickey tried several times to marry
Common Lisp and java:

http://jfli.sourceforge.net/
http://foil.sourceforge.net/
http://lisplets.sourceforge.net/

He spend lots of time and effort to come to realization that something
like clojure is nesessary.

Maybe it is time to use your experience in creating web frameworks and
start a new one, on clojure. Crails :)


Wilson MacGyver

unread,
Jul 19, 2009, 12:49:40 PM7/19/09
to clo...@googlegroups.com
There are already two webframework in clojure being developed.
Compojure and cascade. While I'm eagerly waiting to see how these two
and others will envole, there are benefit to this approach as well. It
allows Grail developers to experiment with clojure, and leverge the
language's strength.

After all, how can more clojure users be a bad thing :)

Vagif Verdi

unread,
Jul 19, 2009, 4:24:23 PM7/19/09
to Clojure
On Jul 19, 9:49 am, Wilson MacGyver <wmacgy...@gmail.com> wrote:
> There are already two webframework in clojure being developed.  
> Compojure and cascade. While I'm eagerly waiting to see how these two  
> and others will envole

Not much to wait there. Compojure is quite stable and feature rich
now. It is a low level web framework. You have to explicitly manage
urls and code html by hand, using their html combinatorics library.
There's nothing wrong with being a low level web framework. You
certainly can build up upon it. I'm currently migrating our web
application from plain java servlets to compojure.

Cascase is not even a web framework yet. It is a toy. And sadly from
what i've seen so far, it took the same path as compojure: explicitly
dealing with urls and manually building html pages with its own
library. No high level object/widget approach a-la Seaside, Weblocks,
Rails etc.
So there's a space for different kind of web frameworks in clojure
ecosystem.

Wilson MacGyver

unread,
Jul 19, 2009, 4:35:45 PM7/19/09
to clo...@googlegroups.com
I can only speak on compojure. So far I've only done some simple
expermental apps using compojure and using enlive for template,
clojurql for database. It's more work to make everything tie together
than I'm used to. Since I use grails for production work, and have
used lift for some internal apps as well. I keep looking for lazy ways
to generate wars and such.

Howard M. Lewis Ship

unread,
Jul 19, 2009, 7:19:21 PM7/19/09
to Clojure
You seem to have a better idea of what's going in in Cascade than I
do, and I'm the one writing it. Please be patient.

Vagif Verdi

unread,
Jul 19, 2009, 8:01:44 PM7/19/09
to Clojure
On Jul 19, 4:19 pm, "Howard M. Lewis Ship" <hls...@gmail.com> wrote:
> You seem to have a better idea of what's going in in Cascade than I
> do, and I'm the one writing it.  Please be patient.

I was replying to the author of the thread who said there are 2
clojure web frameworks. Cascade could very well become a great web
framework. But it is a toy right now. As for being patient, i'm not in
a hurry.

Daniel Renfer

unread,
Jul 19, 2009, 10:26:16 PM7/19/09
to clo...@googlegroups.com


There are way more than two web frameworks for clojure out there right
now. It seems like every other month there is an announcement for a
new framework. No offence to Howard or any of the others, but at this
point, Compojure has the most momentum. That's okay though. If it
weren't for new people playing around with HttpServlet and it's ilk,
we wouldn't have the Ring protocol, and that would be a bad thing.

There's a lot of potential for Clojure on the web, and there is lot's
of neat things you could do with the expresiveness of Clojure, but at
this point, it looks like Compojure is going to be the de jure choice
for web work.

As a side note, I would happily purchase the book if Pragmatic or some
others ever decided to put out a "Functional Web Development (with
Compojure/Clojure)" type book. (You can have the name.)

e

unread,
Jul 19, 2009, 11:45:15 PM7/19/09
to clo...@googlegroups.com
i enjoyed the video very much and forwarded it on to colleagues.  It's a terrific idea for people who haven't done ANY of these things before.  They haven't done scala, no groovy let alone grails . . . .no jruby . . . .maybe played with ruby .... lot's of python and certainly haven't ever had much interest in clojure (nevermind compojure or cascade).  In fact a lot of people I know loath most things JVM.

... But, whenever they think about giving this whole jvm thing another try, they think about groovy (hoping the reports of speed improvements are true).  So being able to tell them that it's ok to try clojure because they won't be missing out on grails is a GREAT thing.

As for compojure ... I'm greatful for it because it taught me about slicehost (thanks to Eric Lavigne's tutorial), but I could never figure out how to make it do much beyond what that tutorial talked about.

Maybe I should give it a try again, myself, but this grails video was at least as awesome as any of that, so thank you for it.

- Eli

Jeff Brown

unread,
Jul 19, 2009, 5:33:45 PM7/19/09
to clo...@googlegroups.com
On Sun, Jul 19, 2009 at 11:23 AM, Wilson MacGyver <wmac...@gmail.com> wrote:
Great info. When I saw this my first reaction was to use clojure as a "blackbox" STM inside a grails app

You may want to include what you just posted in the plugin info page, since I imagine clojure will be new to most Grail developers.

Done.



jb 
Reply all
Reply to author
Forward
0 new messages