Clojure: High Performance JVM Programming

Explore the world of lightning fast Clojure apps with asynchronous channels, logic, reactive programming, and more

Clojure: High Performance JVM Programming

This ebook is included in a Mapt subscription
Eduardo Díaz, Shantanu Kumar, Akhil Wali

Explore the world of lightning fast Clojure apps with asynchronous channels, logic, reactive programming, and more
$0.00
$32.00
$79.99
$29.99p/m after trial
RRP $63.99
RRP $79.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781787129597
Paperback565 pages

Book Description

Clojure is a general-purpose language from the Lisp family with an emphasis on functional programming. It has some interesting concepts and features such as immutability, gradual typing, thread-safe concurrency primitives, and macro-based metaprogramming, which makes it a great choice to create modern, performant, and scalable applications.

This learning path aims at unleashing the true potential of the Clojure language so you can use it in your projects. It begins with installing and setting up the Clojure environment before moving on to explore the language in depth. You’ll get acquainted with its various features such as functional programming, concurrency, reducers, transducers, core.async and core.logic, and so on with a great level of detail.

Moving on, you’ll also learn how to enhance performance using Java interoperability and JVM-specific features from Clojure; you’ll even master language features such as asynchronous channels, actors, logic programming, reactive programming, metaprogramming, and so on.

This learning path combines some of the best that Packt has to offer in one complete, curated package. It includes content from the following Packt products:

  • Clojure for Java Developers by Eduardo Díaz
  • Clojure High Performance Programming, Second Edition by Shantanu Kumar
  • Mastering Clojure by Akhil Wali

Table of Contents

Chapter 1: Getting Started with Clojure
Getting to know Clojure
Installing Leiningen
Using a REPL
Creating a new project
Using Cursive Clojure
Getting started with Clojure code and data
Clojure's data types
Summary
Chapter 2: Namespaces, Packages, and Tests
Namespaces in Clojure
The classpath and the classloader
Testing in Clojure
Summary
Chapter 3: Interacting with Java
Using Maven dependencies
Clojure interop syntax
Writing a simple image namespace
Writing the tests
Destructuring in Clojure
Exposing your code to Java
Proxy and reify
Summary
Chapter 4: Collections and Functional Programming
Basics of functional programming
Persistent collections
Types of collections in Clojure
The sequence abstraction
Specific collection types in Clojure
Summary
Chapter 5: Multimethods and Protocols
Polymorphism in Java
Multimethods in Clojure
Protocols in Clojure
Summary
Chapter 6: Concurrency
Using your Java knowledge
The Clojure model of state and identity
Promises
Futures
Software transactional memory and refs
Atoms
Agents
core.async
Summary
Chapter 7: Macros in Clojure
Lisp's foundational ideas
Macros as code modification tools
Writing your first macro
Debugging your first macro
Macros in the real world
References
Summary
Chapter 8: Performance by Design
Use case classification
A structured approach to the performance
The performance vocabulary
The latency numbers that every programmer should know
Summary
Chapter 9: Clojure Abstractions
Non-numeric scalars and interning
Identity, value, and epochal time model
Persistent data structures
Sequences and laziness
Transducers
Transients
Performance miscellanea
Summary
Chapter 10: Leaning on Java
Inspecting the equivalent Java source for Clojure code
Numerics, boxing, and primitives
Arrays
Reflection and type hints
Using array/numeric libraries for efficiency
Resorting to Java and native code
Summary
Chapter 11: Host Performance
The hardware
The Java Virtual Machine
Measuring latency with Criterium
Summary
Chapter 12: Concurrency
Low-level concurrency
Atomic updates and state
Asynchronous agents and state
Coordinated transactional ref and state
Dynamic var binding and state
Validating and watching the reference types
Java concurrent data structures
Concurrency with threads
Clojure parallelization and the JVM
Parallelism with reducers
Summary
Chapter 13: Measuring Performance
Performance measurement and statistics
Performance testing
Performance monitoring
Profiling
Summary
Chapter 14: Performance Optimization
Project setup
Identifying performance bottlenecks
Profiling code with VisualVM
The Monitor tab
Performance tuning
Summary
Chapter 15: Application Performance
Choosing libraries
Logging
Data sizing
Resource pooling
I/O batching and throttling
Precomputing and caching
Concurrent pipelines
Applying back pressure
Performance and queueing theory
Summary
Chapter 16: Working with Sequences and Patterns
Defining recursive functions
Thinking in sequences
Working with pattern matching
Summary
Chapter 17: Orchestrating Concurrency and Parallelism
Managing concurrent tasks
Managing state
Executing tasks in parallel
Summary
Chapter 18: Parallelization Using Reducers
Using reduce to transform collections
Using fold to parallelize collections
Processing data with reducers
Summary
Chapter 19: Metaprogramming with Macros
Understanding the reader
Reading and evaluating code
Quoting and unquoting code
Transforming code
Summary
Chapter 20: Composing Transducers
Understanding transducers
Comparing transducers and reducers
Transducers in action
Summary
Chapter 21: Exploring Category Theory
Demystifying category theory
Using monoids
Using functors
Using applicative functors
Using monads
Summary
Chapter 22: Programming with Logic
Diving into logic programming
Thinking in logical relations
Summary
Chapter 23: Leveraging Asynchronous Tasks
Using channels
Using actors
Summary
Chapter 24: Reactive Programming
Reactive programming with fibers and dataflow variables
Using Reactive Extensions
Using functional reactive programming
Building reactive user interfaces
Introducing Om
Summary
Chapter 25: Testing Your Code
Writing tests
Testing with specs
Generative testing
Testing with types
Summary
Chapter 26: Troubleshooting and Best Practices
Debugging your code
Logging errors in your application
Thinking in Clojure
Summary

