Repl-Driven Development in Clojure
- Tired of long compile times?
- Sick of losing your state when you reload your server?
- Wish you could get into deep flow while you're programming?
Instead, imagine if you:
- Recompiled only what changed—even as small as a single function
- Never restarted your server so the state is never lost
- Got rich, frequent feedback from a live, running system
All of that is possible with Clojure, when you use Repl-Driven Development.
Clojure was built, first and foremost, to be dynamic. It was designed for a very interactive coding style where you are continuously evaluating code at the repl. This syle of programming is called Repl-Driven Development, and it's one of the superpowers of Clojure.
This course teaches the mindset, practices, and tools of Repl-Driven Development.
Repl-Driven Development is not a specific process. It is an idea—that programming should be a process of interacting with and modifying a live system. You don't bundle up your whole application and send it to the computer for processing. Instead, you are in a continuous conversation about your problem domain. The end result, when you do it right, is a deep state of flow and engagement with your software.
Repl-Driven Development is a set of tools and techniques that support this idea. The tools come from your editors and Clojure itself. And the techniques are ways of evaluating code and working with the dynamic runtime. We go over all of that in this course.
Who is this course for?
This course is for anyone who has wanted to write better code and have more fun. Throughout the course, we dive deep into important topics like:
- the evaluation semantics of Clojure—which is designed specifically for Repl-Driven Development (RDD)
- the three keybindings you need for RDD—which are available in the top Clojure IDEs
- guidelines for what to evaluate, when
- how to maintain flow while you're programming
- dealing with common problems you may encounter
- how to run a Clojure repl even in Java projects
- navigating namespaces
- setting up your project for RDD
- using the repl to explore large amounts of data
Repl-Driven Development in Clojure
Want this course?
Love it or leave it guarantee
If you don't learn as much from this course as you thought, just ask for a refund within 30 days and I'll give you your money back.
1. What is Repl-Driven Development?
Repl-Driven Development is a set of tools and practices for programming that emphasize fast and rich feedback. The term is used interchangeably with interactive programming.
2. The mental switch to Repl-Driven Development - Batch vs interactive programming
The mindset of Repl-Driven Development is different from what you find in most languages. It turns out that the split happened long ago. It's instructive to go back in time and understand why the split happened and what the differences are.
3. All about Flow
Flow is a mental state where we feel totally immersed in our activity. We feel deep enjoyment and are energized by it. It's the state the repl-driven programming promises us. In this lesson, we look at Flow, its benefits, and what is needed to maintain it.
4. A map of the Repl-Driven Development territory
We take a look at an idealized model of the development process so that we can understand all of the places where we can make tools and practices to improve our development workflow.
5. Example of Repl-Driven Development
This lesson shows an in-depth example of repl-driven development. We start a new project to parse and analyze an unknown CSV file. By taking small steps at the REPL, we develop a program to parse the CSV. We test each step at the repl before moving on, and interactively expand the program. At the end, we have a program to parse it, and we have tested everything carefully along the way.
6. Clojure execution semantics
When you're developing in Clojure, you're interacting with a live system. You are in control, so you need to understand how the Clojure system works under the hood. In this lesson, we go over how Clojure executes code one expression at a time, how namespaces and Vars work, and how files can get out of sync with the runtime.
7. Compiling and executing code from your Clojure editor
Compiling code quickly with a keystroke is the fundamental skill for Repl-Driven Development. Other skills are based on this one. That's why we're talking about it so early in the course. It's one of the skill that you might not have when coming from another language. We go over three main ways to compile code in your files.
8. Starting a Basic REPL Workflow
Whenever we get started with a development session for the day, we want to get the REPL set up right away so that we can start Repl-Driven Development. Otherwise, we risk derailing our flow since we'll have to interrupt ourselves to start the Repl later. This lesson goes over the habits and practices of starting an RDD session.
9. Coding interactively at the Repl
Repl-Driven Development is all about breaking up a coding problem into small chunks so that you are always balancing challenge and skill level. In this lesson, I demonstrate 2 techniques for building up a function iteratively, with small changes each time.
10. Guidelines for Repl-Driven Development
In this lesson, we go over 7 guidelines you should keep in mind when doing Repl-Driven Development.
11. Ergonomics - Tools to write code
In this lesson, we go over three tools to help you write and modify code faster. These are autocomplete, brace matching, and visual argument prompts. You may be familiar with these tools, but it's important to think of them as options.
12. Structural editing - Tools to write code
In this lesson, we go over four different modes for structural editing, along with my recommendations for what you should use.
13. Testing code with the Repl
We want to quickly test our code to get valuable and fast feedback on how we are progressing toward our goals. In this lesson, I go over three ways of running tests: automated tests at a keystroke, testing at the Repl using the Repl history, and tests saved in comment blocks.
14. Dealing with errors
In this lesson, we go over how you can interact with errors at the Repl to print only the information you need.
15. println debugging
println debugging has a long tradition. It's a great way to quickly pinpoint problems in your code. It lets you figure out where the bug is, and also surface intermediate values that can help you understand what's going on. In this lesson, we talk about how to do println debugging in Clojure, including the 3 types of printing, 3 tricks for embedding printlns in your code, and a cool other way to surface the value that is causing an error.
16. Scientific debugging
Scientific debugging might also be called "repl-driven debugging". It's basically executing expressions from your program at the repl to pinpoint the source of a problem. You form a hypothesis (a guess about where the bug is), do an experiment (run an expression), and analyze the results.
17. Keeping code in sync
When you're doing Repl-Driven Development, your repl and the code in your files can get out of sync. The first step is to diagnose whether it is the code or your repl that is broken. Once diagnosed, the fixes are usually straightforward. Either way, it can be frustrating, but knowing is half the battle.
18. Controlling namespace reloading with defonce
We want to be able to reload namespaces at will. But if there are some defs that we can't reload, we won't be able to reload. Hence, we need to control those few times when we don't want to reload code each time. There are three situations where we might not want to reload. In this lesson, we go over those three, with some options.
19. Printing values and controlling printing
Values are one of the primary ways we get feedback that our code is correct. In this lesson, we go over 5 ways to print and two knobs you have to control printing.
20. Playing with values at the repl
We go over three tips for working with values directly at the repl.
21. Navigating namespaces at the repl
When you're connected to a repl without an IDE, you'll need to find your way around to different namespaces. In this lesson, we go over commands for viewing the current namespace, understanding what's in it, requiring new namespaces, changing namespaces, and removing namespaces.
22. Interactive documentation
Clojure gives you some tools for learning about what functions and variables are available in the loaded namespaces. You can look up their documentation and their source code.
23. Running a Clojure repl in a Java application
One of the cool things about Clojure is that it is hosted. That means it has access to the underlying platform in intimate ways. One thing you can do with that is run a Clojure repl inside of your JVM. You have access to all of the JVM stuff, but through a language that is more conducive to interactive programming. In this lesson, we look at four ways of running a repl you can connect to. Two ways are within Java projects themselves.
24. Editing servers and other long-running processes
We are often editing a web server or some process that is meant to run for a long time. We want to be able to RDD those as well. In this lesson, we go over some tips and techniques for editing these so we don't have to restart all the time.
25. Some reloading tools some people use
clojure.tools.namespace is for automatically reloading code, and Component, mount, and Integrant are tools for managing the lifecycles and configuration of stateful or side-effecting resources you need to load at application startup. Some people use these tools to help them. In this lesson, I go over each of the tools, what problem they are trying to solve, and how they differ.