Web Development with Clojure: Build Bulletproof Web Apps with Less Code ペーパーバック – 2014/1/12
Kindle 端末は必要ありません。無料 Kindle アプリのいずれかをダウンロードすると、スマートフォン、タブレットPCで Kindle 本をお読みいただけます。
If the usual patchwork of web development tools and languages just isn't cutting it for you, you need Web Development With Clojure. Clojure gives you the rich infrastructure of the JVM with the expressive power of a modern functional language. It combines excellent performance with rapid development--and you can exploit these virtues for web app development. With step-by-step examples, you'll learn how to harness that power and richness to build modern web applications.
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.
What You Need:
The latest JVM, Clojure 1.4+, and the Leiningen build tool, as well as an editor such as Emacs, Eclipse, or Light Table.
Dmitri Sotnikov has been developing Web applications professionally for close to a decade. He has developed and continues to maintain several Clojure libraries as well as the Luminus framework. He has worked in both startup and enterprise environments.
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.