Created
October 15, 2014 08:46
-
-
Save Kungi/cb735bb33b117bb60a58 to your computer and use it in GitHub Desktop.
Frameworkless Web Development in Clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Talk Title: Frameworkless Web Programming in Clojure | |
Content of the Talk: | |
1. Why Web Frameworks? | |
- Everything from one source (parts fit together) | |
- Good tooling support (see Django) | |
- Easy to set up | |
- Easy to use | |
2. Why Not? | |
- Most of the time not simple | |
- If you have to deviate from the framework it gets messy | |
- Frameworks are quite rigid most of the time | |
- Choosing your own tools and therefore building a | |
"framework" creates flexibility | |
- (Microframeworks try to solve this problem) | |
3. Analyzing the contents of the typical web framework | |
- HTTP Abstraction | |
- HTTP Middlewares | |
- Routing | |
- Templating | |
- Authentication | |
- Database abstraction | |
- Communication with the frontend | |
4. Clojure provides libraries for all these needs | |
- Starting with a small compojure app directly from the | |
the leiningen template I will analyze its parts. | |
4.1 HTTP Abstraction - Ring | |
- How Ring works | |
- Request -> Map -> Input Middlewares -> Program -> Output Middlewares -> Response | |
- What is a Ring middleware | |
- Input Middleware (fn [handler] (fn [req] do something (handler req))) | |
- Output Middleware (fn [handler] (fn [req] (let [res (handler req)) do something)) | |
4.2 Routing - Clout and Compojure | |
- Routing patterns | |
- Show clout examples | |
- Show compojure examples | |
4.3 Templating - Hiccup, Enlive, mention some others | |
- Hiccup is simple | |
- Convert nested Clojure lists into HTML | |
- DSL? for HTML | |
- You can interact with your HTML in a clojury way | |
- Enlive | |
- Still write HTML (no DSL) | |
- Selector based syntax to interact with HTML snippets | |
- Transformations | |
4.4 Authentication - Friend | |
- How to use friend | |
- What is a workflow | |
4.5 Database Abstraction - clojure/java.jdbc, Korma | |
- clojure/java.jdbc | |
- Simple DSL for SQL | |
- A bit like hiccup for SQL | |
- Korma | |
- Another more fleshed out SQL DSL | |
4.6 Communication with the Frontend - ClojureScript and EDN | |
- You can use the same data structures on the client | |
as on the server. | |
- Show a funny toy example where a function is created in | |
ClojureScript, sent to the server, executed and the result | |
sent back to the client. | |
5. Summary | |
- The frameworkless approach works good | |
- No interaction problems between the libraries because | |
no objects are involved | |
- It is easy to swap out the libraries | |
- A very flexible approach |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment