Keith's Notes

Clojure: It Begins

Apr 10, 2023, 7:57 PM

Last Friday I said to myself, "Self," I said, "you should learn a new programming language."

First try: Yaksha

I had run across a new project called Yaksha which looked pretty interesting. And it has a built-in graphics api, which was appealing. So I downloaded it and went to do a simple hello world program and that's where I saw its limitations. It's a brand new project created by one person. The language documentation is great, but there are almost no resources out there telling you how to get started. I'm sure I could have figured it out, but I didn't really want to dive into something so raw.

Second try: nim

So I moved on to another language that I've heard word of occasionally, nim. This looked pretty interesting and I was able to get a simple program running very quickly. This was just a bit later on Friday night. But one thing that's going to be pretty important to me if I'm going to use a language long term is tooling. I use neovim as an editor and it's super configurable. I've been using neovim's built-in language server protocol (LSP) to do things like code completion and real time error checking. So I wanted to get that working with nim. I banged away at this for the rest of Friday night and off and on throughout the day on Saturday. There is an LSP module for nim, nimlsp. It is supported by the LSP library I'm using in neovim. I got it to connect to the file I was editing and recognize it, but I could not get it to actually do anything, like error checking or code completion. I've set up LSPs on other languages just fine and I pretty much know how they go, but for the life of me I could not get the nim one to work. So it was time to move on.

Third try: Clojure

Clojure was next. I've never worked with a Lisp type programming language and really haven't done too much with functional programming. Clojure looks horrible to read at first glance. It just seems all weird to me. But, there's a whole world out there that I know nothing about, so I figured why not dive into it a bit?

I was able to get all the tooling set up to be able to write and run a program very quickly. Setting up an LSP was a little confusing, but it had more to do with project structure than the LSP itself. Honestly, it might have been the same basic problem with nim, but for whatever reason I solved it pretty quickly with Clojure.

I announced on Mastodon that I was starting to dabble in the language and got a recommendation for a book:

mastodon book recommendation for Clojure for the Brave and True

It's "Clojure for the Brave and True" by Daniel Higgenbotham. You can buy it or read for free here: I have an O'Reilly subscription so I'm reading it from there.

I got through chapter 2 so far. OK, actually I got through chapter 1 and skipped chapter 2 which is all about emacs, which I'm not going to use. But I skimmed it to be sure there was nothing useful for me in there.

So, I've begun my journey and I'm kind of excited. I see there are Clojure bindings for Cairographics, so that should keep me engaged for a while. If this goes well, I'll probably port my bitlib project to Clojure. But that's getting a bit ahead of things at this point.