current state of Clojure support

762 views
Skip to first unread message

Norman Richards

unread,
Oct 3, 2012, 8:13:31 PM10/3/12
to ve...@googlegroups.com
Is anyone actively working on Clojure integration?  I've checked through the mailing list and there doesn't seem to be any recent activity, but perhaps there is activity that isn't being discussed much on the list.  If anyone is actively working on it, please let me know as I'd like to contribute.  

matt....@gmail.com

unread,
Oct 3, 2012, 9:59:45 PM10/3/12
to ve...@googlegroups.com
I'm not, but this has also been on my mind. Would be interested in collaborating. 

Sent from my iPhone

On Oct 3, 2012, at 7:13 PM, Norman Richards <o...@nostacktrace.com> wrote:

Is anyone actively working on Clojure integration?  I've checked through the mailing list and there doesn't seem to be any recent activity, but perhaps there is activity that isn't being discussed much on the list.  If anyone is actively working on it, please let me know as I'd like to contribute.  

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/OCH17uJnCP0J.
To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.

Tim Fox

unread,
Oct 4, 2012, 4:07:35 AM10/4/12
to ve...@googlegroups.com
Clojure support is something we've wanted for a long time. We've had a
few people express interest in driving this, but nothing has ever
materialised.

If someone wants to take up the reins and give it another go, that would
be excellent.
> know as I'd like to contribute. --
> You received this message because you are subscribed to the Google
> Groups "vert.x" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/vertx/-/OCH17uJnCP0J.
> To post to this group, send an email to ve...@googlegroups.com.
> To unsubscribe from this group, send email to
> vertx+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/vertx?hl=en-GB.


--
Tim Fox

Vert.x - effortless polyglot asynchronous application development
http://vertx.io
twitter:@timfox

Norman Richards

unread,
Oct 4, 2012, 10:52:56 AM10/4/12
to ve...@googlegroups.com
On Wed, Oct 3, 2012 at 8:59 PM, <matt....@gmail.com> wrote:
> I'm not, but this has also been on my mind. Would be interested in
> collaborating.

Excellent. As best as I can tell, none of the prior work has produced
anything public to work from. I'm really comfortable on the clojure
side, but being new to vert.x, I've still got some learning to do.
But, given that I'm now using it on my main project, it shouldn't take
long.

You wouldn't happen to be going to Clojure/conj next month, would you?
That would be a really great opportunity to group of with interested
people.

Matt Stine

unread,
Oct 4, 2012, 10:59:06 AM10/4/12
to ve...@googlegroups.com
On Thu, Oct 4, 2012 at 10:52 AM, Norman Richards <o...@nostacktrace.com> wrote:
> On Wed, Oct 3, 2012 at 8:59 PM, <matt....@gmail.com> wrote:
>> I'm not, but this has also been on my mind. Would be interested in
>> collaborating.
>
> Excellent. As best as I can tell, none of the prior work has produced
> anything public to work from. I'm really comfortable on the clojure
> side, but being new to vert.x, I've still got some learning to do.
> But, given that I'm now using it on my main project, it shouldn't take
> long.

Great. I'm somewhere in the "advanced beginner" stage of Clojure, with
a decent background in functional programming. I'm speaking on Vert.x
this week...I have a very good grasp of it from a user perspective,
but have yet to dig into the internals. This seemed like a fun way to
do that while also giving me something that I want.

>
> You wouldn't happen to be going to Clojure/conj next month, would you?
> That would be a really great opportunity to group of with interested
> people.

Unfortunately no. I was lucky to be able to get away from client work
to go to Strange Loop, and two conferences this close together wasn't
going to happen. Fortunately there was a ton of Clojure love at SL,
amongst other functional/Lispy things. That said, a Skype call or
Google Hangout is possible.

There's a thread bouncing around about doing language implementations
as separate modules, with an eventual possibility of refactoring core
to handle all language impls that way. I'm interested in pursing this
approach...feels right to me.

>
> --
> You received this message because you are subscribed to the Google Groups "vert.x" group.
> To post to this group, send an email to ve...@googlegroups.com.
> To unsubscribe from this group, send email to vertx+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.
>



--
Matt Stine
Deep South Software: Training, Consulting, Coaching
http://www.deepsouthsoftware.com
matt....@gmail.com

