Fork me on GitHub

rosetta code has a ton of interview questions, some solved in clojure and some not.


And of course there are always ClojureKoans


@zzamboni: maybe check out They have a functional programming track that you can do in Clojure


Thanks @dmbennett, @mkaschenko, @yogidevbear - very nice resources! In the meantime I also found, which has pointers to most of the above plus some other things


guys, I’m trying to join this wonderful clojure world (I’ve started dirtying my hands last saturday)… and it’s pretty awesome… I’ve started from Brave Clojure and Aphyr - Clojure From ground up… But actually I’m not liking it anymore… because I don’t feel the examples are going to fit the real world, I would like something more enterprise… whole scenarios, not only algorithms… structure full projects, manage db access with connection pool, jdbc, serve and process json, etc… do you suggest me any good content that I can find all of it?


@leo.ribeiro: so Clojure for the Brave and True doesn't go to those things? Hmm.. the only thing that comes to mind for now is getting your hands dirty and starting with a project, maybe using Luminus? It's got some pretty good documentation, and helps you set everything up so you can focus on small parts first.

kauko15:06:34 is a good book too, but not available online I think. It's got a pretty good balance of language features and real world scenarios.


Building Bulletproof Web Apps in Clojure (something like that) goes through a lot of that. I’m only in the first few chapters so I don’t know if it gets into pooling but it does do database code.


DB access with a connection pool's typically transparent, anyway, in my experience.


Yeah, @leo.ribeiro the book @jeff.engebretsen mentioned is this one: ---I've been using the beta 2nd edition as reference for basically every question for building my first complicated webapp. It's really good.


@kauko @jeff.engebretsen @meow @meowy — thank you very much guys!!! besides everything, I can feel that this community is pretty awesome!


@gowder: the beta edition covers a full web app? or it’s missing any important part?


There’s a page about connection pooling, with examples for two different libraries.


If you’re willing to invest in more books, you might find Clojure Applied helpful (as well as the already-recommended from O’Reilly).


@leo.ribeiro: it's not missing anything that I can discern! (then again, I'm not an expert, just learning how to do web stuff... maybe ask @yogthos ?)


thank you 😄


@seancorfield: thank you my friend!


(also, happy to answer any questions you have about java.jdbc that don’t seem to be answered by the docs — since I maintain java.jdbc and wrote most of those docs)


My experience has been when trying to tackle projects like leo.ribeiro is talking about, I was intimidated and hungry for a framework or example that showed how to do all of the things I wanted to do, but when I approached it one bite at a time, (JDBC, HTTP, JavaSockets) I was super amazed with how quickly I got to the meat of productive business problem solving..


@fingertoe: exactly… I’m trying to runaway from frameworks… I would like to just glue the pieces together… what I need? An "http-server" library that can provides and listen a port (I think it’s RING right?), then I would route my request based on the address, or to avoid reinvent the wheel I would use a route for that (compojure), finally I would need a json processor (serialize and deserialize) to understand my requests and also serialize my response… obviously I would need a database behind my processes…


But what I’m going to do now is follow this book that I already bought and saw that it follows the luminus, and after the end of everything I will see what I will need to keep from luminus and what I should remove… because I don’t want templates and probably a bunch of other stuff


@leo.ribeiro: Ring is basically an abstraction for different web servers, comparable to Rack in the Ruby world. It essentially defines how a handler for HTTP requests should look like - handlers are designed to be nestable to allow building middleware - and also brings along some useful handlers of its own. It also abstracts the complexities of HTTP itself into a defined interface. Rack doesn't actually handle requests or define how the server should work, all it defines is how the server and the application code should talk to each other.


A unified layer like this allows application code not to depend on the server and vice versa - you can swap them out.


so what should I use as the server?


There are a few servers that implement the Ring interface: ring-jetty-adapter, http-kit, and Immutant, among others.


It's up to you what to use, but personally, I roll with Immutant as it's based on a Java web server library called Undertow, which I have good experience with.


undertow has the best performances overall under this benchmark:


what luminus uses? do you have an idea?


It's based on Immutant, I think.


By default, anyway.


For routing, you'd probably use Compojure, though there's a few other libraries available for that task. Depends on your requirements, really. What it essentially does is just to provide you with Ring middleware, that's all - you can compose it with other Ring handlers as you like.


For JSON serialization and deserialization, the go-to solution is Cheshire, which is based on Java's Jackson. It's fast and does what it's supposed to.


Here's some links:


Note that Immutant's actually a set of projects, and you can pick and choose which ones you want to use. You don't need to use the caching stuff if you only need the web server, for instance.


thank you very much @meowy 😄


No problem!


Also, if all you want to do is to provide an API and maybe some static pages (i.e. you don't need templating), look into compojure-api.


It lets you create a typesafe (!) API with fancy Swagger documentation real easily.


Also handles request and response serialization and deserialization, so you don't need to care about it.


I will take a look into that


Actually, typesafe might have the wrong connotation... what I mean is that it uses Schema, which lets you validate your input and output. It's a lot more flexible than type systems.


What're you using for your DB integration?


I’m just following the book


by the way it’s not just the db library, it happens to the v/required, v/min-count which is from bouncer


I think it’s a bug or misconfiguration in my intellij


Oh, yeah, I had the same problem. Basically, Conman dynamically defines functions at runtime, and Cursive (the IntelliJ IDEA plugin) doesn't know about it. Not sure about Bouncer, though.


Yeah. It's why I switched to Spacemacs for Clojure development.


@leo.ribeiro: did you refresh the leiningen plugin after adding libs to project.clj? Apart from that @cfleming is very active in #C0744GXCJ and usually has a fast respond time if he is awake.


@sveri: oh probably you are right


@leo.ribeiro: CTRL+Shift+A -> refresh leiningen


do you know the exact name of that command in the intellij menu? because I think my shortcut is not working


hm, CTRL+Shift+A should work in every intellij


thats how I find most of the actions I use


Help -> Find Action


I’ve refreshed but same problem… anyway I posted into the #C0744GXCJ now I will wait for their response! 😄


Hm, strange, did you check that this function exists with zero arity in the given namespace?


maybe run lein compile and see if it compiles?


it compiles ok


I’ve restarted intellij and created a new projected… the same issue happened with ring.adapter.jetty that I was trying to use...


after I pressed ctrl shift a it worked


maybe it was a problem before...