Web Development with Clojure: Build Bulletproof Web Apps with Less Code (英語) ペーパーバック – 2016/7/24
Kindle 端末は必要ありません。無料 Kindle アプリのいずれかをダウンロードすると、スマートフォン、タブレットPCで Kindle 本をお読みいただけます。
Modern web applications deserve modern tools. Harness the JVM's rich infrastructure while taking advantage of the expressive power and brisk performance of a modern functional language. Exploit Clojure's unique advantages for web development. Step by step, apply the fundamentals of programming in Clojure to build real-world, professional web applications. This edition features new libraries, tools, and best practices, and focuses on developing modern single-page applications.
Stop developing web apps with yesterday's tools. Today, developers are increasingly adopting Clojure as a web-development platform. See for yourself what makes Clojure so desirable, as you create a series of web apps of growing complexity, exhibiting the full process of web development using a modern functional language. Journey through all the steps in developing a rich Picture Gallery web application--from conception to packaging and deployment. You'll work hands-on with Clojure and build real-world, professional web apps.
This fully updated second edition reveals the changes in the rapidly evolving Clojure ecosystem. Get up to speed on the many new libraries, tools, and best practices. Gain expertise in the popular Ring/Compojure stack using the Luminus framework. Learn how Clojure works with databases and speeds development of RESTful services. See why ClojureScript is rapidly becoming a popular front-end platform, and use ClojureScript with the popular Reagent library to build single-page applications.
This book is for you, whether you're already familiar with Clojure or if you're completely new to the language.
What You Need:
The latest JVM, Clojure 1.6+, and the Leiningen build tool, as well as an editor such as Emacs, IntelliJ, Eclipse, Light Table, or VI.
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.
What I really like is that Clojure and the tools and frameworks are so expressive that I can get useful projects completed in very few lines of code. Small enough that you can get your head around whole pieces of functionality. Something that might take several classes, and several pages of code in Java can be completed in Clojure in one to two pages of code.
UPDATE: I've updated to three stars because I feel like this was a quality book that got caught in the common trap of being about technology that is rapidly changing.
I've found out that the authors are working on another edition due out in the next 6-9 months so if you're interested in the book, you might want to wait for that next edition to be released. In the mean time, you can try out the Luminus micro-framework tutorials on that project's web site. I found it to be similar to what is covered in the first chapter of this book.
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.