r/Clojure • • Jun 03 '21

Tour of our 250k line Clojure codebase - Red Planet Labs

https://tech.redplanetlabs.com/2021/06/03/tour-of-our-250k-line-clojure-codebase/
95 Upvotes

15 comments sorted by

20

u/halgari Jun 03 '21

I'd love to actually see the code. Having attempted some of these goals in other language and runtimes, I'm interested in seeing how it works out in Clojure.

9

u/alexanderjamesking Jun 04 '21

Thanks for writing this up, it was an interesting read.

static type checks wouldn’t be able to check all the kinds of constraints we define using Schema anyway (e.g. the value of a number being within a certain range) - you can do exactly this in languages with refined types, whether it’s a good thing to have this is another debate, I prefer to handle this at runtime with spec/schema.

I’m always hesitant to use with-redefs, especially when it comes to code running on separate threads (see https://widdindustries.com/with-redefs-problems/). I prefer to pass dependencies in and be explicit, and making use of partial to pass around functions pre loaded with their dependencies, then there is no need to override or redefine anything.

I’d love to see another blog post on your language within a language, and the use of continuations.

4

u/emacs-noob Jun 04 '21

Excellent writeup. Lots of fascinating ideas to chew on here. I was skeptical at first about how you inject no-op functions into source code to later override with with-redefs, but seeing your example and thinking about it a little bit I've come to really like the approach!

1

u/n__sc Jun 06 '21

I thought the same, I‘d never thought of using with-redefs this way. Seems great to enable some kinds of testability „after the fact“; you only have to think of some checkpoints and their names while developing, and have at least a modicum of assertions to make.

3

u/I_LIKE_FACE_TATTOOS Jun 04 '21

Thanks for sharing! Do you mind explaining why you're using both Leiningen and deps.edn?

3

u/boisdeb Jun 04 '21

I can't speak for them, but one common reason is that a project starts with leiningen but then deps.edn ability to declare a local folder as a dependency is too good to pass and so they add it only for classpass management.

3

u/nathanmarz Jun 04 '21

We have a small amount of Java source code and deps.edn local targets don't understand that. So Java source has special handling (e.g. :java-source-paths in the project.clj for "distributed" includes "../core/src/java). It's not ideal but it meets our needs for the time being.

2

u/[deleted] Jun 04 '21

I just noticed Nathan Marz changed to red planet labs.

1

u/fnordsensei Jun 05 '21

I’m so excited to see what this will look like.

I hope the language will be at least as awesome as Clojure.

1

u/zhming0 Jun 06 '21

I'm curious how they implement first class continuation in the sub language. Is it through exception handling or co-routine via core.async.

1

u/Michaelmrose Jun 08 '21

So what features from your work are useful enough that you think Clojure as a whole would benefit from them?

1

u/Euclid556 Jul 02 '21

Awesome write up here….

0

u/[deleted] Jun 04 '21

[deleted]

5

u/nathanmarz Jun 04 '21

Yes, they do. All of our ClojureScript lives in the "webui" module, and we have a few .cljc files in both "distributed" and "webui".

2

u/ertucetin Jun 04 '21

Are you planning to open source the new language that you wrote for the project?

1

u/nathanmarz Jun 04 '21

Not anytime soon, though I'd like to one day.