Tags

, , ,

At the time of writing, I’m organising a ClojureBridge workshop.  ClojureBridge targets underrepresented groups who are either brand new to programming or only have limited experience.  While preparing for the workshop, I struggled to find quality info in the public domain about whether Clojure is a suitable first programming language.  There are lots of introductions to Clojure written from the assumption that the reader/viewer has previous programming experience, but very little substance around choosing Clojure (or any other language for that matter) as your first language.  So this is my attempt to answer the question:

“Is Clojure a good choice as a first programming language?”

Criteria

The get-out-of-jail answer to any question like this is “it depends”, so I’m going to list some key criteria that I think are important for someone choosing their first programming language, even if the significance of some of these criteria might not be immediately apparent.  The criteria I settled on are:

  1. TTHW (Time To Hello World)
  2. Community Support
  3. Funability
  4. Industry relevance

I’ll step through each of these criteria and give a subjective “grade” (i.e., “A” through to “F”)  on how well Clojure meets these criteria, as well has listing other language choices that perform particularly well or poorly on each criteria.

1. TTHW (Time To Hello World)

There is an age-old tradition where programs that show the text “Hello World” on the screen are the first ones you see/construct in any new language.  The essence of “Hello World” programs is that they are simple, quick to write and with very little that can go wrong with them.  “Hello World” programs also provide unambiguous tangible feedback that they are working (or not).  This criteria recognises how important it is for a first language to support novice developers by allowing them to write and run programs as quickly as possible.

With the only prerequisite that you have a computer with a working internet connection and browser, languages that perform well on this criteria allow you to code without the need to install or configure any additional software.  On the other end of the spectrum are languages which require installation and configuration of significant amounts of non-standard software.

Hello World in the Browser

TryClojure, 4Clojure and Repl.it are three online Clojure environments (amongst others) that let you use only your browser to experiment with the Clojure language.  It’s important to note that while these tools are great for the early days of experimenting with a language, you will fairly quickly want/need to write code on your own machine which requires the installation of additional software, and Clojure does have a higher hurdle to clear than some other languages in this respect.

Clojure Grade: A (lots of options, very little friction)

Hello World on your Computer

Clojure runs on top of the Java programming language.  Learning Clojure doesn’t require you to learn Java, but Java must be installed.  Many operating systems (e.g., Windows, OSX on Apple computers) come with a version of Java pre-installed, but in some cases Java wont be installed or be the wrong version for Clojure, so installing Java will be required as well.

Once Java is installed, installing Clojure usually requires that you install Leiningen (another piece of software you use to construct Clojure programs) which will allow you to download and install Clojure easily.  Installing Leiningen requires some familiarity with the command line tools on your Operating System, which can complicate things if you have not used these tools before.

A final step in this process is to install some form of text editor or IDE to write your Clojure programs.  Your computer will come installed with a basic editor already, but it will not be especially useful for Clojure programming in it’s default state so options like Sublime Text, Atom or Cursive are popular choices to quickly provide a beginner developer a decent development environment.

Clojure Grade: C (compared to languages like Ruby and Python which are often pre-installed on most Apple and Linux computers).

2. Support

This criteria could have been renamed “Time to First StackOverflow Answer” as it relates to how much support the language community will/can provide to beginner developers.  This support could come from a variety of channels; official documentation, tool support, online communities like StackOverflow, local user groups, conferences, books, etc.

From a beginner’s perspective, it’s important to understand that languages come with their own unique culture which often flows from their creators and high profile advocates.  My experience been that community support peaks in the early years of a language’s popularity where the “size” of the language is small enough to keep the active members of the community cohesive and passionate about it’s growth.  As languages mature and their reach into the software development world both broadens and slows, the pioneering spirit of the community will most likely dissipate as the need to support programmers of various levels of experience exceeds the ability/desire of the core community.  The upside of this phase of a language’s evolution is that all the beginner problems have been solved many, many times over and Google will answer the vast majority of your questions fairly effectively.

