Primarily technical blog on Lisp, .NET, C# development.

Tuesday, July 21, 2009

Setting up SBCL and Emacs on Ubuntu 9.04

I am always forgetting how to do this and every now and then I am finding myself installing LISP somewhere so here it goes my how-to so I don't have to google for it anymore... Nothing wrong with googling something though.

1) sudo apt-get install emacs22-gtk sbcl slime

2) add the following lines to .emacs on home folder.

(setq inferior-lisp-program "/usr/bin/sbcl")
(add-to-list 'load-path "/usr/share/common-lisp/source/slime/")
(require 'slime)
(slime-setup)

Done.

To test your installation:

1) Open emacs: (Applications -> Accessories -> Emacs 22 (GTK)
2) Press ALT + X
3) type slime
SBCL will start you should get a prompt like this:
; SLIME 2010-01-19
CL-USER> 
4) On the prompt type "Hello, World."
You should see this:

; SLIME 2010-01-19
CL-USER> "Hello, World."
"Hello, World."
CL-USER>
5) Congratulations! You have just ran the first obligatory application on any language, but in Lisp!
6) To quit SLIME+LISP: press , then type quit
7) To quit emacs: CTRL+X CTRL+C

Tuesday, May 19, 2009

Outside-in

I am trying to read OnLisp by Paul Graham again and I really liked the turn your imperative code outside-in in chapter 3.

This is almost a reminder to myself.

Let's say I have an imperative function:
(defun imp-fn (x)
(let ((a 2) result)
(setf result (+ x a))
result)

I have seen a lot of code like that.

Turning it outside-in:
1) It returns result what is result?
we can replace it by the expression: (+ x a)
2) what is a?
we can replace it by its expression: (+ x 2)
3) then the result is:
(defun not-so-imp (x)
(+ x 2))

This is a very simple example but the idea remains the same. The OnLisp book has another example which is better than this one, but this one is good enough to show off the idea.

Thursday, May 8, 2008

Books on LISP

Getting back to the subject of what books should I read if I want to learn LISP. Now I have a better improved list I feel it will make the transition from anywhere to LISP easier.

In the order I would suggest a friend to start:

1) A funny warm up of how fun it is to LISP.
2) The beginning of the beginnings (even if not a programmer):
3) Still on beginning but a day after:
4) Getting practical:
5) Getting deep:

Good reading!

Tuesday, March 25, 2008

Weblocks first impressions

On a previous post I was commenting on how easy it was to prototype a domain model in lisp. This happens primarily due to its REPL (read-eval-print-loop) way of programming.

A few days ago I started playing with weblocks which is, as it is referred on its website, "A continuations-based common lisp web framework". The shift of paradigm from page-centric development to something different at first sounded just like something interesting to learn about. Because of that, I tried it a couple of months ago, without much success, trying to replace a league management system I built using only hunchentoot by itself.

Today, with a little bit more experience in lisp I could manage to build a simple prototype with some of the entities of a domain model I was working on. The results were really impressive, primarily due to the straight forward approach to get the presentation done.

At first, the whole composite widget centric approach seems overwhelming but at some point it sinks in and we can see how easy it is to "compose" the web user interface for an application using weblocks without having to think about pages and getting data back and forth from the web session.

Despite the fact that it is still a work in progress, I really liked the feeling of working on a web application and not having to deal with html or ajax to get a nice presentation in minutes. (In my case, one hour, because I had no clue how to use it...)

Anyway, personally I really like building software without having to work on the UI manually. Auto-generation based on the model or on view definitions seems to be the more productive approach to deliver enterprise based applications. I wish one day we could have weblocks and cells-gtk, for example working against the same view abstraction and being able to generate desktop and web user interfaces in a seamless way.

Monday, March 3, 2008

Uninstalling on Windows XP without Add Remove Programs

I really don't like that Add Remove Programs applet. It is really slow and does not have even an option to remove orphan entries from the registry. Since I tend to install/uninstall the software I develop a lot, it is a pain to go to that sluggish control panel applet.

Well, it was, now I found two great options:

1) C:\windows\installer right-click header and select Author, Title, Comment, find the uninstaller and execute it.

2) Safarp (blazing fast, don't have to install if you don't want too)

There are plenty other options, I know. Check out the original articles where I got this great information from:

Saravana's blog
Download Squad

Friday, February 29, 2008

Why prototype in LISP

One of the features I like the most in LISP is to be able to change the code in the middle of the running process and to be able to keep evaluating the functions and variables with the new behavior on the fly. This is an extremely powerful tool when you are trying to figure out the right structure for a given problem. You can play with the different structures and still be able to keep the application running and see how it reacts to the changes you make. It is like running in a self-evaluating forever debug mode. But that is exactly what LISP is, isn't it?

I can say that when I think about prototyping at the model designing level I am more and more choosing to do it in LISP and then, when I feel more confident about the model port it to c# than to start straight in C#. It is simply more productive in my opinion.

Monday, February 25, 2008

Lisp project template with Emacs

In my first post I was describing the environment I had to use Lisp. After a few issues, usually related to the fact that Eclipse is really a memory hungry application. I moved back to the Emacs + Slime combination. The only difference from what I used to do prior using cusp is that now I work with a "project" file, just the way eclipse + cusp does. I like the idea of working with an asd file to define the files and dependencies in my project and it is very effective to load and compile all lisp files from my project and start being productive right away.

In order to get there I created this symbolic link on my .sbcl/system folder to point to my asd file.

By doing this you are able to load your project using asdf.