
The Clojure Workshop
A New, Interactive Approach to Learning Clojure
- 800 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
The Clojure Workshop
A New, Interactive Approach to Learning Clojure
About this book
Learn how to solve problems using Clojure or ClojureScript and become a confident functional programmer with the help of engaging activities and challenging projects
Key Features
- Master the tools and patterns of the Clojure and ClojureScript ecosystems
- Learn the fundamentals of functional programming and immutability
- Apply your skills practically by developing a range of scalable applications
Book Description
The Clojure Workshop is a step-by-step guide to Clojure and ClojureScript, designed to quickly get you up and running as a confident, knowledgeable developer.
Because of the functional nature of the language, Clojure programming is quite different to what many developers will have experienced. As hosted languages, Clojure and ClojureScript can also be daunting for newcomers because of complexities in the tooling and the challenge of interacting with the host platforms. To help you overcome these barriers, this book adopts a practical approach. Every chapter is centered around building something.
As you progress through the book, you will progressively develop the 'muscle memory' that will make you a productive Clojure programmer, and help you see the world through the concepts of functional programming. You will also gain familiarity with common idioms and patterns, as well as exposure to some of the most widely used libraries.
Unlike many Clojure books, this Workshop will include significant coverage of both Clojure and ClojureScript. This makes it useful no matter your goal or preferred platform, and provides a fresh perspective on the hosted nature of the language.
By the end of this book, you'll have the knowledge, skills and confidence to creatively tackle your own ambitious projects with Clojure and ClojureScript.
What you will learn
- Write idiomatic code with Clojure and ClojureScript
- Understand and use common patterns and best practices
- Experiment with code and interact with programs using the REPL
- Learn the fundamentals of functional programming and immutability
- Master concepts including mapping, filtering, reducing and recursion
- Structure and build your code using namespaces and Leiningen
- Write unit tests to validate application behavior
- Simplify your code and improve efficiency with macros
Who this book is for
The Clojure Workshop is for anyone who is curious about functional programming and wants to get started learning Clojure or ClojureScript. Prior experience of another programming language, such as Java or JavaScript, is recommended, and will help you grasp the concepts covered in this book more easily.
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Information
1. Hello REPL!
Introduction
REPL Basics
Exercise 1.01: Your First Dance
- Open Terminal and type clj. This will start a Clojure REPL:$ cljThe output is as follows:Clojure 1.10.1user=>The first line is your version of Clojure, which in this example is 1.10.1. Don't worry if your version is different—the exercises we will go through together should be compatible with any version of Clojure.The second line displays the namespace we are currently in (user) and prompts for your input. A namespace is a group of things (such as functions) that belong together. Everything you create here will be in the user namespace by default. The user namespace can be considered your playground.Your REPL is ready to read.
- Let's try to evaluate an expression:user=> "Hello REPL!"The output is as follows:"Hello REPL!"In Clojure, literal strings are created with double quotes, "". A literal is a notation for representing a fixed value in source code.
- Let's see what happens if we type in multiple strings:user=> "Hello" "Again"The output is as follows:"Hello""Again"We have just evaluated two expressions sequentially, and each result is printed onto separate lines.
- Now, let's try a bit of arithmetic, for example, 1 + 2:user=> 1 + 2The output is as follows:1#object[clojure.core$_PLUS_ 0xe8df99a "clojure.core$_PLUS_@e8df99a"]2The output is not exactly what we expected. Clojure evaluated the three components, that is, 1, +, and 2, separately. Evaluating + looks strange because the + symbol is bound to a function.NoteA function is a unit of code that performs a specific task. We don't need to know more for now except that fu...
Table of contents
- Preface
- 1. Hello REPL!
- 2. Data Types and Immutability
- 3. Functions in Depth
- 4. Mapping and Filtering
- 5. Many to One: Reducing
- 6. Recursion and Looping
- 7. Recursion II: Lazy Sequences
- 8. Namespaces, Libraries and Leiningen
- 9. Host Platform Interoperability with Java and JavaScript
- 10. Testing
- 11. Macros
- 12. Concurrency
- 13. Database Interaction and the Application Layer
- 14. HTTP with Ring
- 15. The Frontend: A ClojureScript UI
- Appendix