Saturday, March 21, 2015

Book Review: Clojure Web Development Essentials by Ryan Baldwin

A few weeks ago, I got an email from Gavin Cardoza at Packt Publishing offering me a free e-book in exchange for writing a review of Packt's recently-published Clojure Web Development Essentials, by Ryan Baldwin. I think I'll turn down the offer of a free e-book, but I'm happy to write a review because I think Baldwin has done an excellent job on the book. (Disclaimer: I did get a review copy of the book at no charge).

Rather than trying to survey all the tools and libraries available to the Clojure web developer, the author has made the very sensible decision to zero in on Luminus, a mature and well-crafted base project that provides you with the fully-functioning core of a web application, without locking you into a rigid framework. Starting from the Luminus defaults, Baldwin then walks you step by step through the process of configuring the server, configuring the logs (including the tricky bits!), handling forms, persisting data to a SQL database, handling logins, security, and sessions, and finally deploying to production. At each step, you have a fully operational (though incomplete) web application to play with, so the feedback is immediate and satisfying.

In keeping with the Essentials theme, the author sticks to the basics, and resists the temptation to drag in all the interesting related topics that so often muddy and confuse introductory tutorials. Anywhere Luminus offers the developer a wide range of choices, Baldwin picks a good one and runs with it, without falling down the rabbit hole of trying to consider the strengths and weaknesses of each option. This makes the book much easier to follow, retain, and apply, and keeps it from getting boring. Those other choices are out there, and you can learn them later if you're interested, but when you do, you'll already have the basic essentials down, and will be much better equipped to relate new information to what you already know.

As a web developer who uses exclusively MySQL (and/or MariaDB) in my day job, I was interested to see that Baldwin chose to focus on PostgreSQL as the database for this book. That's a good choice for anyone interested in deploying to Heroku or a similar platform, where Postgres services are easier to find than MySQL services, but it might surprise you if you're coming to this book from other web development environments like me. If you haven't played with Postgres before, this book might whet your appetite for more.

If I had to criticize this book for anything, it would be regarding two points. First of all, this book is written from the point of view of a developer working either in OS X or Linux, not Windows. That's understandable, since Clojure development involves a certain amount of command-line work, and Windows brings in a bit more complexity when it comes to getting everything up and running. The omission does make it easier for the book to stay focused on the Essentials of Clojure web development, but might prove frustrating to Windows-based developers trying to get their feet wet in Clojure for the first time.

My other complaint is that the book does not spend a lot of time on the topic of web security. This, again, is probably a tactical decision in the interests of keeping to the Essentials, but being the naturally paranoid person that I am, I wish the book had devoted more discussion to the topic. It does at least walk through the process of using bcrypt to secure passwords, instead of making the mistake of storing them in a decryptable form, so that's a big point in its favor. But an appendix, or at least a link or two, would not have been amiss.

Other than those two complaints, I was very impressed by this book. The writing style is lively and interesting, yet clear and to the point. The examples are easy to follow and do a good job of conveying the technology they are trying to explain. And I love his decision to implement his database interactions using YeSQL rather than a more complicated ORM or ORM-ish system. As someone who has to wrestle with ORM syntax every day (in PHP, no less), the simplicity of straight SQL-as-a-function is something I drool over.

I've got a number of Packt books and I keep going back because they're generally high quality and their e-book format is just right for the Kindle app on my iPad, but I have to say that Clojure Web Development Essentials looks like one of their best so far. Kudos to Ryan Baldwin on a great job, and I hope he decides to do a follow-up book on securing Clojure web applications. (Hint, hint.)