r/Clojure • • Feb 21 '18

[ANN] Programming Clojure, 3rd edition

https://pragprog.com/book/shcloj3/programming-clojure-third-edition
76 Upvotes

17 comments sorted by

8

u/WalterGR Feb 21 '18 edited Mar 25 '18

Great news! The 2nd edition is my go-to book for learning Clojure. I hope this will be on Safari soon.

EDIT: [2018-03-25] It's now on Safari. https://www.safaribooksonline.com/library/view/programming-clojure-3rd/9781680505719/

4

u/alexdmiller Feb 21 '18

I assume it will be eventually but I'm pretty far removed from knowing how long that will take.

3

u/xtreak Feb 21 '18

Thanks a lot for the updated release. Going from 1.3 to 1.9 is a pretty big leap. Apart from using specs for testing is using specs for validation in :pre and :post along with using it in if clauses a good practice? I saw a talk from Rich about not using it in production which is mostly with respect to instrumentation I think.

Also if I am library writer how can I allow the user to turn on instrumentation for my library functions during their development so that they get better error messages during testing. Does doing instrument-all turns on instrumentation for the required namespaces as well?

10

u/alexdmiller Feb 21 '18

Apart from using specs for testing is using specs for validation in :pre and :post along with using it in if clauses a good practice?

It is perfectly fine to use spec to validate data in production, if that meets your performance criteria. I would recommend that you isolate this kind of testing to only data coming from external sources, not between internal calls though and make those validation checks explicit with calls to s/valid? or s/conform. Or use s/assert to make the validation checks toggleable via flags. For this kind of use, I would probably not use pre/post checks - you're likely to want more control around the error handling if data is invalid.

Also if I am library writer how can I allow the user to turn on instrumentation for my library functions during their development so that they get better error messages during testing. Does doing instrument-all turns on instrumentation for the required namespaces as well?

If you're a library writer, you can choose to deliver function specs either in the same namespace as your code or in separate namespaces. The latter gives the user more control over whether and if those specs are loaded. They can choose to instrument your code by calling instrument at either the specific var, namespace (via enumerate-namespace) or for everything (by passing no args to instrument). It may make sense in some cases to provide a function specifically to enable instrumentation for the parts of your library that make sense.

3

u/dustingetz Feb 22 '18

Thanks, for everyone else here is some addl info on spec perf

https://groups.google.com/forum/#!msg/clojure/kLLvOdtPO_k/Pwtcn9KlCQAJ

2

u/xtreak Feb 21 '18

Thanks

3

u/SimonGray Feb 22 '18

/u/alexdmiller is it possible to get an excerpt in mobi format (or alternatively, epub for converting to mobi) so that I can preview it on a kindle? When I download excerpts I just get PDF.

1

u/alexdmiller Feb 22 '18

You’ll need to ask Pragmatic about that, I’m not involved in the delivery portion. :)

1

u/SimonGray Feb 22 '18

Ok. Thanks for letting me know anyhow.

5

u/agumonkey Feb 21 '18

Congrats to the authors (and everyone involved)

1

u/nogridbag Feb 25 '18

Bought the eBook version - thanks. I read the Brave and True book online previously and really enjoyed that. Being a Java dev I was able to get up to speed with Clojure very quickly. Hoping this will help drill down some of the concepts I forgot.

I'm still early on in the book, but the only issued I noticed was the getting started path for Windows users is not really clear since the Clojure CLI tools are not available for Windows yet. Clojure 1.9's a bit harder to launch from the command line as well since it requires spec and core.specs.

2

u/alexdmiller Feb 26 '18

My hope is that that gap will only be true for a short time here at the beginning. :)

1

u/[deleted] Feb 26 '18

Ordered both the physical copy + ebook from the Pragmatic site on 2/22. Shipping was supposed to start 2/23. Haven't received an email yet about my copy being shipped.

Hope this happens soon here as I hate reading technical books on pdf.

Just something about a physical book - being able to mark stuff, write in the margins and flip through it makes all the difference for me.

1

u/alexdmiller Feb 26 '18

Yeah, I'm not sure what the schedule is on physical printing + shipping. I haven't seen it yet either!

2

u/[deleted] Feb 26 '18

As a Clojure novice, it's amazing to see the kind of community involvement here.

Am looking forward to get my hands on the copy. Meanwhile, the book looks really well done!

Congratulations, and thanks for all the hard work!

2

u/kinleyd Feb 22 '18

Great news - well done!

2

u/amoe_ Feb 23 '18

Amazing!