Roshan Book

My Tech Notebook

Setting up Lisp on Linux (Ubuntu)


I consider Paul Graham as my guru. His book Hackers & Painters has given me my dream. So when he says Lisp is great , I believe him. I have no idea about the concept of “macros”, or “closure” is, but I know one day I will learn Lisp and get that blub paradox.

Installing Lisp

Today I tried to set up lisp environment on my system, and succeed🙂 . Not a tough job when you have the power of

sudo apt-get install clisp

You can install popular Clisp dialect on ubuntu system by typing above command.

For start using it, well you could just type clisp in your terminal and be greeted with

You are now at the lisp REPL (Read Eval Print Loop).

To get an editor

I was recommended to used Emacs with slime for Lisp. In-fact hardcore vim users also uses emacs for lisp editing

So, the magical command to get this 88mb program installed is

sudo apt-get install emacs slime

Configuring Emacs with Slime

No don’t ask me what they mean. Just go ahead with the following steps to configure Emacs with slime

mkdir ~/.slime

This command will make a directory “.slime” in your home folder

gedit .emacs

This will open a new file by the name of .emacs in gedit (editor), which is to be saved in home directory

;;; Lisp (SLIME) interaction
(setq inferior-lisp-program “clisp”)
(add-to-list ‘load-path “~/.slime”)
(require ‘slime)
(slime-setup)

(global-font-lock-mode t)
(show-paren-mode 1)
(add-hook ‘lisp-mode-hook ‘(lambda ()
(local-set-key (kbd “RET”) ‘newline-and-indent)))

Add above lines to .emacs file

I tried to explain what each command does. Will try to add more, once I get hang of it.

Just for fun

; Lisp
(defun addn (n)
#'(lambda (x)
(+ x n)))

Do you know what this does ?

Yes it takes a number n, and returns a function that adds n to its argument
Do you understand how it does?

No Idea, Bro!

Can you represent something like this in C?

Not possible at all.

That is just one sample, to show power of lisp – self🙂

Do read about blub paradox, to get little bit of light on this .

One response to “Setting up Lisp on Linux (Ubuntu)

  1. A. Madhur December 22, 2012 at 8:27 am

    Roshan – if you love Lisp then check out VIVEK SHANGARI – Lisp guru of India! worth knowing him. We were a batch of 10 people sent by our company to one of his Lisp training programs. Man!!! I can’t believe what all Lisp can do! So much power! It’s awesome. There are things you can do in Lisp that are just not possible in any other programming language. Once you learn Lisp you will never go back to your previous programming language.

    The way this guy teaches Lisp is amazing – making games in Lisp, code hacking, concepts from science fiction movies explained in Lisp, coding competitions in Lisp, puzzle solving – just mindblowing stuff! Nothing like what you would have seen before. Totally recommend it if you want to learn Lisp.

    http://www.codeCraft.in – this is his website.

    Choosing Lisp is a great career move friend. I think programmers like us who have tasted Lisp should advocate it more often. We should educate our friends on what they are missing out on. Great job Roshan!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: