11

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?

8
  • Maybe you should consider using CGI. Commented Aug 11, 2013 at 14:19
  • Well, yes, this may be an idea - although I dislike the "plugin" approach of CGI. But it may be an idea ... thanks for pointing this out! Commented Aug 11, 2013 at 14:21
  • 2
    you should probably check: stackoverflow.com/questions/556456/… Commented Aug 11, 2013 at 14:26
  • Thanks, this looks quite interesting! Commented Aug 11, 2013 at 14:28
  • If Emacs is an acceptable platform, have a look at Elnode. Commented Aug 11, 2013 at 16:52

3 Answers 3

21

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 
Sign up to request clarification or add additional context in comments.

Comments

9

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.

1 Comment

Thanks for the Wookie mention! I would also recommend Hunchentoot for starters. The synchronous model is about 5x easier to wrap your head around. Where Wookie really shines is when you need an app to tie different pieces together (calling out to internal or 3rd party APIs via HTTP, running database queries, grabbing values from redis, queuing larger jobs to the background, etc...anything that requires network I/O). It's not meant to do much "work" other than encoding/decoding and passing data around. Beware also, async driver support is lacking. Your favorite DB probably isn't supported (yet)
8

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.

1 Comment

I have had a really good time with Caveman. Would recommend it to anyone.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.