Interested in building the Clojure module for Vert.x 3?

314 views
Skip to first unread message

Toby Crawley

unread,
Apr 16, 2015, 1:15:09 PM4/16/15
to vertx
Vert.x v2 currently has Clojure support via a language module[0], but
that module won't work with the upcoming Vert.x v3[1], since it is
substantially different. I wrote the Clojure module for v2, but don't
have time to build/maintain the module for v3. If you are a Clojure +
Vert.x user and want to take on building the v3 language module, let
us know. I would be happy to provide guidance as to how the v2 module
works, but know little about v3.

- Toby


[0]: https://github.com/vert-x/mod-lang-clojure/
[1]: https://vert-x3.github.io/

stream liu

unread,
Apr 16, 2015, 9:40:13 PM4/16/15
to ve...@googlegroups.com
Hi Toby
We are planning migrate project from v2 to v3, and some mods was write by mod-lang-clojure, i have a look the v3 and is true that fully different.
Does we need rewrite mod-lang-clojure with vertx-codegen that is the recommend way to implement other lang in vert.x3


--
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/d/optout.

Toby Crawley

unread,
Apr 17, 2015, 8:58:24 AM4/17/15
to vertx
Hi Stream!

Yes, it is my understanding that language modules for v3 should be
written using vertx-codegen. I haven't looked at the code generation
process, so I'm not sure what's involved with that our how difficult
it will be to generate Clojure with it.

- Toby

stream liu

unread,
Apr 17, 2015, 9:52:43 PM4/17/15
to ve...@googlegroups.com
I found the that lang-clojure would be release with vert.x 3.1 after look the roadmap.
I am glad to follow your step if your kick off lang-clojure someday :)

Jordan Halterman

unread,
Apr 18, 2015, 12:59:08 AM4/18/15
to ve...@googlegroups.com
Yep. You should write it using the code generation API. It's not too difficult to pick up; just check out some of the existing languages. Code generation will ultimately ensure a consistent API and decrease the maintenance required for each language.

Joseph Moore

unread,
Jul 5, 2015, 1:30:50 AM7/5/15
to ve...@googlegroups.com
Any update on this so far? Sounds like a fun project to attempt.. thank you for your v2 work.
Message has been deleted

Feuer Au

unread,
Jan 5, 2018, 10:07:37 AM1/5/18
to vert.x
Hi Toby:

As we discussed in Clojure google group
we now start working on implementing Cojure support in Vert.x
so far we got some progresses but there is a problem there
there are some states in Verticle e.g.(vertx and context object)
but we cant make this since if we def vertx as global var then it is actually a static variable in Java and may cause conflicts
and also for purely functional programming, we prefer to use pure function so I would suggest to use some functions like start[], start[^Vertx vertx],  start[^Vertx vertx ^Context ctx] etc. to simulate the start and stop functions in Verticle/Java just change the input to make functions pure
and we could use Clojure Java api to invoke these methods defined in Clojure namespace so far it works nice
here is the sample code:

(ns com.whitewoodcity.test)

(import
io.vertx.core.Vertx)
(import
io.vertx.core.Context)
(import
io.vertx.core.eventbus.Message)

(defn arities [v]
(-> v meta :arglists))

(def handler0
(reify
io.vertx.core.Handler
(handle [this message]
do
(println (.body message))
(.reply message "got it"))))

(defn handler1 [f]
(reify
io.vertx.core.Handler
(handle [this message]
(f message))))

(defn start [^Vertx vertx ^Context context]
(.consumer (.eventBus vertx) "com.whitewoodcity.test" handler0))

;(def consumer (reify java.util.function.Consumer
; (accept [this t]
; ; here the impl
; )))

(defn get-start-inf [] (count (first (arities #'start))))


public class ClojureTest {

@Test
public void name() {
IFn require = Clojure.var("clojure.core", "require");
require.invoke(Clojure.read("com.whitewoodcity.test"));
IFn startIFn = Clojure.var("com.whitewoodcity.test","get-start-inf");
System.out.println(startIFn.invoke());

IFn inc = Clojure.var("com.whitewoodcity.test", "start");
Vertx vertx = Vertx.vertx();
inc.invoke(vertx, vertx.getOrCreateContext());

vertx.eventBus().send("com.whitewoodcity.test","this is a message",ar->{
System.out.println(ar.result().body());
});
}

}

so actually we could wrap clj namespaces in the Verticle Java code
Is OK we implement the Clojure support in this way? 
and use codegen to generate apis like event-bus rather than eventBus, http-client rather than httpClient etc.
Reply all
Reply to author
Forward
0 new messages