What You Will Learn

  • Understand tools for the Clojure world and how they relate to Java tools and standards (such as Maven)
  • Write simple multicore programs using Clojure’s core concepts, such as atoms, agents, and refs
  • Get to grips with Clojure’s concurrency and state-management primitives in depth
  • Analyze latency using the Criterium library
  • Avoid reflection and boxing with type hints
  • Maximize the impact of parallelization, functional composition, and process transformation by composing reducers and transducers
  • Modify and add features to the Clojure language using macros
  • Test your code with unit tests, specs, and type checks to write testable code
  • Troubleshoot and style your Clojure code to make it more maintainable

Authors

Table of Contents

Chapter 1: Getting Started with Clojure
Getting to know Clojure
Installing Leiningen
Using a REPL
Creating a new project
Using Cursive Clojure
Getting started with Clojure code and data
Clojure's data types
Summary
Chapter 2: Namespaces, Packages, and Tests
Namespaces in Clojure
The classpath and the classloader
Testing in Clojure
Summary
Chapter 3: Interacting with Java
Using Maven dependencies
Clojure interop syntax
Writing a simple image namespace
Writing the tests
Destructuring in Clojure
Exposing your code to Java
Proxy and reify
Summary
Chapter 4: Collections and Functional Programming
Basics of functional programming
Persistent collections
Types of collections in Clojure
The sequence abstraction
Specific collection types in Clojure
Summary
Chapter 5: Multimethods and Protocols
Polymorphism in Java
Multimethods in Clojure
Protocols in Clojure
Summary
Chapter 6: Concurrency
Using your Java knowledge
The Clojure model of state and identity
Promises
Futures
Software transactional memory and refs
Atoms
Agents
core.async
Summary
Chapter 7: Macros in Clojure
Lisp's foundational ideas
Macros as code modification tools
Writing your first macro
Debugging your first macro
Macros in the real world
References
Summary
Chapter 8: Performance by Design
Use case classification
A structured approach to the performance
The performance vocabulary
The latency numbers that every programmer should know
Summary
Chapter 9: Clojure Abstractions
Non-numeric scalars and interning
Identity, value, and epochal time model
Persistent data structures
Sequences and laziness
Transducers
Transients
Performance miscellanea
Summary
Chapter 10: Leaning on Java
Inspecting the equivalent Java source for Clojure code
Numerics, boxing, and primitives
Arrays
Reflection and type hints
Using array/numeric libraries for efficiency
Resorting to Java and native code
Summary
Chapter 11: Host Performance
The hardware
The Java Virtual Machine
Measuring latency with Criterium
Summary
Chapter 12: Concurrency
Low-level concurrency
Atomic updates and state
Asynchronous agents and state
Coordinated transactional ref and state
Dynamic var binding and state
Validating and watching the reference types
Java concurrent data structures
Concurrency with threads
Clojure parallelization and the JVM
Parallelism with reducers
Summary
Chapter 13: Measuring Performance
Performance measurement and statistics
Performance testing
Performance monitoring
Profiling
Summary
Chapter 14: Performance Optimization
Project setup
Identifying performance bottlenecks
Profiling code with VisualVM
The Monitor tab
Performance tuning
Summary
Chapter 15: Application Performance
Choosing libraries
Logging
Data sizing
Resource pooling
I/O batching and throttling
Precomputing and caching
Concurrent pipelines
Applying back pressure
Performance and queueing theory
Summary
Chapter 16: Working with Sequences and Patterns
Defining recursive functions
Thinking in sequences
Working with pattern matching
Summary
Chapter 17: Orchestrating Concurrency and Parallelism
Managing concurrent tasks
Managing state
Executing tasks in parallel
Summary
Chapter 18: Parallelization Using Reducers
Using reduce to transform collections
Using fold to parallelize collections
Processing data with reducers
Summary
Chapter 19: Metaprogramming with Macros
Understanding the reader
Reading and evaluating code
Quoting and unquoting code
Transforming code
Summary
Chapter 20: Composing Transducers
Understanding transducers
Comparing transducers and reducers
Transducers in action
Summary
Chapter 21: Exploring Category Theory
Demystifying category theory
Using monoids
Using functors
Using applicative functors
Using monads
Summary
Chapter 22: Programming with Logic
Diving into logic programming
Thinking in logical relations
Summary
Chapter 23: Leveraging Asynchronous Tasks
Using channels
Using actors
Summary
Chapter 24: Reactive Programming
Reactive programming with fibers and dataflow variables
Using Reactive Extensions
Using functional reactive programming
Building reactive user interfaces
Introducing Om
Summary
Chapter 25: Testing Your Code
Writing tests
Testing with specs
Generative testing
Testing with types
Summary
Chapter 26: Troubleshooting and Best Practices
Debugging your code
Logging errors in your application
Thinking in Clojure
Summary

Book Details

ISBN 139781787129597
Paperback565 pages
Read More

Read More Reviews