Hello World in Lisp

Published on 08 April 2018 (Updated: 15 May 2023)

Welcome to the Hello World in Lisp page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

(format t "Hello, World!")

Hello World in Lisp was written by:

This article was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

Unfortunately, Lisp has many flavors which means the following implementation of Hello World will likely only be applicable to handful of those flavors:

That said, I'm happy to dig into this implementation of Hello World in Lisp.

First things first, we have the format keyword. In Common Lisp, format is basically the equivalent to printf in C. It basically takes some string and outputs it to some destination.

That brings us to this mysterious letter t. According to gigamonkeys, t is actually the destination of the output. More specifically, t indicates standard output. Another option is NIL which causes the string to be returned.

Finally, we have our Hello World string. This is obviously what gets printed to standard output.

How to Run the Solution

If we want to try it ourselves, we can copy the code above into an online Common Lisp compiler. The one I linked is in CLISP, but it gets the job done.

Alternatively, as mentioned before, we can download a copy of Steel Bank Common Lisp as well as a copy of the solution. Assuming SBCL is in the path, we can run a lisp file like a script as follows:

sbcl --script hello-world.lsp

And, that should produce the "Hello, World!" string on the command line.