Norman Richards

unread,
Oct 5, 2012, 1:20:59 PM10/5/12
to ve...@googlegroups.com
On Thu, Oct 4, 2012 at 9:59 AM, Matt Stine <matt....@gmail.com> wrote:
>
> There's a thread bouncing around about doing language implementations
> as separate modules, with an eventual possibility of refactoring core
> to handle all language impls that way. I'm interested in pursing this
> approach...feels right to me.

This might be a productive approach. I've started from the current master:

https://github.com/orb/vert.x/tree/clojure

It doesn't do anything clojure yet except recognize .clj files. I
suspect I should be able to get some kind of minimal clojure code
running over the weekend.

If you want to pursue this from the direction of how to make this work
under the new system, that would be great.

Matt Stine

unread,
Oct 5, 2012, 1:30:00 PM10/5/12
to ve...@googlegroups.com
Sounds like a plan. I'm in the throes of last-minute slide/demo prep
right now for my SF JUG talk on Tuesday. Once I get through that, I
should get a few slack hours to hack on this.

Norman Richards

unread,
Oct 24, 2012, 10:19:57 AM10/24/12
to ve...@googlegroups.com
On Fri, Oct 5, 2012 at 12:20 PM, Norman Richards <o...@nostacktrace.com> wrote:
> This might be a productive approach. I've started from the current master:
>
> https://github.com/orb/vert.x/tree/clojure
>
> It doesn't do anything clojure yet except recognize .clj files. I
> suspect I should be able to get some kind of minimal clojure code
> running over the weekend.

Wanted to follow up on this for those who are interested. I have
working clojure integration on my branch and I've ported most of the
examples. My approach so far has been to focus on the clojure java
interop and slowly introduce abstractions/syntax as they are needed.
This doesn't make for the most beautiful of clojure yet, but it's
allowed me to productively use clojure with vertx on a prototype app
I'm doing for a client.

Here's a few examples. I've introduced macros for event result
handlers and some more specific macros for doing redis using
modmod-redis. Threading and doto aren't too bad. It's quite usable
now, so with a little more work it ought to be pretty nice.


(defhandle not-found [_ request]
(doto (. request response)
(content-type "text/html; charset=UTF-8")
(status-code 404)
(.end "<html><body><h1>Not Found</h1></body></html>")))


(def routes
(doto (new org.vertx.java.core.http.RouteMatcher)
(.get "/" list-sessions)
(.get "/stats" list-sessions)
(.get "/stats/:user" list-user-sessions)
(.get "/stats/:user/:villain" show-stats)
(.noMatch not-found)))


(defhandle main [this deployment-id]
(doto (.createHttpServer vertx)
(.requestHandler routes)
(.listen 8080)))

(-> container
(deployModule "de.marx-labs.redis-client-v0.3" redis-conf 1 main))


(-> container
(deployModule "de.marx-labs.redis-client-v0.3" redis-conf 1
(handle [this deployment-id]
(.setPeriodic vertx 5000 poll-incoming)
(.setPeriodic vertx 5000 poll-queues))))


(defn send-to-queue [hand-id player1 player2]
(let [session-key (str "session:" player1 ":" player2)]
(if-exists session-key
(let [queue-key (str "queue:" player1 ":" player2)]
(redis-lpush queue-key hand-id
(with-redis-response r
(println "LPUSH" queue-key r)))))))

Tim Fox

unread,
Oct 25, 2012, 5:06:23 AM10/25/12
to ve...@googlegroups.com
awesome!

2tothe8th

unread,
Nov 13, 2012, 8:29:31 AM11/13/12
to ve...@googlegroups.com
What is the progress on this?  I'm currently waiting on Clojure support to determine if the company I work for can use vert.x.  Thanks.

NovaNick

unread,
Jun 11, 2013, 1:21:24 AM6/11/13
to ve...@googlegroups.com
Bumping for clojure.
Looks like Matt and Norman were able to make some progress here, and the git doesn't show any activity since. Is there any new activity on clojure integration activity happening off-list? Seems like there's a foundation to build on here.

Bruno Bonacci

unread,
Jun 11, 2013, 10:39:08 AM6/11/13
to ve...@googlegroups.com
Hi,

I'm interested in the Clojure bindings as well. Is there anything happening on this side?

