Fork me on GitHub
#beginners
<
2016-06-20
>
dmbennett01:06:16

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

dmbennett01:06:55

And of course there are always ClojureKoans http://clojurekoans.com/

yogidevbear07:06:38

@zzamboni: maybe check out http://hackerrank.com. They have a functional programming track that you can do in Clojure

zzamboni07:06:29

Thanks @dmbennett, @mkaschenko, @yogidevbear - very nice resources! In the meantime I also found https://notamonadtutorial.com/how-to-earn-your-clojure-white-belt-7e7db68a71e5#.59pfu7f8r, which has pointers to most of the above plus some other things

leo.ribeiro14:06:37

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?

kauko15:06:09

@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

http://www.clojurebook.com/ 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.

jeff.engebretsen15:06:42

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.

meowy15:06:27

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

gowder15:06:37

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

leo.ribeiro16:06:20

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

leo.ribeiro16:06:20

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

seancorfield16:06:40

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

seancorfield16:06:53

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

gowder17:06:57

@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 ?)

leo.ribeiro17:06:23

thank you 😄

leo.ribeiro17:06:34

@seancorfield: thank you my friend!

seancorfield17:06:41

(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)

fingertoe17:06:30

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..

leo.ribeiro17:06:24

@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…

leo.ribeiro17:06:32

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

meowy18:06:36

@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.

meowy18:06:14

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

leo.ribeiro18:06:56

so what should I use as the server?

meowy18:06:24

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

meowy18:06:37

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.

leo.ribeiro18:06:36

undertow has the best performances overall under this benchmark: http://techempower.com/benchmarks/

leo.ribeiro18:06:52

what luminus uses? do you have an idea?

meowy18:06:22

It's based on Immutant, I think.

meowy18:06:54

By default, anyway.

meowy18:06:47

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.

meowy18:06:54

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.

meowy18:06:34

Here's some links:

meowy18:06:36

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.

leo.ribeiro18:06:15

thank you very much @meowy 😄

meowy18:06:19

No problem!

meowy18:06:06

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.

meowy18:06:54

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

meowy18:06:02

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

leo.ribeiro18:06:14

I will take a look into that

meowy18:06:06

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.

meowy18:06:59

What're you using for your DB integration?

leo.ribeiro18:06:37

I’m just following the book

leo.ribeiro18:06:53

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

leo.ribeiro18:06:31

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

meowy18:06:32

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.

meowy18:06:07

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

sveri18:06:25

@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.

leo.ribeiro18:06:43

@sveri: oh probably you are right

sveri18:06:39

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

leo.ribeiro18:06:31

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

sveri18:06:08

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

sveri18:06:22

thats how I find most of the actions I use

sveri18:06:06

Help -> Find Action

leo.ribeiro18:06:01

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

sveri18:06:24

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

sveri18:06:35

maybe run lein compile and see if it compiles?

leo.ribeiro19:06:26

it compiles ok

leo.ribeiro19:06:19

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

leo.ribeiro19:06:26

after I pressed ctrl shift a it worked

leo.ribeiro19:06:50

maybe it was a problem before...