Clojure
Clojure
In the fun distraction from actually doing what I set out to do I wnted to get bakc into having a look at the alorithmic botany book and felt the experimental nature of it would benefit from being done in a more dynamic language.
Having recently done the Advent of Code in Common-Lisp I thought Clojure as one of the LISP decendents might be a good shot. To have a shot at learning it I decided to do the year before last’s advent of code (2023) in Clojure this proved to be a sufficient distraction from me actually doing what I set out to do.
I did go through most of the Advent of Code a lot quicker (and do some I didn’t manage first time around) although part of that is likely to be that I had already thought through the questions. I didnt get tot he end but I did a lot more than my run through at the time.
Clojure and CL
On Clojure and it’s comparason to Common LISP one of the main differences (at least to me) is it’s use of some extra syntax elements particularly square and curly brackets for things like hash maps and function arguments. I (as a personal preference) found this much much easier to reason about and avoid getting lost in a sea of brackets wen trying to read anything. I understand why more pureist LISP-ers might object as the sparsity is one of the distinctive features, however it is still a very syntactically sparse from the view points of other languages.
ON running on the JVM I thought i would find this a bigger issue than I did - it can be a problem to warm up the JVM but any things I was working on were either long running - and thus not a big issue. Or interactive and I was playing around in the REPL. I did find what was in the standard library vs the platform to feel a bit arbitrary at times and I ended up jumping back and forth a bit.
I did try to program with pure fnctions as much as possible - a lot of the programs for the advent of code involved updating hash maps however - I dont know how much this cost me in terms of performance but I would wager a lot of time was spend copying hashmaps to update values. From haskell programming I vaguley remember a preference for ordered maps as pure updates could be done hile preserving most of the map via sharing. It could be I should have looked for a different solution - or dropped immutability in those cases. It was fast enough for what I was doing however so I cant really complain.
I think out of the two I prefer Clojure to do experiments in (I wish there was a project with Clojure’s syntax features but with more nativish bindings). I understand some of the issues people have with it but it and it’s standard library tend to click more for me. I hope to go through the algorithmic botany book at some point in it but getting this far has exhausted my interest for now. Didnt get onto what I planned to do but at least got further forwards!