Clojure is a relatively mature language that is attracting the “Early Majority” in the adoption life cycle.  That said, Clojure is a language from the functional programming family of languages and the mathematical and academic background to this group can flow into the online and physical communities (e.g., user groups, conferences) which can portray Clojure as less accessible than necessary.

Clojure Grade: B- (minus marks for some of the pious FP attitude that leaks from the community)

3. Funability

Of all the largely subjective nature of these criteria, this one takes the cake!  How does one measure how much fun it is to program in a language?  But for a beginner programmer, using your first language must generate positive vibes or you’ll quickly lose interest.

Under the premise that a sense of achievement (i.e., accomplishing what I set out to do) will generate feelings of satisfaction, I’m going to use a proxy metric of “how much does the language get in my way of doing what I want” to measure how much fun Clojure is, and I think Clojure has a good story to tell in this sense:

(Note: some of what follows is might not be immediately obvious/understandable to completely novice developers)

  • Dynamic typing – not needing to worry (much) about types increases the speed with which beginner programmers can produce working code.
  • The REPL – having an interactive environment to experiment in not only overcomes the downside of Clojure’s Java dependence but provides instantaneous feedback for a development cohort that have no past experience to give them confidence in their actions.
  • Concise syntax – less syntactic breadth means less mental energy needed when coding.  There’s still the APIs to grok, but almost everything in Clojure code is a function call with a very small set of reserved terms in the language.

And on the negative side…

  • Java/Clojure Stacktraces – it wont be long before every new Clojure developer is presented with their first stacktrace… and even as a seasoned Java developer, I still recoil at the sight of some of these.
  • Prefix notation – this might be a vastly polarising topic, but I suspect a group of people will never get comfortable with prefix notation and the sea of parenthesis that are so commonly associated with Clojure and it’s siblings in the Lisp family.

Clojure Grade: B- (with Ruby as possibly the most “fun” language I’m aware of with all the benefits of dynamic typing and a REPL, but without the pain of reading Clojure-like stacktraces and a more “natural” infix notation).

4. Industry relevance

Of course, many people start coding as part of a career change, so choosing a first language that puts you somewhere along a path to said career might factor very highly in importance.  Breaking into the software development market with your only experience being in “niche isolated language X” is probably not going to stand out on your fledgling CV as “highly popular, widely used language Y”.

It’s hard to deny that the “best” language if you wish to optimise for (broard) industry relevance above everything else is JavaScript.  Ubiquitous on the browser and with considerable popularity on the server via Node.js, Javascript (considerable warts and all) is the ideal choice if you want to bootstrap yourself into a development career as quickly as possible.

Clojure has nowhere near the market presence as Javascript (or Ruby or Python for that matter), but it does have success stories at some fairly high profile brands.  It also has a browser version of the language – ClojureScript – which can give you exposure to front-end web development with little extra investment.

However the biggest advantage Clojure has in industry relevance is the Java connection.  Java is an very mature and widely adopted language that is deeply integrated into the IT systems of tens of thousands of companies.  The JVM (platform on which both Java and Clojure run) will be a permanent part of the global IT landscape for decades to come, and more and more companies with existing experience in the JVM (via Java) are looking to broaden this experience with other JVM languages (like Clojure).

Clojure Grade: B (Javascript is an A+ on this scale.  Clojure looses marks for relative lack of popularity, but gains some back via ClojureScript and the Java connection.)

Conclusion

“Is Clojure a good choice as a first programming language?”

Coming back to the criteria, I judged Clojure as follows:

  • Time To Hello World – A (on browser) and C (on computer)
  • Community Support – B minus
  • Funability – B minus
  • Industry relevance – B

Overall, that’s not a bad report card and while Clojure doesn’t stack up as the obvious choice for a first programming language, it’s not a bad choice by any means.

Individuals may place different weights against these criteria, but if you keep in mind that your first programming language shouldn’t also be your last one (i.e., you can/should learn plenty more over time), there’s very little downside to making Clojure the first one.

Clojure gives you a good first programming experience with little overhead, lots of support avenues and good options to turn your programming hobby into the beginnings of a programming career.

Advertisements