- Paperback: 308 pages
- Publisher: Pragmatic Bookshelf; 2 edition (July 24, 2016)
- Language: English
- ISBN-10: 1680500821
- ISBN-13: 978-1680500820
- Product Dimensions: 7.5 x 0.8 x 9 inches
- Shipping Weight: 1 pounds (View shipping rates and policies)
- Average Customer Review: 5 customer reviews
- Amazon Best Sellers Rank: #781,023 in Books (See Top 100 in Books)
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
Web Development with Clojure: Build Bulletproof Web Apps with Less Code 2nd Edition
Use the Amazon App to scan ISBNs and compare prices.
Frequently bought together
Customers who bought this item also bought
From the Publisher
Five Questions about Clojure and Web Development by Dmitri Sotnikov
What’s Clojure like?
Clojure is a small, elegant, and extensible language whose primary goals are simplicity and correctness. As a functional language, it emphasizes immutability and declarative programming. It is hosted on the Java Virtual Machine, giving it a mature and highly performant environment with great tooling and deployment options.
What’s so special about Clojure?
Anything that can be expressed in one high-level language can also be expressed in any other. But the practical question is how well the language maps to the problem to be solved. Does the language let you think in terms of your problem domain, or do you have to keep translating domain concepts in the constructs of the language? The best case is when you can use the language without thinking about it. This is where Clojure shines. It allows you to easily derive a solution expressed in the terminology of the problem domain.
Why use a functional language for web apps?
Functional languages are ideal for writing large applications because by default they eschew global state in favor of immutability. Having data that can’t change its value off-stage allows us to safely reason about parts of the application in isolation. In addition, the focus on immutability makes it much easier to tackle the difficult problems of parallelism and concurrency. While there is no silver bullet for addressing either problem, a functional language can go a long way in helping you reason about them.
Why write web apps in Clojure?
Clojure boasts tens of thousands of users, and web development is one of the major domains where it’s used. But many other platforms are available for doing web development, so why should you choose Clojure over one of them? Well, most popular platforms force you to make trade-offs: sacrificing performance, infrastructure, conciseness, or ease of development. By hosting a modern functional language on the JVM, Clojure’s creator doesn’t ask you to sacrifice anything.
Are there Clojure frameworks like Rails for Ruby?
The Clojure community has settled on using libraries coupled with project templates in favor of frameworks. Libraries can be easily composed in a way that makes sense for your particular project. Meanwhile, the templates allow creating projects quickly without the need for the inversion of control seen in frameworks. Many web developers find that this model has clear advantages over the framework-based approach. I think you will too.
About the Author
Dmitri Sotnikov is a passionate Clojure developer who enjoys building web applications. He has developed a number of popular Clojure libraries and is the author of the Luminus micro-framework.
Top customer reviews
There was a problem filtering reviews right now. Please try again later.
There are a number of books on Clojure but none that focus specifically on how to build a website - i.e. setting up a http server, database connections, db queries, taking form, url or session params to get data from the db, etc. So this book was very helpful in quickly getting me building a guestbook with all these essential requirements for a website app.
What I found as I went through the book's example apps was how flexible and easy it is to switch libraries and that the Clojure library system is quite extensive. In the rare case one doesn't exist for your needs, you simply include a java lib.
You include libraries in your project.clj file and then in the root of your app in the terminal command line simply type 'lein ring server' and before firing up the web server lein automatically fetches and installs them in your app. Lein is akin to rake in Ruby on Rails and just as concise and user friendly.
The book walks you through building the example applications with the views in the Hiccup template language. In later chapters, the author shows you a walk through of how to do the same application with the Selmer template system which he created based on the django template design.
The author is quite prolific in his support of the Clojure community having contributed some key libraries, developed the Luminus web framework in Clojure and as one of the maintainers of lib-noir, one of the key Clojure libraries useful for building websites. I tried Luminus which is a Clojure web project template with a curated set of useful libraries.
With one command line in your terminal with lein Luminus generate a project template with either mysql or postgres, authentication and clojurescript if you desire it. Then you just enter your username and password for the database in the db config file to get up and running.
If I got stuck on anything, I was able to go to click on a link related to the example in the digital book which takes you to the publishers website to view the source code of the example. With the book you get access to a zip file that has source code versions for all the examples utilizing different libraries so you can see how they actually work.
There are even examples writing direct sql vs an orm. For example on the picture gallery app in the book there are 12 source code versions of the same app utilizing different libraries in the zip file.
A side effect of delving into Clojure with this book was that it made traditional object oriented code in other languages seem far simpler than before. It also sped up up my coding in other languages.
Functional programming with Clojure functions is quite different to object oriented programming, yet has a powerful simplicity once it clicks. As the author states in the intro, Clojure is a simple language to learn as there's very little syntax, and once you learn a handful of patterns you're quickly productive, typically within a couple of weeks.
The book takes you from creating your project application, installing the libraries of your choice, building your app and then deploying it stand alone, as a Tomcat servlet or in the cloud. There's also references to other useful libraries depending on your preference, so its quite flexible.
At the end of the book there's a section on the clojure language to get you productive enough to build web applications. I would say this book greatly simplifies the task of building web apps, luckily it exists as there is no other comprehensive resource specifically for building websites in Clojure.
One thing unique to Clojure is a real time REPL whereby your can see the results of your functions in real time in either an IDE called Light Table or IntelliJ. That helps you experiment and save time debugging as you're going along.
The book assumes you know nothing about Clojure and gets you seeing results right away. So I would highly recommend it to anyone using another language interested in exploring Clojure for skill expansion or greater performance and productivity.
I would rate the book 5 stars but I can't. The author did a great job, no doubt about it, but Clojure web development is a bit hectic at the moment. I had to take a star off because I wish the book covered more technologies. There is just too much going on in Clojure, there is no single accepted way to develop web apps. Ruby, for example, has Rails and this is pretty much a defacto stack for the language. Clojure on the other hand has many different libraries and "no one true" web framework (Arachne is upcoming and we don't know much about it yet).
Dmitry focuses on Reagent for the front end, and he makes some safe choices for a back end (Postgres). But if we look around available web tools for Clojure then we'll see many many different technologies. Ask anybody who is using Clojure in production and chances are they all will have different tools. There is OM, Reagent, Rum, Hoplon, etc. Many templating languages. Various databases, including unique Datomic. And there are many ways to build an app in Clojure/ClojureScript.
So this is what I am getting at. Dmitry shows you how to build an app one way, his way, based on Luminus (the tool he wrote). But I am not saying that it's wrong in anyway, I just wish the book covered more technologies, that way a reader could choose what he likes best. And there are a lot of good and interesting stacks right now. Of course author couldn't explain everything in detail, it's not his fault, web development in Clojure has no unity and there is a lot going on. But here's the thing, if we had a book that covers most popular web stacks then it would be a 5 star. Perhaps in a 3rd edition Dmitry can build up on what he has and he can introduce more material.
Nonetheless, this book is probably the best one on the market right now that covers web development with Clojure from start to finish. It is similar to Hartl's tutorial about Ruby on Rails.
Overall this book was the best Web Development book for Clojure I have read!