Tuesday, January 8, 2008

cgi programming using clisp

Lisp is considered as the language for the creamy layer in the programming world Cool

As I am not “so busy” these days, I have decided to give lisp a try……….. So decided to start with a hello world thing in lisp…
First I have installed clisp in my linux machine…

Then created the file hello.lsp which contains a single line…

(write-line “Hello World”)

Then ran the program :

clisp hello.lsp

Hello World…

OMG, my first program in Lisp works…… 

Then decided to try the same program as a CGI script in Apache to get the feel of web programming using lisp…

test.lisp
 
#! /usr/local/bin/clisp
(write-line “Content-type: text/html”)
(write-line “”)
(write-line “Hello World”)

to /var/www/cgi-bin/test.lisp
chmod +x /var/www/cgi-bin/test.lisp
Restarted apache..
/etc/init.d/httpd restart
Then accessed it like
http://localhost/cgi-bin/test.lisp

Hello World…

It works…

Now just after a hello world, I feel like I became a hacker… as  Eric S Raymond commented on LISP in “How to Become A Hacker” …

” the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot. (You can get some beginning experience with LISP fairly easily by writing and modifying editing modes for the Emacs text editor, or Script-Fu plugins for the GIMP.)”

Posted by maxinbjohn at 06:28:18 | Permalink | No Comments »