Kick off your book project in 3 hours! Live workshop on Zoom. You’ll leave with a real book project, progress on your first chapter, and a clear plan to keep going. Saturday, June 6, 2026. Learn more…

Leanpub Header

Skip to main content

From Ruby to Clojure

A Ruby Programmer's Guide to Learning Clojure

This book is 100% completeLast updated on 2026-05-29

You should know Ruby. You don't need to be an expert — if you can read a Ruby class, understand blocks and Enumerable, and follow a begin/rescue block, you have what you need.

You don't need to know Clojure at all. You don't need to know Java. You don't need to know Lisp. Chapter 1 starts from zero parentheses.

Minimum price

$19.00

$29.00

You pay

Author earns

$
PDF
EPUB
WEB
About

About

About the Book

Clojure is not an object-oriented language. No classes, no mutable state, no inheritance hierarchies, no nil-safety gymnastics. If you're coming from Ruby, that sounds like a completely different world. But Clojure's approach — functions instead of methods, persistent data structures instead of mutable objects, macros instead of metaprogramming hacks, and the REPL as your constant companion — produces code that is radically simple, effortlessly concurrent, and a joy to work with.

This book is built on one idea: the fastest way for a Rubyist to learn Clojure is to map every Clojure concept back to Ruby. Each chapter starts with Ruby code you already understand, then shows the Clojure equivalent. You're not learning from scratch — you're translating.

What You'll Learn

  • Set up a Clojure project with Leiningen and master the REPL-driven workflow
  • Understand Clojure's syntax — S-expressions, prefix notation, and why everything is data
  • Work with immutable, persistent data structures (vectors, maps, sets) that share structure instead of copying
  • Write functions as first-class citizens with defn, fn, higher-order functions, comp, and partial
  • Master the seq abstraction: map, filter, reduce, and lazy evaluation
  • Use powerful destructuring in function parameters and let bindings
  • Interop with the entire Java ecosystem — every Java library is a Clojure library
  • Manage state safely with atoms, refs, agents, and core.async channels
  • Write macros that extend the language itself
  • Build and test a real Clojure project from scratch

Share this book

Categories

Author

About the Author

Joel Bryan Juliano

Hi, I'm Joel.

I am Senior 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.

Originally from the Philippines, I am now a Dutchman living in Amsterdam together with my family.

My journey has taken me through a variety of industries, from sports streaming to cybersecurity, and everything in between.

Along the way, I’ve picked up a diverse set of skills and experiences, in which I document into books.

Contents

Table of Contents

Preface

Introduction

  1. Who This Book Is For
  2. How to Use This Book
  3. What This Book Is Not
  4. A Note on Versions
  5. About the Author

Chapter 1: Getting Started

  1. Installing Clojure
  2. The REPL
  3. Creating a New Project
  4. The -main Function
  5. println — Clojure’s puts
  6. String Formatting with str and format
  7. Functions
  8. Chapter Exercises
  9. Summary

Chapter 2: Syntax and Data Literals

  1. S-Expressions
  2. Numbers
  3. Strings and Characters
  4. Keywords
  5. Symbols
  6. Lists
  7. Vectors
  8. Maps
  9. Sets
  10. Homoiconicity: Code Is Data
  11. Try It Yourself
  12. Chapter Exercises
  13. Summary

Chapter 3: Immutability and Persistent Data Structures

  1. Persistent Data Structures
  2. Core Operations
  3. Why Immutability Matters
  4. Transients: Escape Hatch for Performance
  5. Let Bindings
  6. Threading Macros
  7. Try It Yourself
  8. Chapter Exercises
  9. Summary

Chapter 4: Functions

  1. defn — Named Functions
  2. Multi-Arity Functions
  3. Variadic Functions
  4. Anonymous Functions
  5. Higher-Order Functions
  6. Closures
  7. juxt — Apply Multiple Functions
  8. some-fn and every-pred
  9. Try It Yourself
  10. Chapter Exercises
  11. Summary

