This post is not intended to be a contest of one language versus another. We are using Perl for a water project for a number of pragmatic reasons, like folks working on the water project who do not know Clojure and Perl’s DBI support to name two.

Instead, this post is about something I’ve noticed, having used Clojure on a few small projects, and now returning, like Kellog’s Corn Flakes, to Perl again for the first time (since 2000, and then again in 2003).

I am re-writing three major Informix 4GL programs in Perl. They rely heavily on Perl’s DBI, and hence need to store a lot of intermediate data. So, there are quite a few module and subroutine scope variables. For me, the striking difference between Perl (and perhaps languages like it, including 4GL, VB, and so on) and Clojure is my Clojure programs don’t seem to need variables, other than global vars and data bound in let statements.

I believe my appreciation for Clojure’s immutable data is as full as it can be for someone who has worked with the language for a couple of years, so I appreciate that you cannot initialize a variable and modify it. The design of my Clojure programs always was different, despite the fact I could have bound a lot of let variables wherever I needed them, but I just never needed to do that.

The data seemed to come and go. My Clojure programs read in data; manipulate that data, make network I/O calls using that data; and then write some of that input data and new data out to disk.

When I first started learning Clojure, the luminaries said my views of designing would change, and I believe they have.

One response to “Clojure and Perl: Noticing First Differences”

Interestingly, I use tons of let assignments in my Clojure programs. But obviously it’s still immutable. Maybe my programming problems are different: by nature they involve munging strings (mostly). I still do appreciate the power of Clojure, and I have gone from seeing immutable references as a crippling handicap to a coding and maintenance advantage, and now I try to follow similar practices in other languages. Functions that have side effects are dangerous and tend to cause problems.