Web Apps in Clojure Overview

A typical Web application receives data, does something with it and return a result. This is the essence of how a function works in Clojure. So again, its really simple to build web apps with.

As Clojure is centered around dynamically typed & immutable data structures, it makes web applications really easy to build and simple to scale through parallelism. As most of your application will be stateless, it is less complex and less prone to conflicts.

Libraries over frameworks

Clojure also takes a very modular approach to building any application and has many great libraries to minimise the work involved. As Java Interoperability is also very easy in Clojure, its trivial to use Java libraries too.

Web apps in Clojure are typically built from a collection of highly focused libraries, that complement each others functions. Talking a modular approach, you can swap components & libraries easily should there be value in a different approach. Common libraries for web app development include:

The closed thing to a framework in Clojure is Pedistal. Frameworks constrain you to a certain approach to building apps and if you can live inside these constraints they can be very powerful.

Project templates

You don't have to build projects from scratch each time, although this is a valid approach. There are many great Clojure project templates available via the build automation tool, Leiningen

Project templates are used as follows

lein new template-name project-name

There are many great templates to try that provide insight into building webapps in Clojure.

  • compojure - a simple project with routing
  • luminus - a production ready app template
  • duct - simple, minimal production-grade framework
  • pedestal-service - an opinionated, extensible & scalable framework

You can find a range of project templates by searching for lein-template on Clojars.org. There is also a guide to writing templates on Leiningen.org

results matching ""

    No results matching ""