ClojureScript: The industry's favorite functional frontend language

By Zach Oakes on January 21st, 2017

Over the past five years, ClojureScript has almost certainly become the industry's most-used functional language that compiles to JavaScript. Admittedly, this is like being the most popular person who can speak Klingon. Nonethless, if you listen to people online, this fact might take you by surprise. I've even seen blog posts about functional frontend languages that either don't mention ClojureScript, or dismiss it out of hand.

Is there a rift between the software industry and the software peanut gallery? Is asking a question with an obvious answer a useful rhetorical device?

The main languages in this category are ClojureScript, Scala.js, Elm, PureScript, and GHCJS. In an alternate universe, they're the members of an embarrassing boy band. Now, I'm specifically interested in industrial use, so Github stars, TIOBE, Google Trends, and vain laptop stickers are irrelevent. Instead, I suggest perusing this list of companies using ClojureScript.

Granted, some companies keep a tight lid on their tech choices, but there's no reason to believe a language would be underrepresented because of that. After all, a given language shouldn't inspire more secrecy than any other. Except for LabVIEW, of course — I know a guy who uses that, and he's a shady little bastard.

My intent is not to cast aspersions (though I enjoy doing that as well), but rather to ask — and answer — what is it about ClojureScript that appeals to the industry but not to the tech crowd?

  1. Stability - Companies don't want to update their code every time you decide to rename a function in your standard library. Its role in Java's dominance can't be overstated. This culture, explained beautifully by Brian Goetz, made its way into Clojure and ClojureScript, who haven't made breaking changes in the five years I've used them.
  2. Interop - If you're doing industrial frontend development, you don't have time to reimplement everything. In ClojureScript, calling a JavaScript function is as easy as doing it from JavaScript. It has wrappers for things like React, for the sake of abstraction, but they aren't required. Some compile-to-JS languages require extra ceremony. This pain isn't fully felt until you have to interop with a large JavaScript codebase.
  3. Google Closure - An important early decision was to hitch ClojureScript's wagon to the Google Closure project, which provides both a huge standard library and a dead code eliminator. Google Closure allowed it to avoid much of the generated code bloat and runtime cost normally associated with compile-to-JS languages. Despite its utility, the tech crowd frowns upon it due to its Java dependency.

By contrast, what are the qualities most sought after by the tech crowd?

  1. Purity - A major clash between idealism and practicality is the notion of enforcing functional purity via a static type system. ClojureScript encourages it, but doesn't enforce it. The downside to enforcing it is that JavaScript itself is impure, and enforcing purity means more effort is needed to interop with it. In the industry, interacting with large JavaScript codebases is an inevitability.
  2. Openness - Some people have an adamant belief that a language should be developed "in the open", preferably on Github, and take input from the community. In contrast, Clojure(Script) uses JIRA, requires signing a CA, and most decisions are made Willy Wonka style by Rich Hickey. This irks some people, perhaps on philosophical (egalitarian) grounds, but unsurprisingly companies couldn't care less.
  3. Easiness - For individuals working for pleasure, the beginner experience is more important than it is for companies. Admittedly, ClojureScript still has poor documentation and error messages. Instead of with static typing, both are being tackled in a very "clojuresque" way by spec.

A lot of this dichotomy can be cast in terms of practicality and idealism. Companies with budgets and deadlines care about the former, while hobbyists tend to indulge more in the latter. That being said, the beginner experience is important. If you're a beginner, try my new cloud IDE. In a few clicks you can start a project, break things, hit a roadblock, and hate yourself. It'll be great.