Experimenting with Clojure

Jars with labels

Learning Clojure By Building a Practical Label Printer

When I decided to learn Clojure in 2023, I wanted to make a real-world project rather than abstract exercises. Since we do a lot of food preservation, I decided to create a script to generate beautiful, consistent labels that I could actually use in my daily life. It is a simple project I’ve done in the past that I haven’t had the time to revisit.

Why Clojure and Babashka?

I actually wanted to learn more about functional languages. Clojure is an interesting candidate and Babashka easily turns Clojure into a scripting language.

Challenges and Results

I wanted to convert simple HTML into images for label generation, which has been challenging initially. Fortunately, I discovered CutyCapt, which adequately serves my current needs.

Setting up Doom Emacs with CIDER gave me the full Clojure experience, though the learning curve was steep.

Clojure does have a syntax that is different from what I am used to since it is code as data. I did not dig deep enough to really grasp all the concepts of Clojure, I’ve rather learned the base and have been able to make something useful with it. Of course, the script would need some improvement.

Two years later, I still use this tool regularly for labeling food containers, organizing my garage, and managing cables. With just a simple command, I can specify the contents, date, and any other information I need, and get professionally formatted labels ready to use. My only complain is that the P-Touch device shutdown automatically, so every time I need to print labels, I need to physically move to the device before launching the command but that has nothing to do with Babashka but rather the device or possibly the driver.

Moving On to Go

While this script could get improved, I have made it in 2023. Since then, I have moved away from Doom Emacs to Neovim and I did not renew my interest in Clojure. I may use Babashka again because I think it is an interesting replacement for Bash scripting but I would have yet to find a scripting project that requires a lot of data manipulation to justify it over a simple Bash script. Until then, I recently have started learning Go as it seems to be a language that would complement well my fullstack background.

Jonathan

Published on 2025-05-01,
Updated on 2025-05-03