Chapter 5: Control Flow

  1. if and when
  2. Truthiness
  3. cond — Multi-Way Branching
  4. do — Grouping Expressions
  5. loop / recur — Iteration Without Mutation
  6. for — List Comprehension
  7. doseq and dotimes — Side Effects Only
  8. some and every? — Existential Checks
  9. Try It Yourself
  10. Chapter Exercises
  11. Summary

Chapter 6: Namespaces and Code Organization

  1. ns — The Namespace Declaration
  2. :require — Loading Clojure Namespaces
  3. Creating a Namespace
  4. :import — Java Classes
  5. The Classpath
  6. require vs use vs refer
  7. Reloading Code
  8. project.clj vs deps.edn
  9. Try It Yourself
  10. Chapter Exercises
  11. Summary

Chapter 7: Sequences and Laziness

  1. The Seq Abstraction
  2. map, filter, reduce — The Big Three
  3. The Rest of the Toolkit
  4. Sequences on Maps
  5. Sequences on Strings
  6. Lazy Sequences
  7. The Threading Macros Revisited
  8. Try It Yourself
  9. Chapter Exercises
  10. Summary

Chapter 8: Destructuring

  1. Vector Destructuring
  2. Map Destructuring
  3. Destructuring in Function Parameters
  4. Destructuring in let and loop
  5. Destructuring in for
  6. Real-World Example: Parsing API Responses
  7. Try It Yourself
  8. Chapter Exercises
  9. Summary

Chapter 9: Java Interop

  1. Why Java Interop Matters
  2. Calling Methods
  3. Creating Objects
  4. doto — Mutating a Java Object
  5. Static Fields and Enums
  6. Type Hints for Performance
  7. Arrays
  8. Importing Java Classes
  9. Real Examples
  10. Try It Yourself
  11. Chapter Exercises
  12. Summary

Chapter 10: Concurrency and State

  1. The Identity/Value Separation
  2. Atoms — Independent, Synchronous State
  3. Refs and Software Transactional Memory (STM)
  4. Agents — Asynchronous Updates
  5. Vars and Dynamic Binding
  6. Futures and Promises
  7. core.async — Channels and Go Blocks
  8. Choosing the Right Reference Type
  9. Try It Yourself
  10. Chapter Exercises
  11. Summary

Chapter 11: Macros and Metaprogramming

  1. Why Macros?
  2. Syntax Quoting, Unquote, and Unquote-Splicing
  3. Writing Your First Macro
  4. Debugging Macros
  5. Auto-Gensym for Hygiene
  6. Common Macro Patterns
  7. When NOT to Use Macros
  8. Macros vs Ruby Metaprogramming
  9. Try It Yourself
  10. Chapter Exercises
  11. Summary

Chapter 12: Building a Project

  1. The Project: bkmrk
  2. Project Setup
  3. The Data Model
  4. Persistence
  5. Command Handling
  6. CLI Entry Point
  7. Testing
  8. Building and Running
  9. The REPL-Driven Workflow in Practice
  10. Project Structure Recap
  11. Try It Yourself
  12. Chapter Exercises
  13. Summary

Appendix A: Resources

  1. Official Documentation
  2. Books
  3. Online Learning
  4. Editor Support
  5. Libraries Worth Knowing
  6. Community
  7. Staying in Touch with Ruby

Appendix B: Exercise Answers

  1. Chapter 1: Getting Started
  2. Chapter 2: Syntax and Data Literals
  3. Chapter 3: Immutability and Persistent Data Structures
  4. Chapter 4: Functions
  5. Chapter 5: Control Flow
  6. Chapter 6: Namespaces and Code Organization
  7. Chapter 7: Sequences and Laziness
  8. Chapter 8: Destructuring
  9. Chapter 9: Java Interop
  10. Chapter 10: Concurrency and State
  11. Chapter 11: Macros and Metaprogramming
  12. Chapter 12: Building a Project

Glossary

Acknowledgements

Credits

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

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.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

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.)

In fact, authors have earned over $15 million writing, publishing and selling 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.

Learn more about writing on Leanpub