Bruno

Tim Fox

unread,
Jun 11, 2013, 11:08:30 AM6/11/13
to ve...@googlegroups.com
I've wanted Clojure support for a long time (it's a similar story with
Scala), but no-one in the vert.x core team has the Clojure skills (or
the time right now) to do this.

So it's really up to some-one in the Vert.x community to take up the
task and drive it through to completion.

Matt and Norman did a great job in starting this effort, but it's always
the last part that's the hardest.

So, if anyone out there would like to kick some life back into it,
please go ahead!

stream

unread,
Jun 11, 2013, 9:09:03 PM6/11/13
to ve...@googlegroups.com

Ha

i'm interesting too, but there are some trifles to do, such as how to develop it in lein.
how to ues repl to interactive with vertx on the fly.and i hope there are pretty implemention
of vertx-ring-adapter for web develop. 

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bruno Bonacci

unread,
Jun 12, 2013, 4:50:26 AM6/12/13
to ve...@googlegroups.com

Since Clojure has got a very strong idiomatic code and way of working (REPL),
a simple "wrapper" wouldn't be enough. The few line of Clojure-Vertx sample I've seen they don't look like Clojure idiomatic code,
but more like calling Java API from Clojure. 

I think we should do like the Scala guys and join forces in the Clojure space.

Bruno 

Nathan Frund

unread,
Jun 12, 2013, 7:44:32 PM6/12/13
to ve...@googlegroups.com
On Wednesday, June 12, 2013 4:50:26 AM UTC-4, Bruno Bonacci wrote:

Since Clojure has got a very strong idiomatic code and way of working (REPL),
a simple "wrapper" wouldn't be enough. The few line of Clojure-Vertx sample I've seen they don't look like Clojure idiomatic code,
but more like calling Java API from Clojure. 

I think we should do like the Scala guys and join forces in the Clojure space.


The REPL is huge when doing Clojure dev.

When googling around I found lein-vertx:
https://github.com/isaiah/lein-vertx


And the accompanying project - Vertex-clj:
https://github.com/isaiah/vertx-clj

I gave the projects a quick spin but didn't get very far.

I'm still evaluating Vertx for a project but the decision would be made easier if I could jump in with Clojure.

stream

unread,
Jun 27, 2013, 5:37:21 AM6/27/13
to ve...@googlegroups.com

Hi.

I hava spent part time to clojure, and make some test, 
i refer two project  vertx-clj and vertx-mod-lang-clojure, both could be found in github.
it could work on the REPL with clojure code.
but they are still two things need to be done.

1. a lein plugin for dev clojure with vertx. (which like lein-ring)

2. implement ring adapter with vertx HttpServer (we could use a lot of lib with ring middleware)

i will do my best to make it work fine, hope this would be done in July...





Toby Crawley

unread,
Jun 27, 2013, 9:38:46 AM6/27/13
to ve...@googlegroups.com

I've been thinking about clojure support as well, and there are a few
issues that it would need to address (many of which have already been
mentioned by others):

* Since clojure has a static runtime, support for multiple independent
runtimes in the same JVM can be challenging. To support this, the lang
module would need to implement VerticleFactory in Java, and add the
clojure jar to the classloader for each individual verticle created in
createVerticle(). The verticle would likely need to be wrapped in a
shim class that exposes enough of the clojure API to act as an entry
point without exposing any clojure classes outside of the verticle's
classloader. I'm basing this on experience writing the runtime
isolation code for Immutant.

* Good leiningen integration is important - a lein-vertx plugin not only
needs to run the project in vertx, but would also need:

* a task to package the project as a module zip

* a mechanism to transfer a list of the project dependencies to vertx

* a configurable main ns, with maybe a sensible default?

* a mechanism for setting arbitrary configuration that passes through
to the verticle

* The lang module would need a built-in repl, probably by depending on
nrepl, and providing a config option to start it when a verticle is
created.

* Ring-like http support would be needed, but this could probably be
provided by another module that sits on top of the lang
module. http-kit may serve as a good model for this; I haven't looked.

* In addition to good verticle/module support, the lang module would
need to work well when embedded. I don't see that as being too
difficult.

