PurelyFunctional.tv Newsletter 391: the immediacy interval

Issue 391 - August 17, 2020 · Archives · Subscribe

Clojure Tip 💡

the immediacy interval

How fast is instantaneous? How alive is your live coding? How far are you from seeing the effect of a change in code? If it is easy and fast to run our code, we will run it more. This leads to faster, more stable progress toward working code.

When I'm doing REPL-driven development well, things feel instantaneous. I make a change to a function, I hit a few keystrokes, and I see the effect of the change. Yes, it feels nice that things are fast. And speed in development is good. But that's just the first-order effect. The magic of it comes in the second-order effects.

The magic is that, now that it's faster, I can do it more times. I can do it more frequently. I can know sooner and with more confidence whether I'm on the right track. I can relax more easily, knowing that the code is behaving as expected. I make fewer mistakes and spend less time figuring out where a mistake is.

I've programmed in some systems that were very fast to see the changes. But somehow, they weren't fast enough to encourage me to do it more. For example, I can remember times where I wanted to try just one more thing. But I didn't try it because I anticipated too much time and pain to do it. We want to be so fast that we will surely try just one more thing.

REPL-driven development is work to get right. It's work from the language and it's work from you, the programmer. Clojure does a huge amount of lifting to get RDD working. The rest is up to you. But even in Clojure, it's not automatic.

In my REPL-driven development course, I break down the development process into a series of steps. Then we systematically address each one to make it fast and easy. You can see the map of the development process here. I've made that lesson temporarily free to everyone. Here is the breakdown:

  1. Write/modify c ode
  2. Compile
  3. Test
  4. Check if it works; if yes, work on the next thing; if no, analyze and go back to Step 1

Much of the course is structured around this breakdown. There are lessons showing how to write and modify code faster and easier (Step 1). There are lessons about how to test code quickly (Step 3). There are lessons about printing values to check them more easily (Step 4). And there is a lesson teaching the 3 commands you need for compiling code (Step 2). I'd like to talk about those next week.

Quarantine update 😷

I know a lot of people are going through tougher times than I am. If you, for any reason, can't afford my courses, and you think the courses will help you, please hit reply and I will set you up. It's a small gesture I can make, but it might help.

I don't want to shame you or anybody that we should be using this time to work on our skills. The number one priority is your health and safety. I know I haven't been able to work very much, let alone learn some new skill. But if learning Clojure is important to you, and you can't afford it, just hit reply and I'll set you up. Keeping busy can keep us sane.

Also, if you just want to subscribe for a paid membership, I have opened them back up for the moment. Register here.

Stay healthy. Wash your hands. Stay at home. Wear a mask. Take care of loved ones.

Clojure Challenge 🤔

Last week's challenge

The challenge in Issue 390 was to create expressions to express the prime factorization of a number. You can find the submissions here.

Please do participate in the discussion on the gist where the submissions are hosted. It's active and it's a great way to get comments on your code.

This week's challenge

Powers in range

Let's say you have an inclusive range of integers [a, b]. You also have an exponent n. What numbers k^n (integer k raised to the nth power) occur in that range? Write a function that takes a, b, and n and returns the numbers k^n.


;; n = 2, [a, b] = [49, 65]
(powers-in-range 2 49 65) ;=> [49 64] ;; that is, 7^2 and 8^2
;; n = 3, [a, b] = [1, 27]
(powers-in-range 3 1 27) ;=> [1 8 27] ;; 1^3, 2^3, and 3^3
;; n = 10, [a, b] = [1, 5]
(powers-in-range 10 1 5) ;=> [1] ;; 1^10

Thanks to this site for the challenge idea where it is considered Hard level in Python.

You can also find these same instructions here. I might update them to correct errors and clarify the descriptions. That's also where submissions will be posted. And there's a great discussion!

As usual, please reply to this email and let me know what you tried. I'll collect them up and share them in the next issue. If you don't want me to share your submission, let me know.

Rock on!
Eric Normand