PurelyFunctional.tv Newsletter 332: Tool: jEnv

Sign up for weekly Clojure tips, software design, and a Clojure coding challenge.

Issue 332 - June 24, 2019 · Archives · Subscribe

JVM Tool 🔨


The JVM has always been a very stable platform, and releases were seldom. You could get away with running a single version of Java for years. That's no longer the case. Java 9 introduced some breaking changes, so many people are running Java 8 in production, past the end of life date. And Oracle now releases new JDK versions every 6 months.

I write software that has to run on my customers' machines, and I can't really control what version of the JDK they have. Recently, I've found myself installing and switching between multiple JDK builds so I could test out all of the combinations. Somewhere in there, I discovered a tool called jEnv. It lets you switch between different JDKs.

You can set the JDK globally, to enable a default JDK. You can set the JDK for a specific directory, for a per-project JDK. And you can set the JDK for the running shell instance, if you need to test a project in a different JDK from the per-project setting. It's quite nice to have the ability to quickly switch between your installed JDKs.

Clojure Media 🍿

A couple of great Clojure talks have popped up on my radar recently.

Reitit, the Ancient Art of Routing by Tommi Reiman was a cool romp through the internals of Reitit, Metosin's routing library. They've spent the time to make it super fast. The numbers he was showing were competitive with go's router, which is very impressive. He was also encouraging that Clojure could create a very fast stack from curated libraries.

Crawling Inside the Tauntaun by James Cash was an adventure deep into the bowls of Clojure. It was nice to hear some of the hard truths of debugging.

There were lots of other great talks at Clojure/north. Check them out.

Brain skill 😎

Make it social.

It's funny how differently we think about people vs about symbols, even when the problems are equivalent. Having trouble with a hairy conditional? Instead of doing the logical negation and conjunctions in your head, try to imagine a person saying it. If the person is telling the truth, it's true. If they are lying, it's false. It's crazy how that works, but it does. Our brains must have logical engines that only work to check people's stories, but turn off if we're trying to actually do logic!

Clojure Challenge 🤔

Last week's challenge

The puzzle in Issue 331 was to come up with ways to generate sorted lists.

I got some great submissions. You can check them out here.

Some notable ones:

  1. Generate a random initial number and a sequence of positive numbers. As you add the positive numbers to the initial number, it generates a sequence of numbers that only get bigger.
  2. Similarly, you could generate a random sorted sequence of strings by appending a random character to the end of the last element.
  3. Apply any monotonic function to an already sorted list, such as the sequence of natural numbers. For example, map square root over (range 100). It's not exactly random, but you could select a random slice from that.

I think the creative juices flowed nicely on this one.

This week's challenge


Two words are anagrams of each other if they have the same letters but in different orders.

This week's challenge is a two-parter.

  1. Write a function to determine if two words are anagrams.
  2. Given a dictionary of words (such as this one), find all of the anagrams for a target word.

Bonus points for efficiency.

As usual, please send me your answers. I'll share them all in next week's issue. If you send me one, but you don't want me to share it publicly, please let me know.

Rock on!
Eric Normand