Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web Applications in Clojure

Joy Heron
February 07, 2017

Web Applications in Clojure

Clojure, as a Lisp dialect running on the JVM, is a purely functional language that also takes advantage of the great library support available in the Java world.

As a functional language, it provides great abstractions for developing web applications, particularly because of how it handles HTTP, which is a fundamentally stateless protocol. In this talk, I will explain the fundamental concepts behind Clojure web applications and how the Clojure libraries harness the power of the existing Java infrastructure in order to provide state of the art server technology.

Joy Heron

February 07, 2017
Tweet

More Decks by Joy Heron

Other Decks in Technology

Transcript

  1. @iamjoyclark Clojure > Lisp Variant for the JVM > Functional

    Language > Dynamically Typed > Immutable Data Structures > Simplicity - Separation of Data and Behavior
  2. @iamjoyclark Data Structures “Hello World” 3 3.14 3/2 \a :first

    foo #“Ch.*se” (“Hello” :first) [3 4 3] { :name “Joy” :company “innoQ” } #{3 4 3}
  3. @iamjoyclark Functions (+ 1 2) > 3 (:city {:name “innoQ”

    :city “Munich”}) > “Munich” (map inc [1 2 3]) > (2 3 4)
  4. @iamjoyclark Ring: Handler (defn example-app [request] (let [name (get-in request

    [:params :name])] {:status 200
 :headers {“Content-Type” “text/plain”} :body (str “Hello, ” name “!”)})
  5. @iamjoyclark Ring: Middleware (defn wrap-logging [handler] (fn [request] (print request)


    (let [response (handler request)] (print response) response))) webapp Java HTTP Server Ring Server Adapter middleware middleware
  6. @iamjoyclark Compojure: Handler (defroutes app-routes (GET “/” request (list-users request))

    (POST “/” {params :params :as request} (add-user request params)) (GET “/:username” [username :as request] (get-user request username)))
  7. @iamjoyclark Summary > Functional Language ideal for Web Apps >

    Clojure usage is increasing > Libraries vs. Frameworks > Community is healthy and welcoming
  8. Joy Clark | @iamjoyclark | [email protected] www.innoq.com Tutorial for Getting

    Started: https://github.com/innoq/tutorial-clj-webapp Thank you!