Your SlideShare is downloading. ×
Clojure Web Development
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Clojure Web Development

3,252
views

Published on

Slides for a talk given at the first China Clojure Users meeting.

Slides for a talk given at the first China Clojure Users meeting.

Published in: Technology, Design

0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,252
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
99
Comments
0
Likes
9
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Clojure WebDevelopment OnyCloud 江宏
  • 2. Example - Trakrhttps://trakrapp.com/Web-based project management systemA product created for our own needsRequirements Feature-complete for software devs Modern friendly UI Affordable
  • 3. Demo
  • 4. Architecture MongoDB (Log & Cache)JavaScript HTTP JSON App Server(Backbone.js) (Clojure) PostgresQL
  • 5. HTTP Server Structure Ring Middleware Handlers The Compojure Framework
  • 6. RoutesMapping: Request -> Handler:(defroutes app-routes (context "/users" [] (GET "/new" [] accounts/show-signup) (POST "/" [email] (accounts/new email)));; GET /users/new -> accounts/show-signup;; POST /users/ -> accounts/new
  • 7. HandlersRequest in, response out.(defn say-hello [req] (let [name (-> req :params :name)] {:status 200 :body (str “Hello ” name “!”)}
  • 8. MiddlewareTransform: Handler -> New Handler(defn wrap-failsafe [handler] (fn [request] (try (handler request) (catch Exception e (.printStackTrace e) {:status 500 :body "An error occured."}))))
  • 9. TestingUnit testing with clojure.test andclojure.contrib.mockIntegration testing using WatirDemo
  • 10. PerformanceNo optimization tricks (type hints, transients,etc.)Average latency ~ 70msLong tailDatabase performance can be improved (indices).
  • 11. Lessons LearnedGood: High productivity Easy to test (dynamic binding) Relatively easy learning curve
  • 12. Lessons LearnedBad: Ugly stacktraces. Exposes too much Java class hierarchy. PersistentMap, PersistentStructMap, struct_map ... (contains? (transient #{:a}) :a)
  • 13. Thank You

×