Golo Roden
Golo Roden

Reputation: 150624

How do I create a web application using LISP?

I have experience in C# and JavaScript, and have been working for the last few years with Node.js. Basically, I'm very confident with this environment, but one language has always caught my eye: LISP. I find it impressive and quite fascinating how expressive LISP is, given its minimal language concepts. It's basically as with jQuery: Do more with less ;-)

Unfortunately, my experience with LISP is more or less theoretical and some playing around, but not serious programming.

Now I'd like to change that, but I am definitely dedicated to web application development (hence Node.js). My problem is not to learn LISP as a language, my problem is that I do not know where and how to start with a "Hello LISP world" application that is not console-based, but web-based.

So, my question basically is: How could I write a server-side web application in LISP that is similar to the following Node.js application

var http = require('http');
http.createServer(function (req, res) {
  res.end('Hello world!');
}).listen(3000);

without the need for lots of frameworks and additional libraries and stuff and so on?

How would an experienced LISP programmer solve this task? Any hints?

Upvotes: 11

Views: 3244

Answers (3)

PuercoPop
PuercoPop

Reputation: 6807

Just as to complement other answers, there are also ningle1 and caveman2, which also are decently documented. Ningle routing is very similar to Sinatra/Flask.

Upvotes: 8

Vsevolod Dyomkin
Vsevolod Dyomkin

Reputation: 9451

The answer about Hunchentoot is really a way to go for starters, and I fully recommend to try it.

The only major difference from the node.js variant in the question is that Hunchentoot is a synchronous web-server. If you want to get the same asynchronous behavior (actually, why would you, but that's for another discussion ;), you've got to try something else, like wookie. The similar Hello World example is procided at its documentation page.

Upvotes: 9

huaiyuan
huaiyuan

Reputation: 26529

Once you have SBCL and Quicklisp installed,

(ql:quickload "hunchentoot")
(hunchentoot:start 
  (make-instance 'hunchentoot:easy-acceptor :port 3000))
(hunchentoot:define-easy-handler (foo :uri "/bar") (name)
  (format nil "Hello~@[ ~A~]!" name))

Then visit

http://127.0.0.1:3000/bar?name=World

Upvotes: 21

Related Questions