noir vs compojure?
Asked Answered
A

4

18

I'm having trouble understanding the point of clojure's Noir library. It seems to be a framework written on top of compojure that renames defroute to defpage and calls it a day. Obviously an unfair simplification, but what exactly does Noir bring to the table? Why would I use Noir instead of plain compojure+hiccup?

EDIT/UPDATE: Noir is deprecated, interesting write up here: http://blog.raynes.me/blog/2012/12/13/moving-away-from-noir/.

Aeri answered 30/3, 2012 at 20:32 Comment(0)
S
15

Compojure is a small framework that generates Ring request/response handlers, where handlers are chosen based on routes you define.

Noir adds functionality for session handling, cookies, templates and partials, an easier way to generate responses, form validation, route filters, encrypted passwords, JSON (de-)serialising and custom status pages. In other words, Noir combines Compojure, Hiccup, and a bunch of other clever stuff in one package.

Sanmiguel answered 30/3, 2012 at 21:17 Comment(2)
is all of this "clever stuff" already available via other clojure libraries? For example a fair amount of what you describe can be done with compojure, hiccup, sandbar, clj-json, etc. Does Noir provide anything new besides a facade over existing clojure libraries?Aeri
Noir uses existing libraries and glues them together in a useful way - that in itself is "new", and it means the effort to find, test and combine various libraries has been done for you. Besides that, it offers some extra functionality (such as validations, custom statuses, etc etc). The sources show you exactly what is provided - it's functionality that you would probably build anyway if you develop a web app with compojure, hiccup, sandbar, etc. github.com/ibdknox/noirSanmiguel
S
17

From the author of Noir himself:

Noir isn't really a replacement for [compojure and hiccup], more of an abstraction over them. It was born out of seeing how a real web-app evolved and what was missing from the ring/compojure/hiccup stack as I built http://www.typewire.io. Also, as I mentioned in one of the other comments, I hope that it will serve as the single "package" to start with web development in Clojure, instead of having to try and cobble it together from the pieces that are out there now. By controlling all of it, I can create a much more cohesive and well defined story for helping people get started. I can also share what I've learned about maintaining websites in Clojure and hopefully encourage patterns that avoid some of the pits I fell into.

(emphasis mine)

Shrine answered 30/3, 2012 at 21:16 Comment(0)
B
17

Noir, the framework has been deprecated by Noir maintener himself.

It suggests to use Compojure and lib-noir :

For new websites, please use Compojure and lib-noir. This is pretty much just as batteries included as Noir itself ever was! You just have to learn how to write routes with Compojure. It’s easy and just as concise as it was in Noir. You don’t have to use ring-jetty-adapter and stuff, just use the lein-ring plugin to start your server. Also, if you took advantage of Noir including hiccup by default, you’ll have to have an explicit dependency on it now. No biggy, right? Right!

Blus answered 14/12, 2012 at 10:43 Comment(0)
S
15

Compojure is a small framework that generates Ring request/response handlers, where handlers are chosen based on routes you define.

Noir adds functionality for session handling, cookies, templates and partials, an easier way to generate responses, form validation, route filters, encrypted passwords, JSON (de-)serialising and custom status pages. In other words, Noir combines Compojure, Hiccup, and a bunch of other clever stuff in one package.

Sanmiguel answered 30/3, 2012 at 21:17 Comment(2)
is all of this "clever stuff" already available via other clojure libraries? For example a fair amount of what you describe can be done with compojure, hiccup, sandbar, clj-json, etc. Does Noir provide anything new besides a facade over existing clojure libraries?Aeri
Noir uses existing libraries and glues them together in a useful way - that in itself is "new", and it means the effort to find, test and combine various libraries has been done for you. Besides that, it offers some extra functionality (such as validations, custom statuses, etc etc). The sources show you exactly what is provided - it's functionality that you would probably build anyway if you develop a web app with compojure, hiccup, sandbar, etc. github.com/ibdknox/noirSanmiguel
A
0

You can always check the API on the webnoir.org website. There is a lot of added functionality besides defpage.

Abridge answered 30/3, 2012 at 21:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.