Developing and Deploying a Simple Clojure Web Application
21–30 of 41 posts
Re: Developing and Deploying a Simple Clojure Web Application
#22Another nice example can be found in the last "Functional Web" column on IEEE Internet Computing by Steve Vinosky: http://steve.vinoski.net/pdf/IC-Getting_Started_with_Google_... In the July/August 2010 column, Getting Started with Google App Engine and Clojure, guest columnist Aaron Bedra shows how to use Clojure, a relatively new but robust Lisp implementation on the Java Virtual Machine, create and deploy an appli…
Couple more helpful links for some basics not covered in the article (all work in progress):
Compojure docs: http://www.compojure.org
Stub for "Clojure Web Development" book: https://docs.google.com/Doc?docid=0AQqGP1CDN0uIZGhmZjJmcGZfM...
Re: Developing and Deploying a Simple Clojure Web Application
#23 (defpackage :add-nums
(:use :cl :hunchentoot :cl-who))
(in-package :add-nums)
(defmacro with-html (&body body)
`(with-html-output-to-string (*standard-output* nil :prologue t :indent t)
,@body))
(define-easy-handler (add-nums :uri "/add-nums")
((a :parameter-type 'integer)
(b :parameter-type 'integer))
(with-html
(:html
(:head (:title "Add two numbers"))
(:body
(if (and a b)
(htm (:p (str (+ a b)))))
(:form :method :get
(:input :type :text :name "a")
(:input :type :text :name "b")
(:input :type :submit))))))
(defparameter *site* (make-instance 'acceptor :port 8080))
(start *site*)Re: Developing and Deploying a Simple Clojure Web Application
#24If this is an easy way to create a web app that adds two numbers on Clojure, I'd say Clojure is not ready for web development yet.
Huh. 45 LOC for templating, routing, and form processing and you don't need to configure a different webserver since jetty is production quality. Do you have links to something that takes less effort than what is being illustrated here that can be deployed immediately into production and perform well?
(To be honest, I think clojure has its purposes, but a one-off calculator page isn't one of them. Use the right tool for the right job and all that.)
Re: Developing and Deploying a Simple Clojure Web Application
#25In Common Lisp ( without cheating or handwaving; this is it ): (defpackage :add-nums (:use :cl :hunchentoot :cl-who)) (in-package :add-nums) (defmacro with-html (&body body) `(with-html-output-to-string (*standard-output* nil :prologue t :indent t) ,@body)) (define-easy-handler (add-nums :uri "/add-nums") ((a :parameter-type 'integer) (b :parameter-type 'integer)) (with-html (:html (:head (:title "Add two numbers"))…
Re: Developing and Deploying a Simple Clojure Web Application
#26In Common Lisp ( without cheating or handwaving; this is it ): (defpackage :add-nums (:use :cl :hunchentoot :cl-who)) (in-package :add-nums) (defmacro with-html (&body body) `(with-html-output-to-string (*standard-output* nil :prologue t :indent t) ,@body)) (define-easy-handler (add-nums :uri "/add-nums") ((a :parameter-type 'integer) (b :parameter-type 'integer)) (with-html (:html (:head (:title "Add two numbers"))…
Er, Clojure has CL style macros so you can easily get to this level of brevity if that is desired.
I have been screaming for ages telling Clojurists to rip CL APIs and implement them in clojure. They're more tasteful and cultured than that entrerprisey crap that java is smearing all over this nice Lisp dialect.
The majority of open source clojure code that I have seen looks like Java FFI stubs; you need to tuck those loose ends in and tidy them up with macros. But this probably wont happen until Clojure is ported to another runtime/platform; portability is a surefire way to distill the essence of a language from its implementation detail.
Re: Developing and Deploying a Simple Clojure Web Application
#27Earlier quoted context omitted.
Er, Clojure has CL style macros so you can easily get to this level of brevity if that is desired.
The one custom macro I wrote is already in there. The rest is just the web server and cl-who. I have been screaming for ages telling Clojurists to rip CL APIs and implement them in clojure. They're more tasteful and cultured than that entrerprisey crap that java is smearing all over this nice Lisp dialect. The majority of open source clojure code that I have seen looks like Java FFI stubs; you need to tuck those loos…
Care to help? If you feel this strongly about it, surely you can contribute to the community.
Re: Developing and Deploying a Simple Clojure Web Application
#28Earlier quoted context omitted.
The one custom macro I wrote is already in there. The rest is just the web server and cl-who. I have been screaming for ages telling Clojurists to rip CL APIs and implement them in clojure. They're more tasteful and cultured than that entrerprisey crap that java is smearing all over this nice Lisp dialect. The majority of open source clojure code that I have seen looks like Java FFI stubs; you need to tuck those loos…
"I have been screaming for ages telling Clojurists to rip CL APIs and implement them in clojure." Care to help? If you feel this strongly about it, surely you can contribute to the community.
My advice is just that, advice, and it's given in the hope that with our mutual situations improved, maybe we can meet for coffee somewhere down the road and kick it back.
Re: Developing and Deploying a Simple Clojure Web Application
#29Earlier quoted context omitted.
Er, Clojure has CL style macros so you can easily get to this level of brevity if that is desired.
The one custom macro I wrote is already in there. The rest is just the web server and cl-who. I have been screaming for ages telling Clojurists to rip CL APIs and implement them in clojure. They're more tasteful and cultured than that entrerprisey crap that java is smearing all over this nice Lisp dialect. The majority of open source clojure code that I have seen looks like Java FFI stubs; you need to tuck those loos…