Fork me on GitHub
#beginners
<
2016-02-17
>
Josh Horwitz00:02:39

What is the best book recommendation following Clojure For the Brave and True, which I already have

shaun-mahood01:02:24

@joshua.d.horwitz: I think Clojure Applied ( https://pragprog.com/book/vmclojeco/clojure-applied ) is really good as a second book. I also really enjoyed Web Development with Clojure (2nd edition now in beta and seems good so far https://pragprog.com/book/dswdcloj2/web-development-with-clojure-second-edition) and Clojure Reactive Programming ( https://www.packtpub.com/web-development/clojure-reactive-programming ) if either of those subjects are interesting to you. Pretty much all the Clojure books are available on on Safari books, which has a 30 day trial, so it's pretty easy to get access for a month and see which ones really resonate with you (or get a subscription longer if the rest of the service seems worthwhile). Pragmatic seems to put out really good Clojure books, Packtpub is pretty mixed in quality from what I've seen, and O'Reilly and Manning have some good books that are a bit older. Brian Marick also has a good book on Leanpub if you are coming from the OO world (https://leanpub.com/fp-oo ).

eggsyntax01:02:11

@joshua.d.horwitz: I think Joy of Clojure is a pretty unbeatable second book (although I haven't read Clojure Applied yet, and it sounds great).

donaldball02:02:38

It’s not commonly recommended, but nothing really clicked for me like Brian Marick’s Functional Programming for the Object-Oriented Programmer

gowder03:02:45

Can I ask a stupid noob question about Java interop? One of the very first examples in Programming Clojure is this function: (defn blank? [s] (every? #(Character/isWhitespace %) s)) Looking at it, I instantly wonder: why is Character/isWhitespace wrapped in an anonymous function? A Java method is basically the same thing as a function, right? (This may clue you in to the obvious: I don't actually know Java.) And single-arity functions don't need to be wrapped in other anonymous functions to serve as an argument to every? ---like, this works fine: (defn alleven? [v] (every? even? v)) So the following should work: (defn blank? [s] (every? Character/isWhitespace s)) But, instead, when I try that in a REPL it throws a mysterious error: CompilerException java.lang.RuntimeException: Unable to find static field: isWhitespace in class java.lang.Character, compiling:(NO_SOURCE_PATH:1:18) If I had any idea what a "static field" was, I'd probably be able to understand the mystery here. But, as noted, I don't know Java. I know Python, and JavaScript (ish) and a bit of C, but, well... Is the general principle that you have to wrap Java stuff in anonymous functions? Thanks!

jonahbenton03:02:24

hey @gowder- that's a good example. It's confusing in the sense that if Character referred to a Clojure namespace in which lived a single arity function called isWhitespace, your second example would work fine. But Character refers to a Java class so the implications of the same syntax are a little different, as described: http://clojure.org/reference/java_interop. In the (every? Character/isWhitespace ...) form, Character/isWhitespace is not in function position, so Clojure treats it as a "static field"- roughly equivalent to a class variable in Python, a value slot associated with the class, rather than with an instance. But it's not a static field, so when examining the Character class, Clojure can't find it. In the (every? #(Character/isWhitespace ...)) form, Character/isWhitespace is in function position, so Clojure treats it as a "static method"- a function associated with the class, rather than an instance- and that is what it is, so Clojure is able to find it when examining the Character class.

jonahbenton04:02:33

Anyway- you do have to wrap or otherwise adapt Java incantations for use in a Clojure function context.

yogidevbear10:02:18

Hi everyone. I am literally just starting my journey into the land of Clojure. I was curious as to how html is used within Clojure for web app development. Are .html files included inside projects or is everything down with a templating engine similar to this article (https://devcenter.heroku.com/articles/clojure-web-application#html-templating-with-hiccup)?

yogidevbear10:02:45

I tried using Luminus to generate their example app and this appears to have a /resources/templates/ folder with html files in

yogidevbear10:02:04

Is the inclusion of these template html files within Luminus something that Luminus itself makes possible or is this functionality built-in to Clojure?

ordnungswidrig10:02:51

No, clojure does not include any „templating“. IIRC then luminus uses the Selmer library to do html based templating: https://github.com/yogthos/Selmer

ordnungswidrig10:02:31

But it supports some other templating libraries too, so take this as an educated guess for your particular case.

yogidevbear11:02:29

Any recommendations for books for a Clojure noob coming from a specifically web-oriented background? Clojure Web Development Essentials, Web Development with Clojure (2nd Ed.), etc.?

samlinncon12:02:46

@yogidevbear: try the official documentation of luminuweb,its a nice framework too

yogidevbear12:02:12

Thanks Sam, I was looking through that earlier this morning. Seems very cool. I suppose I'm really trying to wrap my head around the differences between what is Clojure specific and what is 3rd party developed library/framework stuff in the context of web app dev.

yogidevbear12:02:38

So far though, I'm really liking what I see overall

samlinncon12:02:44

@yogidevbear: from my point of view libraries /framework are to make your work easier in accomplishing some tasks in clojure and also make development much faster. its an intresting framework,learning to use it too

yogidevbear12:02:47

I'm all for frameworks that make work easier/faster simple_smile I suppose the main difference is that frameworks come and go whereas the core language features are likely to persist for longer, so striking a good balance between understanding the core language and using the most appropriate framework is important. And because I'm completely new to Clojure, I guess I'm just trying to figure out what the best approach or framework is to use that will give me the most mileage and keep me heading in the right direction.

yogidevbear12:02:59

Luminus does seem pretty awesome

yogidevbear12:02:17

And the docs seems pretty well put together

samlinncon12:02:52

you are so right,understanding the core language is quit important and it even makes it easier understanding how to work with a http://framework.Am also learning clojure though quit held up by work stuff,and as for luminusweb its great.

samlinncon12:02:28

and its better to learn with a project in hand for good practice.😀👍

samlinncon12:02:14

@yogidevbear: you use other languages too?

yogidevbear12:02:34

Yes, coming from a ColdFusion background at the moment. Before that I did .NET (back in the days of webforms - shudder)

samlinncon12:02:29

thats cool,coldfusion i have not used it before

yogidevbear12:02:09

I really like it. I think it gets a lot of flack from the newer "cool kids", but truthfully I quite enjoy coding with it.

samlinncon12:02:25

haha.the cool kids are quit a number and seem to be taking over in web development

yogidevbear12:02:26

So do you use any other languages? Maybe move discussion to #C03RZGPG3 ?

ghufran20:02:43

@yogidevbear: if you’re new to clojure, I would recommend taking a couple of days learning some clojure before getting into the web development. This course https://iloveponies.github.io/ is good, starting from the basics.

arijun20:02:10

If I use (java.util.Date.), I get a java.util.Date object which looks like #inst "2016-02-17T20:28:02.815-00:00". I just want the date part as a string, but take doesn't work on that object and str changes the formatting completely. How do I just get the date?

arijun20:02:46

I see mentions of packages like clj-time online but that seems like overkill to just get the date.

codonnell20:02:08

@arijun: if you don't want to use clj-time, I think you could cobble together a solution using java.util.Calendar.

codonnell20:02:05

clj-time is really simple, though. I'd probably use that if it were me.

akiva20:02:50

Another option is, and especially if the library is well-designed, to simply take the functions you need and incorporate them directly. Most libraries have generous licenses; just make sure you credit the original authors in the comments and so forth as required.

yogidevbear20:02:29

Cool, thanks @ghufran. I'll check the link out

arijun22:02:14

@akiva: not sure that would work in this case since it looks like clj-time is built on top of a java library (joda).

arijun22:02:59

@codonnell: perhaps you're right, might as well just grab clj-time.

akiva23:02:30

Ah, yeah, @arijun, that’s true. But it might be worth a look.