Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Preface

Acknowledgments

About this Book

1. Getting started

Chapter 1. Introduction to Clojure

1.1. What is Clojure?

1.1.1. Clojure—the reincarnation of Lisp

1.1.2. How we got here

1.1.3. How this book teaches Clojure

1.2. Understanding Clojure syntax

1.2.1. XML and parentheses

1.2.2. Lists, vectors, and hashes

1.3. The sources of Clojure’s power

1.3.1. Clojure and Lisp

1.3.2. Clojure and functional programming

1.3.3. Clojure and the JVM

1.3.4. Clojure as a Lisp

1.3.5. More advantages of Clojure

1.3.6. Clojure as a functional language

1.3.7. Clojure as a JVM-based Language

1.4. Clojure—beyond object orientation

1.5. Summary

Chapter 2. A whirlwind tour

2.1. Getting started

2.1.1. Installing Clojure

2.1.2. The Clojure REPL

2.1.3. Hello, world

2.1.4. doc and find-doc

2.1.5. A few more points on Clojure syntax

2.2. Program structure

2.2.1. Functions

2.2.2. The let form

2.2.3. Side effects with do

2.2.4. try/catch/finally and throw

2.2.5. Reader macros

2.3. Program flow

2.3.1. Conditionals

2.3.2. Functional iteration

2.3.3. The threading macros

2.4. Clojure data structures

2.4.1. nil, truth, and falsehood

2.4.2. Chars, strings, and numbers

2.4.3. Keywords and symbols

2.4.4. Sequences

2.5. Summary

Chapter 3. Building blocks of Clojure

3.1. Functions

3.1.1. Defining functions

3.1.2. Calling functions

3.1.3. Higher-Order Functions

3.1.4. Anonymous functions

3.1.5. Keywords and symbols

3.2. Scope

3.2.1. Vars and binding

3.2.2. The let form revisited

3.2.3. Lexical closures

3.3. Namespaces

3.3.1. ns

3.3.2. Working with namespaces

3.4. Destructuring

3.4.1. Vector bindings

3.4.2. Map bindings

3.5. Metadata

3.6. Summary

Chapter 4. Polymorphism with multimethods

4.1. Polymorphism

4.1.1. Subtype polymorphism

4.1.2. Duck typing

4.2. Method dispatch

4.2.1. Single and double dispatch

4.2.2. The visitor pattern (and simulating double dispatch)

4.2.3. Multiple dispatch

4.3. Multimethods

4.3.1. Without multimethods

4.3.2. Using multimethods

4.3.3. Multiple dispatch

4.3.4. Ad hoc hierarchies

4.3.5. Redis-clojure

4.4. Summary

Chapter 5. Clojure and Java interop

5.1. Calling Java from Clojure

5.1.1. Importing Java classes into Clojure

5.1.2. Creating instances and accessing methods and fields

5.1.3. memfn

5.1.4. bean

5.1.5. Arrays

5.1.6. Implementing interfaces and extending classes

5.2. Compiling Clojure code to Java byte code

5.2.1. Example–a tale of two calculators

5.2.2. Creating Java classes and interfaces using gen-class and gen-interface

5.3. Calling Clojure from Java

5.4. Summary

Chapter 6. State and the concurrent world

6.1. The problem with state

6.1.1. Common problems with shared state

6.1.2. The traditional solution

6.2. Identities and values

6.2.1. Immutable values

6.2.2. Objects and time

6.2.3. Immutability and concurrency

6.3. The Clojure way

6.3.1. Requirements for immutability

6.3.2. Managed references

6.4. Refs

6.4.1. Mutating refs

6.4.2. Software transactional memory

6.5. Agents

6.5.1. Mutating agents

6.5.2. Working with agents

6.5.3. Side effects in STM transactions

6.6. Atoms

6.6.1. Mutating atoms

6.7. Vars

6.8. State and its unified access model

Creating

Reading

Mutation

Transactions

6.9. Watching for mutation

6.10. Futures and promises

6.10.1. Futures

6.10.2. Promises

6.11. Summary

Chapter 7. Evolving Clojure through macros

7.1. Macro basics

7.1.1. Textual substitution

7.1.2. The unless example

7.1.3. Macro templates

7.1.4. Recap—why macros?

7.2. Macros from within Clojure

7.2.1. comment