I plan on starting on the runtime isolation issue this week, and am
willing to devote significant time to a solid clojure lang module. Once
I get the isolation piece worked out, I'll share what I have and we can
work together on coalescing the bits and pieces that are floating around
into something that can become an official lang module.

- Toby


stream writes:

> Hi.
>
> I hava spent part time to clojure, and make some test,
> i refer two project vertx-clj and vertx-mod-lang-clojure, both could be found in github.
> it could work on the REPL with clojure code.
> but they are still two things need to be done.
>
> 1. a lein plugin for dev clojure with vertx. (which like lein-ring)
>
> 2. implement ring adapter with vertx HttpServer (we could use a lot of lib with ring middleware)
>
> i will do my best to make it work fine, hope this would be done in July...
>
>
>
>
>
> On 2013年6月13日, at 上午7:44, Nathan Frund <nathan...@gmail.com> wrote:
>
>> On Wednesday, June 12, 2013 4:50:26 AM UTC-4, Bruno Bonacci wrote:
>>
>> Since Clojure has got a very strong idiomatic code and way of working (REPL),
>> a simple "wrapper" wouldn't be enough. The few line of Clojure-Vertx sample I've seen they don't look like Clojure idiomatic code,
>> but more like calling Java API from Clojure.
>>
>> I think we should do like the Scala guys and join forces in the Clojure space.
>>
>>
>> The REPL is huge when doing Clojure dev.
>>
>> When googling around I found lein-vertx:
>> https://github.com/isaiah/lein-vertx
>>
>>
>> And the accompanying project - Vertex-clj:
>> https://github.com/isaiah/vertx-clj
>>
>> I gave the projects a quick spin but didn't get very far.
>>
>> I'm still evaluating Vertx for a project but the decision would be made easier if I could jump in with Clojure.


--
Toby Crawley
http://immutant.org | http://torquebox.org

Toby Crawley

unread,
Jun 27, 2013, 9:44:32 AM6/27/13
to ve...@googlegroups.com
I meant to mention as well: I think the clojure lang module should only
target vert.x 2.x and the coming clojure 1.6 - clojure currently leaks
memory when used in a container, but 1.6 should fix that once
the patch for http://dev.clojure.org/jira/browse/CLJ-1125 is applied.

- Toby

stream

unread,
Jun 27, 2013, 9:49:24 PM6/27/13
to ve...@googlegroups.com




 the lang
 module would need to implement VerticleFactory in Java, and add the
 clojure jar to the classloader for each individual verticle created in
 createVerticle(). 

i have look mod-rhino, i think this is not hard to implement.
i test below code in a implement of VerticleFactory.

    private class ClojureVerticle extends Verticle {
        private final String scriptName;
        private Var stopFunc;

        ClojureVerticle(String scriptName) {
            this.scriptName = scriptName;
        }

        public void start() {
            try {
                RT.load("clojure/core");

//cl is classloader from verticleFactory, use it ,we could make a  isolation.

                clojure.lang.Var.pushThreadBindings(RT.map(clojure.lang.Compiler.LOADER, cl));
                RT.var("vertx.core", "vertx", ClojureVerticleFactory.vertx);
                RT.var("vertx.core", "container", ClojureVerticleFactory.container);
                RT.loadResourceScript(scriptName);
            } catch(Exception e) {
                log.info(e.getMessage(), e);
            }
        }




The verticle would likely need to be wrapped in a
 shim class that exposes enough of the clojure API to act as an entry
 point without exposing any clojure classes outside of the verticle's
 classloader.

How many API is enough, i think the api been exposed without java code is
enough. so some clojure's function and marcro is good.


Well, i'm very glad have chance to work with you for this mod.
my clojure is not good, i hope could get your tutor in this project.

thinks again.


Toby Crawley

unread,
Jun 28, 2013, 11:03:45 AM6/28/13
to ve...@googlegroups.com

I was working under the assumption that every verticle of a particular
language type shared one VerticleFactory, but after I chat with Tim,
that assumption has been corrected :)

