r/Clojure • • Dec 05 '23

Why is Jepsen Written in Clojure?

https://aphyr.com/posts/367-why-is-jepsen-written-in-clojure
74 Upvotes

5 comments sorted by

9

u/ares623 Dec 06 '23

A wild Rich Hickey appears!

5

u/elflorduser Dec 05 '23 edited Dec 05 '23

Some aspects of the polymorphism system are lacking, but these can be worked around with libraries.

What does he means by this?

5

u/[deleted] Dec 06 '23

This comes up fairly infrequently, but I hit it every year or so: there are cases where you really, really want inheritance, and Clojure’s protocol/interface/deftype system are set up to fight you. For instance, take implementing a new variant of Clojure’s core map, vector, or set datatypes. There’s a gazillion functions you have to implement across a dozen interfaces+protocols. Most of them would be sensibly implemented by proxying to another function, or simply add default arguments to a more complete version of the function. In Java you’d inherit from an abstract class, or use default methods in the interfaces. But there’s no real equivalent for this in Clojure.

I wind up using Zach Tellman’s Potemkin a good deal for this–both for defining collections and for its abstract inheritance scheme. Here’s an example from jepsen.history, which implements several flavors of vector with different memory/laziness semantics.

1

u/heystatue Dec 07 '23

Jepsen looks immensely cool. Interestingly enough, Nathan Martz in the recent JuxtCast hasn't mentioned using it for testing Rama and testing distributed systems was covered quite a bit.