7.2.2. declare

7.2.3. defonce

7.2.4. and

7.2.5. time

7.3. Writing your own macros

7.3.1. infix

7.3.2. randomly

7.3.3. defwebmethod

7.3.4. assert-true

7.4. Summary

2. Getting real

Chapter 8. Test-driven development and more

8.1. Getting started with TDD

8.1.1. Example: dates and string

8.2. Mocking and stubbing things

8.2.1. Example: expense finders

8.2.2. Stubbing

8.2.3. Mocking

8.2.4. Mocks versus stubs

8.3. Organizing tests

8.3.1. Testing

8.3.2. are

8.4. Summary

Chapter 9. Data storage with Clojure

9.1. MySQL & clj-record

9.1.1. ActiveRecord, users, and charges

9.1.2. The user model

9.1.3. Associations

9.1.4. Validations and callbacks

9.1.5. A look under the hood

9.2. HBase

9.2.1. Meet HBase

9.2.2. Using Clojure to access HBase

9.3. Redis

9.3.1. Installing Redis

9.3.2. Accessing Redis from Clojure programs

9.3.3. A Redis data mapper

9.4. Summary

Chapter 10. Clojure and the web

10.1. An HTTP interface from scratch

10.1.1. The HTTP engine

10.2. Ring

10.2.1. Understanding Ring

10.2.2. Middleware

10.3. Compojure

10.3.1. Using Compojure

10.3.2. Under the hood

10.4. Generating HTML

10.4.1. clj-html

10.4.2. Under the hood

10.5. Summary

Chapter 11. Scaling through messaging

11.1. Messaging systems

11.1.1. JMS, STOMP, AMQP

11.1.2. ActiveMQ, RabbitMQ, ZeroMQ

11.2. Clojure and RabbitMQ

11.2.1. AMQP basics

11.2.2. Connecting to RabbitMQ

11.2.3. Sending messages over RabbitMQ

11.2.4. Receiving messages from RabbitMQ

11.3. Distributed parallel programming

11.3.1. Creating remote workers

11.3.2. Servicing worker requests

11.3.3. Putting it all together

11.3.4. Multicasting messages to multiple receivers

11.3.5. Calling all workers

11.3.6. Additional features

11.4. Summary

Chapter 12. Data processing with Clojure

12.1. The map/reduce paradigm

12.1.1. Getting started with map/reduce—counting words

12.1.2. Generalizing the map/reduce

12.1.3. Parsing logs

12.1.4. Analyzing Rails sessions

12.1.5. Large-scale data processing

12.2. Master/slave parallelization

12.2.1. Defining the job

12.2.2. Maintaining status

12.2.3. Dispatching a job

12.2.4. Defining the slave

12.2.5. Using the master-slave framework

12.2.6. Running a job

12.2.7. Seeing task errors

12.2.8. Rerunning the job

12.3. Summary

Chapter 13. More on functional programming

13.1. Using higher-order functions

13.1.1. Collecting results of functions

13.1.2. Reducing lists of things

13.1.3. Filtering lists of things

13.2. Partial application and currying

13.2.1. Adapting functions

13.2.2. Defining functions

13.2.3. Currying

13.3. Closures

13.3.1. Free variables and closures

13.3.2. Delayed computation and closures

13.3.3. Closures and objects

13.3.4. An object system for Clojure

13.4. Summary

Chapter 14. Protocols, records, and types

14.1. The expression problem

14.1.1. The Clojure world

14.1.2. The Java world

14.1.3. The expression problem

14.1.4. Clojure’s multimethods solution

14.2. Modus operandi

14.2.1. def-modus-operandi

14.2.2. detail-modus-operandi

14.2.3. Tracking our modus operandi

14.2.4. The next step

14.3. Protocols and data types

14.3.1. defprotocol and extend-protocol

14.3.2. deftype, defrecord, and reify

14.4. Summary

Chapter 15. More macros and DSLs

15.1. Macros

15.1.1. Anaphoric macros

15.1.2. The anaphoric if

15.1.3. The thread-it macro

15.1.4. Shifting computation to compile time

15.1.5. Macro-generating macros

15.2. Domain-specific languages

15.2.1. DSL-driven design

15.2.2. User classification

15.3. Summary

Index

List of Figures

List of Tables

List of Listings

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.31.67