Ring and Compojure with Node.js via Clojurescript

729 views
Skip to first unread message

Matthew Molloy

unread,
Dec 8, 2014, 9:50:48 AM12/8/14
to clo...@googlegroups.com, m...@shoffle.com
Dear Community,

I love making Clojure web apps, however their startup time is a serious drawback when used with a transient hosting service such as Heroku.  My thought is to port Ring and Compojure over to Clojurescript so that can get their nice abstractions hosted on the Node.js runtime.

Any thoughts or suggestions?

Matthew

Henrik Eneroth

unread,
Dec 8, 2014, 5:55:31 PM12/8/14
to clo...@googlegroups.com, m...@shoffle.com
Awesome! I look forward to seeing the results.

Thomas Heller

unread,
Dec 9, 2014, 6:07:33 AM12/9/14
to clo...@googlegroups.com, m...@shoffle.com
Due to significant platform differences from the JVM to Node.js (no real threads, everything needs callbacks) you'd probably be better off writing something more javascript-y. Porting Ring is probably not likely since everything is async and Ring is not. Same goes for Compojure but that is mostly macro stuff so it could probably fit in somehow.

Running something on Node.js requires a completely different (async) way of thinking, which you don't nescessarily do on the JVM. You'd probably be better of using something from the node.js ecosystem. Iits not like you could ever take any Clojure Ring Handler and plug it into ClojureScript/Node, at least not likely as soon as you do something with IO.

Just my 2 cents,
/thomas

On Monday, December 8, 2014 3:50:48 PM UTC+1, Matthew Molloy wrote:

Angel Java Lopez

unread,
Dec 9, 2014, 6:26:12 AM12/9/14
to clo...@googlegroups.com
Maybe when you reach the async nature of node.js, you could use node fibers

to wrap up async calls as sync ones, as a "baby step" to implement your ideas. 

Meteor
 use a lot of fibers internally.

Angel "Java" Lopez
@ajlopez


--
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
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Angel Java Lopez

unread,
Dec 9, 2014, 6:32:14 AM12/9/14
to clo...@googlegroups.com
Another path: write ClojureScript that consumes directly Nodejs and some popular web framework (like Express). Then, you can write the controllers/actions/logic in ClojureScript. I'm not sure about the feasibility of this idea from clojurescript.

Angel "Java" Lopez
@ajlopez

James Reeves

unread,
Dec 9, 2014, 6:48:15 AM12/9/14
to clo...@googlegroups.com, m...@shoffle.com
On 9 December 2014 at 11:07, Thomas Heller <th.h...@gmail.com> wrote:
Due to significant platform differences from the JVM to Node.js (no real threads, everything needs callbacks) you'd probably be better off writing something more javascript-y. Porting Ring is probably not likely since everything is async and Ring is not.

Ring does have support for async behaviour. All the core middleware functions are split into request and response parts, allowing them to be applied asynchronously. It's how Pedestal uses Ring.

You'd still need to change the handler abstraction, since that's synchronous by design, but there's a lot from Ring that could potentially be reused.

- James

Matthew Molloy

unread,
Dec 14, 2014, 12:56:55 AM12/14/14
to clo...@googlegroups.com, m...@shoffle.com
Thanks for the feedback.  I'll let you know how things progress.

Matthew

Matthew Molloy

unread,
Dec 16, 2014, 6:12:22 PM12/16/14
to clo...@googlegroups.com, m...@shoffle.com
Update:

Somebody else has beat me to it. 

https://github.com/bodil/dogfort

Matt
Reply all
Reply to author
Forward
0 new messages