Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

About Clack

64,608 views

Published on

This is a presentation for International Lisp Conference 2012 which was held in Kyoto, Japan.

Clack is a web application environment for Common Lisp to make your web applications be portable and reusable by abstracting HTTP into a simple API.

In this paper, I describe what are problems in web development and how Clack solves them.

Published in: Technology
  • Be the first to comment

About Clack

  1. 1. About Clack Hatena Co., Ltd. Eitarow Fukamachi Oct 24, 2012 International Lisp Conference @ Kyoto, Japan
  2. 2. About Me• Eitarow FUKAMACHI (≒ eight arrow)• Live in Kyoto, Japan• Common Lisp user since 2010• Attended ILC2010 @ Reno• (I’m using Clozure CL)• Web application developer at Hatena Co., Ltd.• Using Perl at work
  3. 3. Products• Clack • CL-Markup• Caveman • CL-Project• ningle • Shelly• CL-TEST-MORE etc.• CL-DBI See github.com/fukamachi
  4. 4. What’s “Clack”?
  5. 5. What’s Clack?• Web application environment • Foundation for Web application framework• Equivalent to... • Python’s WSGI, Ruby’s Rack, Perl’s Plack/PSGI and Clojure’s Ring
  6. 6. What’s Clack?• Web application environment • Foundation for Web application framework• Equivalent to... • Python’s WSGI, Ruby’s Rack, Perl’s Plack/PSGI and Clojure’s Ring• Abstract HTTP into a simple API (Portability)• Share code across web frameworks (Reusability)
  7. 7. Clack’s“Portability”
  8. 8. “Portability”• Abstract a web server ※Application includes Web frameworks.
  9. 9. “Portability”• Abstract a web server ※Application includes Web frameworks.
  10. 10. “Portability”(clack:clackup app);-> Hunchentoot server is started.; Listening on localhost:5000.; # #x30200A102B3D
  11. 11. “Portability”(clack:clackup app);-> Hunchentoot server is started.; Listening on localhost:5000.; # #x30200A102B3D(clack:clackup app :server :hunchentoot) ;; default(clack:clackup app :server :fcgi)(clack:clackup app :server :apache)
  12. 12. Clack’s“Reusability”
  13. 13. “Reusability”• Application takes Request and returns Response
  14. 14. “Reusability”• Application takes Request and returns Response• Extension mechanism called “Middleware”• “Middleware” can be reused
  15. 15. “Show me how to use it!”
  16. 16. Example 1“Hello, World!”
  17. 17. Example: Hello, World!(defun app (env) (declare (ignore env)) (200 (:content-type "text/plain") ("Hello, World!")))(clack:clackup #app)
  18. 18. Example: Hello, World!(defun app (env) (declare (ignore env)) (200 ‘(200 (:content-type "text/plain") “text/plain”) ("Hello, World!"))) (“Hello, World!”))(clack:clackup #app)
  19. 19. Example: Hello, World! (defun app (env) (declare (ignore env)) (200 ‘(200(:request-method :GET :script-name "" (:content-type "text/plain") “text/plain”) :path-info "/sns/member" ("Hello, World!"))) (“Hello, World!”)) :query-string "id=3":server-name "localhost":server-port 5000 (clack:clackup #app):request-uri "/sns/member?id=3":server-protocol :HTTP/1.1:http-user-agent "Mozilla/5.0 (Macintosh...":remote-addr "127.0.0.1":remote-port 26077:http-referer nil:http-host "localhost:5000":http-cookies nil)
  20. 20. Example: Hello, World!
  21. 21. Example 2“Conditional flow”
  22. 22. Example: Conditional flow(defun app (env) (cond ((string= (getf env :path-info) "/favicon.ico") (200 (:content-type "image/x-icon") #p"/path/to/favicon.ico")) ((string= (getf env :path-info) "/") (200 (:content-type "text/html") ("Hello again"))) (t (404 (:content-type "text/plain") ("Not found")))))(clack:clackup #app)
  23. 23. Example 3“Basic Auth”
  24. 24. Example: Basic Auth(import ‘(clack.builder:builder clack.middleware.auth.basic:<clack-middleware-auth-basic>))(defun app (env) (declare (ignore env)) (200 (:content-type "text/plain") ("Hello, World!")))(clack:clackup (builder (<clack-middleware-auth-basic> :authenticator (lambda (user pass) (and (string= user "johnmccarthy") (string= password "password")))) #app))
  25. 25. Example: Basic Auth
  26. 26. Example 4“Static files”
  27. 27. Example: Static files(import ‘(clack.builder:builder clack.middleware.static:<clack-middleware-static>))(defun app (req) (declare (ignore req)) (200 (:content-type "text/plain") ("Hello, World!")))(clack:clackup (builder (<clack-middleware-static> :path (lambda (path) (when (ppcre:scan "^/(?:images|css|js)/" path) (ppcre:regex-replace "^/[^/]+" path ""))) :root #p"static/") #app))
  28. 28. What are the benefits of using Clack?
  29. 29. Clack allows you to:• If you’re a “Web framework developer”... • Clack provides server interfaces. • Reuse code from other web frameworks.
  30. 30. Clack allows you to:• If you’re a “Web framework developer”... • Clack provides server interfaces. • Reuse code from other web frameworks.• If you’re a “Web application engineer”... • Reuse code in your projects • Extensible
  31. 31. Frameworks
  32. 32. Frameworks• Caveman • A Sinatra-like micro framework• ningle • A really micro framework
  33. 33. Frameworks• Caveman (fukamachi.github.com/caveman/) • A Sinatra-like micro framework• ningle (fukamachi.github.com/ningle/) • A really micro framework
  34. 34. Future Work
  35. 35. Future Work• More Middlewares• More Servers • non-blocking web server? • preforking web server?
  36. 36. Future Work• More Middlewares• More Servers • non-blocking web server? • preforking web server?• More Frameworks • Ruby on Rails?
  37. 37. THE ENDThank you for listening
  38. 38. Maybe we still have time. Any questions in easy English? To Japanese speakers: Please translate a question for me if it looks I dont understand it. 僕が質問を理解できていなさそうだったら翻訳してください><

×