Preface
Introduction
Who This Book Is For
How to Use This Book
What This Book Is Not
A Note on Versions
About the Author
Chapter 1: Getting Started
Installing Clojure
The REPL
Creating a New Project
The -main Function
println — Clojure’s puts
String Formatting with str and format
Functions
Defining Functions
Parameters
Return Values
Variadic Functions
Leiningen Commands Cheat Sheet
Chapter Exercises
Summary
Chapter 1 Quiz
3 attempts allowed
Chapter 2: Syntax and Data Literals
S-Expressions
Numbers
Strings and Characters
Keywords
Symbols
Lists
Vectors
Maps
Sets
Homoiconicity: Code Is Data
Try It Yourself
Chapter Exercises
Summary
Chapter 2 Quiz
3 attempts allowed
Chapter 3: Immutability and Persistent Data Structures
Persistent Data Structures
Core Operations
Vectors
Maps
Sets
Why Immutability Matters
Transients: Escape Hatch for Performance
Let Bindings
Threading Macros
Try It Yourself
Chapter Exercises
Summary
Chapter 3 Quiz
3 attempts allowed
Chapter 4: Functions
defn — Named Functions
Multi-Arity Functions
Variadic Functions
Anonymous Functions
Higher-Order Functions
Functions That Return Functions
Closures
juxt — Apply Multiple Functions
some-fn and every-pred
Try It Yourself
Chapter Exercises
Summary
Chapter 4 Quiz
3 attempts allowed
Chapter 5: Control Flow
if and when
Truthiness
cond — Multi-Way Branching
do — Grouping Expressions
loop / recur — Iteration Without Mutation
for — List Comprehension
doseq and dotimes — Side Effects Only
some and every? — Existential Checks
Try It Yourself
Chapter Exercises
Summary
Chapter 5 Quiz
3 attempts allowed
Chapter 6: Namespaces and Code Organization
ns — The Namespace Declaration
:require — Loading Clojure Namespaces
Creating a Namespace
:import — Java Classes
The Classpath
require vs use vs refer
Reloading Code
project.clj vs deps.edn
Try It Yourself
Chapter Exercises
Summary
Chapter 6 Quiz
3 attempts allowed
Chapter 7: Sequences and Laziness
The Seq Abstraction
map, filter, reduce — The Big Three
map
filter and remove
reduce
The Rest of the Toolkit
take, drop, take-while, drop-while
partition, partition-by
group-by, frequencies
sort, sort-by
distinct, interleave, interpose
Sequences on Maps
Sequences on Strings
Lazy Sequences
Realizing Lazy Sequences
The Threading Macros Revisited
Try It Yourself
Chapter Exercises
Summary
Chapter 7 Quiz
3 attempts allowed
Chapter 8: Destructuring
Vector Destructuring
Map Destructuring
Renaming Keys
Nested Destructuring
Destructuring in Function Parameters
Destructuring in let and loop
Destructuring in for
Real-World Example: Parsing API Responses
Try It Yourself
Chapter Exercises
Summary
Chapter 8 Quiz
3 attempts allowed
Chapter 9: Java Interop
Why Java Interop Matters
Calling Methods
Instance Methods
Static Methods
Chaining Methods with ..
Creating Objects
doto — Mutating a Java Object
Static Fields and Enums
Type Hints for Performance
Arrays
Importing Java Classes
Real Examples
File I/O
HTTP with clj-http
Database Access with JDBC
Try It Yourself
Chapter Exercises
Summary
Chapter 9 Quiz
3 attempts allowed
Chapter 10: Concurrency and State
The Identity/Value Separation
Atoms — Independent, Synchronous State
Refs and Software Transactional Memory (STM)
Agents — Asynchronous Updates
Vars and Dynamic Binding
Futures and Promises
core.async — Channels and Go Blocks
Choosing the Right Reference Type
Try It Yourself
Chapter Exercises
Summary
Chapter 10 Quiz
3 attempts allowed
Chapter 11: Macros and Metaprogramming
Why Macros?
Syntax Quoting, Unquote, and Unquote-Splicing
Writing Your First Macro
Debugging Macros
Auto-Gensym for Hygiene
Common Macro Patterns
Defining things at compile time
Threading with side effects
Conditional evaluation
When NOT to Use Macros
Macros vs Ruby Metaprogramming
Try It Yourself
Chapter Exercises
Summary
Chapter 11 Quiz
3 attempts allowed
Chapter 12: Building a Project
The Project: bkmrk
Project Setup
The Data Model
Persistence
Command Handling
CLI Entry Point
Testing
Building and Running
The REPL-Driven Workflow in Practice
Project Structure Recap
Try It Yourself
Chapter Exercises
Summary
Chapter 12 Quiz
3 attempts allowed
Final Exam
Final Exam
2 attempts allowed
Appendix A: Resources
Official Documentation
Books
Online Learning
Editor Support
Libraries Worth Knowing
Community
Staying in Touch with Ruby
Appendix B: Exercise Answers
Chapter 1: Getting Started
Exercise 1
Exercise 2
Exercise 3
Chapter 2: Syntax and Data Literals
Exercise 1
Exercise 2
Exercise 3
Chapter 3: Immutability and Persistent Data Structures
Exercise 1
Exercise 3
Chapter 4: Functions
Exercise 1
Exercise 3
Chapter 5: Control Flow
Exercise 1 — FizzBuzz
Exercise 2 — Collatz
Chapter 6: Namespaces and Code Organization
Exercise 1 — Three namespaces
Chapter 7: Sequences and Laziness
Exercise 1 — Running sum
Exercise 2 — Words by length
Chapter 8: Destructuring
Exercise 1 — User summary
Exercise 2 — Winner
Chapter 9: Java Interop
Exercise 1 — File extension
Exercise 3 — Directory listing
Chapter 10: Concurrency and State
Exercise 1 — Hit counter
Exercise 4 — Producer-consumer with core.async
Chapter 11: Macros and Metaprogramming
Exercise 1 — defn-logged
Exercise 4 — Mini testing DSL
Chapter 12: Building a Project
Exercise 1 — Remove command
Exercise 4 — Sort option
Glossary
Acknowledgements
Credits
From Ruby to Clojure: The Course
Think functionally: move from Ruby objects to Clojure's immutable data and REPL-driven code.
Make the jump from Ruby to Clojure and functional programming, one idiom at a time. Quizzes after every chapter and a final exam earn a certificate.
Minimum price
$149
$149
You pay
Author earns
About
About the Course
From Ruby to Clojure
Think functionally: move from Ruby objects to Clojure's immutable data and REPL-driven code.
What You'll Learn
✔ Read Clojure syntax and data literals
✔ Work with immutable, persistent data structures
✔ Write functions and control flow
✔ Organize code with namespaces
✔ Use sequences and laziness
✔ Destructure data
✔ Call Java and manage concurrency and state
✔ Write macros and build a project
Who Is This Course For?
Ruby developers curious about functional programming and the JVM.
Prerequisites
Solid Ruby experience. No Lisp or Java experience needed.
Why This Course?
The shift from objects to data is made step by step from Ruby code you recognise, ending in a complete project.
How It Works
- 12 chapters, each ending with a 5-question multiple-choice quiz (3 attempts, best score counts)
- A 20-question final exam covering the whole course
- 80 quiz questions in total
- Score 70% to pass; 85% or more earns honors
- Pass to receive a certificate of completion
Written by Joel Bryan Juliano.
This course is included in this track...
Instructor
About the Instructor
Hi, I'm Joel.
I am Dutch-Filipino Software Engineer with 20+ years of experience.
And with over 20 years in the game, I’ve seen it all and loved every minute of it.
My journey has taken me through a variety of industries, from sports streaming to cybersecurity, both in the private sector and for the Dutch government, and everything in between.
Along the way, I’ve picked up a diverse set of skills and experiences, in which I document into books.
Material
Course Material
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.
