Modern web development needs modern tools. Web Development With Clojure shows you how to apply Clojure programming fundamentals to build real-world solutions. You'll develop all the pieces of a full web application in this powerful language. If you already have some familiarity with Clojure, you'll learn how to put it to serious practical use. If you're new to the language, the book provides just enough Clojure to get down to business.
You'll learn the full process of web development using Clojure while getting hands-on experience with current tools, libraries, and best practices in the language. You'll develop Clojure apps with both the Light Table and Eclipse development environments. Rather than frameworks, Clojure development builds on rich libraries. You'll acquire expertise in the popular Ring/Compojure stack, and you'll learn to use the Liberator library to quickly develop RESTful services. Plus, you'll find out how to use ClojureScript to work in one language on the client and server sides.
Throughout the book, you'll develop key components of web applications, including multiple approaches to database access. You'll create a simple guestbook app and an app to serve resources to users. By the end, you will have developed a rich Picture Gallery web application from conception to packaging and deployment.
This book is for anyone interested in taking the next step in web development.Q&A with Dmitri Sotnikov
Why did you write Web Development with Clojure?
When I started using Clojure, I found that it took a lot of work to find all the pieces needed to put together a working application. There was very little documentation available on how to organize the code, what libraries to use, or how to package the application for deployment. Having gone through the process of figuring out what works, I thought that it would be nice to make it easier for others to get started.
What are the advantages of using a functional language?
Over the course of my career, I have developed a great appreciation for functional programming. I find that it addresses a number of shortcomings present in the imperative paradigm. For example, in a functional language any changes to the data are created via revisions to the existing data. So they only exist in the local scope. This fact allows us to safely reason about individual parts of the program in isolation, which is critical for writing and supporting large applications.
Why use Clojure specifically?
Clojure is a simple and pragmatic language that is designed for real-world usage. It combines the productivity of a high-level language with the excellent performance seen in languages like C# or Java. It's also very easy to learn because it allows you to use a small number of concepts to solve a large variety of problems.
If I already have a preferred web development platform, what might I get out of this book?
If you're using an imperative language, you'll get to see a very different approach to writing code. Even if you're not going to use Clojure as your primary language, the concepts you'll learn will provide you with new ways to approach problems.
Is the material in the book accessible to somebody who is not familiar with Clojure?
Absolutely. The book targets developers who are already familiar with the basics of web development and are interested in learning Clojure in this context. The book introduces just enough of the language to get you productive and allows you to learn by example.
This book provides not only good overview of the Clojure's libraries for web development, but also shows how to build complete application (picture gallery with support of multiple users, etc.). Besides this, book describes how to use profiles for dev & production, how to deploy applications. In the final parts, book describes templating libraries, and briefly shows how to write client-side code with ClojureScript.
P.S. To read this book you already should be familiar with the Clojure.
I read the beta version of the second edition. I think it was a good introduction to web development in the Clojure world. It mainly focuses on the Luminus approach, but much of the ideas are generalizable.
I think the testing section could have covered a little more, but that could be because I come from a background where integration tests are more prevalent. It seems that dynamic languages do lean this direction a bit more, particularly an app built with Reagent it would have been good to see how to test the client side of the application. I am not sure if this is omitted because of the general complexity of the subject, or something else.
A good overview of the current best practices for writing web applications with Clojure. I did miss a section on i18n and l10n. I understand that I can find that information elsewhere, but it would be nice to have it all in one place.
Near the end the examples get sloppier, and require some fixes if you are following along on the computer. But the source code that you can download from the book's web site is correct, so you can always use that instead.
First of all, this book suffers from the same mistakes every single Lisp-like language book I've read: They throw a truck at you, then slowly, while you're being crushed by it, explain each part that creates a truck -- In other words, they throw a large piece of code at you and then slowly explain each part of it.
Even worst, in the last parts, it's basically "here is truck, take it" -- very little explanation about the code itself, just "we'll do this" and code. What the pieces of code mean, that's entirely to you.
Another problem: no tests. The author prefers the REPL approach, which is okay for little projects, but for projects that should last longer than a weekend project. No only that, but even the tests are wrong, because it mocks the database -- Database is part of your project so it should be tested along all the other tests.
And, on top of that, there is a REST server with sessions, and a lot of code just to keep the frontend session in sync with the server session. That's actually not how a REST server works.
And while I usually don't comment the technology behind the book (because it's not the author's creation), I really have to ask if Clojure is the right tool for web servers. I mean, a lot about Clojure is about immutability and a lot about the shown code is forcing mutability -- one function even is composed with nothing but functions that force mutability.
So, not only the book itself doesn't give a clear picture about web development in Clojure, the language itself doesn't appear appropriate for such task.
Good way to get started developing web applications with Clojure. All of the important things you are going to need developing web applications are addressed. I consider WebSocket related material nice addition to this, as it was my first hands-on exposure to using them.
No prior experience with Clojure is required, but I would say that reading a book on Clojure basics is highly useful. I would have struggled a lot more if this was my first exposure to Clojure.
The book contains a lot of examples to follow through which is very useful to get started building your own projects. As a downside to these examples, I wasn't able to use the versions suggested in the book, so I had to go with the latest versions and because of this there was some additional hassle for me. As a learning experience the extra searching was useful, but made following the book a lot more time consuming.
If Goodreads supported half stars I would have given 3.5, but as it doesn't I feel this book is closer to 4 stars than three.
This book goes over a bunch of libraries you can use to make web applications in Clojure. It does not give you much more compared to their respective websites, but it's in one place and you can read it if you're curious what's going on in that area.
I particularly liked the section on deployment options and testing. However, some parts of the book felt as unnecessary appendices, e.g., the introduction to document DBs.
This is the most complete review there is of making an SPA with microservices in Clojure/Script.
That said, it's not as polished as the RailsTutorial and uses some idiomatic Clojure that I really had to fuss over for a bit. It was also sometimes hard to tell when I was supposed to change code.