Developers are discovering the immense power of Clojure's functional programming model to quickly solve problems in domains ranging from social networking to Big Data. Targeting the Java Virtual Machine, Clojure also leverages the Java platform's maturity and enormous ecosystem. Clojure Recipes is a "code recipe book" for this increasingly popular language.
Julian Gamble focuses on practical and complete examples that illuminate Clojure's key features and show step-by-step how to solve real-world problems with it. Clojure Recipes provides a series of "learn by doing" step-by-step projects, you'll learn how to:
- Write your own DSL
- Build a website with Pedestal
- Add Clojurescript to your website
- Abstract boilerplate code into a macro
- Get started with Storm
- Get started with Datomic
- Build log readers, web app monitors, web testing suites, customized Ant tasks, and more
Author(s): Julian Gamble
Edition: 1
Publisher: Addison-Wesley Professional
Year: 2015
Language: English
Pages: 265
Preface
1 Starting Your Project with Leiningen
Assumptions
Benefits
The Recipe—Windows
The Recipe—Mac
Conclusion
Postscript—Setting Up a JDK on a Mac
Postscript—Setting Up a JDK on Windows
2 Packaging Clojure for a Java EE Environment
Assumptions
Benefits
The Recipe—Common
Conclusion
Postscript—Setting Up Tomcat on a Mac
Postscript—Setting Up Tomcat on Windows
3 Creating a REST Server in Compojure
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
4 Creating a REST Server with Liberator
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Context
Origins
REST Hypermedia
Conclusion
5 A REST Client in ClojureScript
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
6 A Simple JSON Server
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
7 A Simple Server Using the Pedestal Framework
Assumptions
Benefits
Context
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
8 A Stock Ticker on the Pedestal Framework Server
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
9 Simplifying Logging with a Macro
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
10 Extending the Compiler with a Macro
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
11 Simplifying Datomic Syntax by Writing a DSL
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Testing Create Schema
Testing Add Datom
Testing Create Nested Schema
Testing Add Nested Datom
Notes on the Recipe
create.clj
create_test.clj
add.clj
add_test.clj
create_nested.clj
create_nested_test.clj
add_nested.clj
add_nested_test.clj
Conclusion
12 Reading the SASS DSL and Generating CSS with Clojure Zippers
Assumptions
Benefits
Outline—Features of SASS
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
13 Introduction to Cascalog
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
14 Cascalog and Hadoop
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Conclusion
Postscript—Setting Up Hadoop on a Mac
Postscript—Setting Up Hadoop on a Windows Machine
15 Loading a Data File into Cascalog
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Conclusion
16 Writing Out a Data File with Cascalog
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
17 Cascalog and Structured Data
Assumptions
Benefits
The Recipe—Code
Testing the Recipe
Notes on the Solution
Conclusion
18 Loading Custom Data Formats into Cascalog
Assumptions
Benefits
The Recipe—Code
Testing the Recipe
Notes on the Solution
Conclusion
19 Connecting to Datomic from Your Application
Assumptions
Benefits
The Recipe—Code
Getting Set Up
Connecting to Datomic in the Shell
Loading Schema and Data
Connecting to Datomic from Clojure
Connecting to Datomic from Java
Connecting to Datomic from a REST Client
Conclusion
20 Getting Started with Storm
Assumptions
Benefits
The Recipe—Code
Testing the Recipe
Notes on the Recipe
Conclusion
21 Getting Started with JMS in Clojure
Assumptions
Benefits
The Recipe—Code
Testing the Recipe
Notes on the Recipe
Conclusion
22 Integrating Storm and JMS
Assumptions
Benefits
The Recipe—Code
Testing the Recipe
Notes on the Recipe
Conclusion
23 A CSV Reader
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
24 Detecting Errors with a Log Monitoring Application
Assumptions
Benefits
The Recipe—Code
Testing the Solution
Notes on the Recipe
Conclusion
25 Bundling Clojure as an Ant Plug-in
Assumptions
Benefits
The Recipe—Code
Testing the Recipe
Notes on the Recipe
Conclusion
Postscript—Installing Ant on a Mac
26 Bundling Clojure as a Maven Plug-in
Assumptions
Benefits
The Recipe—Code
Testing the Recipe
Notes on the Recipe
Conclusion
27 Integrating Clojure by Scripting Web Tests
Assumptions
Benefits
The Recipe—Code
Testing the Recipe
Notes on the Recipe
Conclusion
28 Monitoring Availability with a Website Status Checker
Assumptions
Benefits
The Recipe—Code
Testing the Recipe
Notes on the Recipe
Conclusion
A Debugging Macros
Assumptions
Benefits
The Recipe
A Simple Approach—Expansion-Time and Evaluation-Time stdout
Some Macro Helper Functions
Read and Evaluate—A More Developed Mental Model
Reading
Evaluating
Conclusion