A First Look at the Clojure Programming Language

The Clojure programming language is a relatively new dialect of the Lisp language. I decided to install Clojure and take it out for a test drive. Bottom line: I’m not impressed. It’s just another language with no compelling advantages and many disadvantages.

But Clojure is interesting.


The documentation to install Clojure and run a program was a bit scattered. There were three main steps. First, install the Java SDK (which in turn installs an associated Java run time). Second, install a program called Leiningen (which contains the Clojure compiler). Third, write a program, save it, and run it.

I installed a version 7 of the SDK rather than the current version 8 because the Leiningen documentation at http://leiningen-win-installer.djpowell.net/ said to use version 7.

Next, from the link above, I installed Leiningen for Windows using a simple self-extracting executable. The process was quick and easy.

Next, I followed the instructions at https://clojurebridge.github.io/community-docs/docs/getting-started/helloworld/ to create a Clojure project named hello-world:

C:\> lein new hello-world
C:\> cd hello-world

Next, I edited file project.clj which was created in the root directory:

C:\hello-world>notepad project.clj

(defproject hello-world "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]]
    :main hello-world.core)

Next, I edited file core.clj, which is essentially the Clojure program:

C:\hello-world>notepad .\src\hello_world\core.clj

(ns hello-world.core)
; This is a Clojure example
(defn -main []
  "Testing clojure"
  (println "\nBegin Clojure example")

  (def vowel? (set "aeiou"))

  (defn pig-latin [word]
  ; return Pig Latin of word
  (let [first-letter (first word)]
    (if (vowel? first-letter)
      (str word "ay") ; 'then' part
      (str (subs word 1) first-letter "ay"))))

  (println "\nPig Latin of red is")
  (println (pig-latin "red"))  

  (println "\nEnd demo"))

The demo program defines a Pig Latin function. I found the code at: http://java.ociweb.com/mark/clojure/article.html.

Finally I ran the program:

C:\hello-world>lein run

Obviously, after one program, I’m no expert at Clojure but my initial impression is, “What’s the point?” Ultimately any programming language is just a wrapper around low level machine language. There are reasons why some programming languages like Lisp, F#, and Clojure don’t become mainstream. They’re just not as good as mainstream languages like C# and Java (where “good” can mean several different things.).

This entry was posted in Machine Learning, Miscellaneous. Bookmark the permalink.