Book Image

Hands-On Reactive Programming with Clojure - Second Edition

By : Konrad Szydlo, Leonardo Borges
Book Image

Hands-On Reactive Programming with Clojure - Second Edition

By: Konrad Szydlo, Leonardo Borges

Overview of this book

Reactive Programming is central to many concurrent systems, and can help make the process of developing highly concurrent, event-driven, and asynchronous applications simpler and less error-prone. This book will allow you to explore Reactive Programming in Clojure 1.9 and help you get to grips with some of its new features such as transducers, reader conditionals, additional string functions, direct linking, and socket servers. Hands-On Reactive Programming with Clojure starts by introducing you to Functional Reactive Programming (FRP) and its formulations, as well as showing you how it inspired Compositional Event Systems (CES). It then guides you in understanding Reactive Programming as well as learning how to develop your ability to work with time-varying values thanks to examples of reactive applications implemented in different frameworks. You'll also gain insight into some interesting Reactive design patterns such as the simple component, circuit breaker, request-response, and multiple-master replication. Finally, the book introduces microservices-based architecture in Clojure and closes with examples of unit testing frameworks. By the end of the book, you will have gained all the knowledge you need to create applications using different Reactive Programming approaches.
Table of Contents (15 chapters)

What this book covers

Chapter 1, What is Reactive Programming?, starts by guiding you through a compelling example of a reactive application written in ClojureScript. It then takes you on a journey through the history of Reactive Programming, during which some important terminology is introduced, setting the tone for the following chapters.

Chapter 2, A Look at Reactive Extensions, explores the basics of this Reactive Programming framework. Its abstractions are introduced, and important subjects such as error handling and back pressure are discussed.

Chapter 3, Asynchronous Programming and Networking, walks you through building a stock market application. It starts by using a more traditional approach and then switches to an implementation based on Reactive Extensions, examining the trade-offs between the two.

Chapter 4, Introduction to core.async, describes core.async, a library for asynchronous programming in Clojure. Here, you learn about the building blocks of communicating sequential processes and how reactive applications are built with core.async.

Chapter 5, Creating Your Own CES Framework with core.async, embarks on the ambitious endeavor of building a CES framework. It leverages knowledge gained in the previous chapter and uses core.async as the foundation for the framework.

Chapter 6, Building a Simple ClojureScript Game with Reagi, showcases a domain where reactive frameworks have been used to great effect in games development.

Chapter 7, The UI as a Function, shifts gears and shows how the principles of functional programming can be applied to web UI development through the lens of Om, a ClojureScript binding for Facebook's React.

Chapter 8, A New Approach to Futures, presents futures as a viable alternative to some classes' reactive applications. It examines the limitations of Clojure futures and presents an alternative: imminent, a library of composable futures for Clojure.

Chapter 9, A Reactive API to Amazon Web Services, describes a case study taken from a real project, where a lot of the concepts introduced throughout this book have been put together to interact with a third-party service.

Chapter 10, Reactive Microservices, introduces you to microservices, showing when using them gives an advantage over monolithic application design. Next, you see a working example of an API microservice written in Clojure.

Chapter 11, Testing Reactive Apps, explores various testing methodologies and introduces four Clojure unit testing frameworks.

Chapter 12, Concurrency Utilities in Clojure, explains why most object-oriented languages are not suited for multi-threaded programming and how Clojure can help developers. Finally, it walks you through available concurrency tools in Clojure.

Appendix, The Algebra of Library Design, introduces concepts from category theory that are helpful in building reusable abstractions. The appendix is optional and won't hinder learning in the previous chapters. It presents the principles used in designing the futures library seen in Chapter 8, A New Approach to Futures.