This document discusses building web applications using Clojure and ClojureScript. It covers the Lispy syntax of Clojure, cross-platform coding using reader conditionals, and popular Clojure libraries. It demonstrates the frontend architecture using React and core.async for asynchronous programming. Remote communication involves serialization with Transit. The backend uses small libraries without frameworks, with routing and handler functions. Overall it provides an overview of building full-stack webapps with the Clojure ecosystem.
11. Language features „a la carte“
core.logic
core.async
clojure.spec
core.match Haskell style pattern matching
Logic programming
CSP style programming
Schematizing data
overtone SuperCollider synthesizers
20. Callbacks are ok, but, uhm ...
function reloadAddressbook (state, event) {
ask("Are you sure?", function (answer) {
if (answer) {
ajax.get("/addresses", function (response) {
if (response.statusCode == 200) {
state.addresses.items = response.body;
}
});
}
});
}
Ask for confirmation
ok?
Issue GET request
success?
Replace items
But how do you implement concurrent requests?
callback 1
callback 2
21. CSP* with core.async = channels + go blocks
Communicating Sequential Processes, Tony Hoare (1978)
*
(def c1 (chan))
(go-loop [xs []]
(let [x (<! c1)]
(println "Got" x ", xs so far:" xs)
(recur (conj xs x))))
(put! c1 "foo")
;; outputs: Got bar , xs so far: [foo]
a blocking read
make a new channelcreates a
lightweight
process
async write
22. core.async: no need for callbacks
Ask for confirmation
ok?
Issue GET request
success?
Replace items
(defn <addressbook-reload
[state event]
(go (if (= :ok (<! (<ask "Are you sure?")))
(let [{s :status addresses :body}
(<! (http/get "/addresses"))]
(if (= 200 s)
(assoc-in state
[:addresses :items]
addresses)
state)))
32. Webapp development with Clojure + ClojureScript ...
... gives you rapid feedback
… provides a mature full-stack ecosystem
… is demanding to learn, but this will pay-off
33. Thank you for listening!
Questions?
@friemens www.doctronic.de