Since there is a VerticleFactory per deployed module instead, using the
clojure classes directly should work fine (clojure < 1.6 will still leak
memory on undeploy, but that's another issue).

I'll fork your repo[1] as a starting point, add some tests for
isolation, and start looking at the API.

- Toby

[1]: https://github.com/stream1984/mod-lang-clojure
>> To unsubscribe from this group and stop receiving emails from it, send an email tovertx+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.


stream

unread,
Jun 28, 2013, 12:09:27 PM6/28/13
to ve...@googlegroups.com

Hi Toby
i update my repo and add some examples. hope this could give you some idea.

run it is very easy..

setting langs.properties in vertx_home/conf with

clojure=me.streamis~lang-clojure~2.0.0-CR2-SNAPSHOT:org.vertx.java.platform.impl.ClojureVerticleFactory

.clj=clojure



vertx run example/echo/echo-server.clj

in another shell

vertx run example/echo/echo-client.clj



may be you can make another repo for official if you think it's ok..


To unsubscribe from this group and stop receiving emails from it, send an email tovertx+un...@googlegroups.com.

isaiah

unread,
Jul 29, 2013, 7:10:08 AM7/29/13
to ve...@googlegroups.com
Hi,

I'm the author of the previous non-mod clojure wrapper project for vertx, https://github.com/isaiah/vertx-clj, the work done so far are: a thin wrapper (DSL) around the api,  with all the examples in the official repo implemented, as well as a leinigen plugin that runs verticles without compiling.

Ideas Toby proposed look like a good start, I would like to join force to make this happen.

Cheers,
Isaiah

Stream

unread,
Jul 29, 2013, 8:24:11 AM7/29/13
to ve...@googlegroups.com

Welcome !!!
I am hope that there are a lein plugin to support mod-lang-clojure.

Toby Crawley

unread,
Jul 29, 2013, 9:31:24 AM7/29/13
to ve...@googlegroups.com
Isaiah:

I was planning on sending a status update to the list today or tomorrow,
but your email has prompted me to do it now :)

Stream and I have made quite a bit of progress at
https://github.com/vert-x/mod-lang-clojure, and would love help/feedback
from anyone that wants to give it.

Our implementation is a bit different from yours - we've avoided macros
for most things, and support fns or Handlers as handler arguments (with
the receiving function converting a fn to the appropriate Handler, often
with a wrapper to decompose the Event).

We've aimed to make the API idiomatic Clojure, but generally only wrap
java methods where doing so adds value. For example, anything that takes
a handler gets wrapped to allow passing fns as handlers. Anything that
takes a Buffer gets wrapped to allow you to pass anything that can be
written to a Buffer, and we create the Buffer for you. Getters that
return data than can be used natively in Clojure generally aren't
wrapped, along with other methods that are fairly simple. This does pose
a documentation challenge though, since users need to read javadocs in
addition to the Clojure docs. I'd like to mitigate that by possibly
documenting the unwrapped java methods in the namespace docstring, and
I'm open to other suggestions.

We have most everything implemented, and most of the examples
written. I'm working on making sure all the examples work with our
latest API changes, and need to document how to run them all.

We also have basic nREPL support - any verticle can start one or more
nREPL servers. It would be great to integrate that with the lein
plugin.

Current todos:

- add/edit docstrings in quite a few namespaces
- add sockjs section to the manual
- review and cleanup the API for consistency

Once we get all that done, I'd like to announce it on the Clojure list,
and work on getting it added to Vert.x proper for the next release
(which involves getting it added to langs.properties, the manual moved
to the website repo, and the examples moved to the examples repo).

You can see the current manual at:
https://github.com/vert-x/mod-lang-clojure/blob/master/docs/core_manual_clojure.md
and the API docs at:
https://projectodd.ci.cloudbees.com/job/vertx.mod-lang-clojure/lastSuccessfulBuild/artifact/target/html-docs/index.html

- Toby

Stream writes:

> Welcome !!!
> I am hope that there are a lein plugin to support mod-lang-clojure.
>
>
> On 2013年7月29日, at 19:10, isaiah <iss...@gmail.com> wrote:
>
>> Hi,
>>
>> I'm the author of the previous non-mod clojure wrapper project for
>> vertx, https://github.com/isaiah/vertx-clj, the work done so far are:
>> a thin wrapper (DSL) around the api, with all the examples in the
>> official repo implemented, as well as a leinigen plugin that runs
>> verticles without compiling.
>>
>> Ideas Toby proposed look like a good start, I would like to join
>> force to make this happen.
>>
>> Cheers,
>> Isaiah
>>


Reply all
Reply to author
Forward
0 new messages