r/Clojure • • Apr 17 '16

The State of Clojure Web Development

http://yogthos.net/posts/2016-04-17-state-of-web-clj-dev.html
74 Upvotes

51 comments sorted by

View all comments

2

u/un_passant Apr 18 '16

What I don't really get in the state of Clojure Web Development is why pedestal did not really take off. Is it just because Ring was too entrenched and good enough of am I wrong in considering that pedestal server was better ? Pedestal client side was also the only client API that made sense to me until re-frame. I like Luminus (especially with Immutant !) and am a grateful and happy buyer of the "Web Development with Clojure" book, but I put some money on Kickstarter for Arachne to help move forward pedestal-server.

7

u/halgari Apr 18 '16 edited Apr 18 '16

There's several reasons for that I think. I will be the first to admit that Pedestal was a bit too complex when it was first released. That has changed a lot in the recent versions and I recommend that people take a look at the current state of things, as most internal things have been reduced to a few simple protocols.

Also, the feature set of Pedestal was designed for a rather specific set of goals, and those are goals that many people haven't thought much about, or simply don't need.

One such goal is "async all the way down" Pedestal (and perhaps Aleph?) is one of the few Clojure frameworks that allows you to do things like make async non-blocking calls inside a hander. So now your authentication module can make a call to a db and release the webserver thread. That's something that just can't be done in the Ring model.

Secondly, Pedestal's routing system is data driven. So it's completely possible to have routing tables that change at runtime, are post-processed by other code, etc. In that sense, the "routing code" is more like a JIT that generates a lookup table than a hard coded set of "comp-ed" functions.

These are just a few of the features that Pedestal supports that I think people are either unaware of, or don't think they need.

2

u/un_passant Apr 18 '16

Being data driven and async are indeed the benefits that I see in Pedestal. It took some efforts to wrap my head around it when it came (same for the client side, btw), but then it just made sense and seemed superior to Ring.

If arachne could be a kind of Luminus for Pedestal and give it momentum, I would consider my kickstarter funding well spent.

2

u/yogthos Apr 18 '16

That's something that just can't be done in the Ring model.

That's not actually correct. Pretty much all Clojure HTTP servers provide async extensions for Ring nowadays. Aleph, Immutant, and HTTP Kit all support async non-blocking calls inside a handler. See HTTP Kit and Immutant async docs as examples.

Secondly, Pedestal's routing system is data driven.

Bidi provides a similar approach on top of Ring, but the nice part is that you have a choice in whether you want to use it or not.

2

u/halgari Apr 19 '16

Inside the handler perhaps, but not inside the middleware. You can't pause the request parsers half way through, then continue later on, likewise you can't pause during the response logic. Sure you can return a promise, but that promise then side-steps the ring response logic, so what's the point?

And at that point, the "Ring Model" is no longer in place, you don't have "just a function" you have "just a function" that returns a promise that will return the rest of your logic.

1

u/yogthos Apr 19 '16

While that's true, it's not really an issue in practice in vast majority of situations from what I've seen. Middleware should not be the place where you have the overhead that necessitates the async functionality in my opinion.