# Common Lisp Hyper Tutorial

> Published  Feb 02 2025, last updated May 05 2025  
> By Ryan Fleck <hello@this-site> and written without LLMs!  
> Original post at <https://ryanfleck.ca/chat-gpt/2025/common-lisp-hyper-tutorial/>  
> An article of astonishing quality and insight. Happy Hacking!


> Can you help me to rapidly learn common lisp, emacs, and SLY? Here's what I want to do and want a short manual for:
>
> 1. A brief description of SBCL and what the binary does
> 2. A brief description of quicklisp and how the system works
> 3. A brief description of SLY (the EMACS repl) and where it fits in
> 4. A hello-world example written with sly and emacs
> 5. Showing how to compile this hello-world to an executable on Debian

All content below is the response to this request.

{{< toc >}}


# Common Lisp, SBCL, Quicklisp, and SLY: A Beginner's Guide

## 1. What is SBCL?
SBCL (Steel Bank Common Lisp) is a high-performance Common Lisp compiler and runtime. The `sbcl` binary is used to:
- Start an interactive Lisp REPL (Read-Eval-Print Loop).
- Compile and run Lisp programs.
- Build standalone executables.

To install SBCL on Debian:
```sh
sudo apt install sbcl
```
You can start the REPL by typing:
```sh
sbcl
```

## 2. What is Quicklisp?
Quicklisp is a package manager for Common Lisp, similar to `pip` for Python. It simplifies library management.

### Installing Quicklisp
Run the following in your terminal:
```sh
curl -O https://beta.quicklisp.org/quicklisp.lisp
sbcl --load quicklisp.lisp
```
Then, in the SBCL REPL:

```lisp
(quicklisp-quickstart:install)
(ql:add-to-init-file) ;; Makes Quicklisp available in future sessions
```

### Using Quicklisp
Load a library (e.g., `cl-ppcre` for regex):
```lisp
(ql:quickload "cl-ppcre")
```

## 3. What is SLY?
SLY (Superior Lisp Interaction Mode for Emacs) is an Emacs extension for working with Lisp. It provides:
- A powerful REPL.
- Code navigation and debugging.
- Integration with SBCL.

### Installing SLY in Emacs
1. Open Emacs and run:
   ```
   M-x package-install RET sly RET
   ```
2. Add this to your `~/.emacs`:
   ```elisp
   (setq inferior-lisp-program "sbcl")
   (require 'sly)
   ```
3. Start SLY with:
   ```
   M-x sly
   ```

## 4. Hello-World in SLY and Emacs
1. Open Emacs.
2. Create a file `hello.lisp`:
   ```lisp
   (defun hello-world ()
     (format t "Hello, world!~%"))
   ```
3. Load the file in SLY:
   ```
   M-x sly
   ```
   Then, inside the SLY REPL:
   ```lisp
   (load "hello.lisp")
   (hello-world)
   ```

## 5. Compiling to an Executable on Debian
To compile your Lisp program into a standalone binary:
1. Create `hello.lisp` with:
   ```lisp
   (defun main ()
     (format t "Hello, world!~%"))

   (sb-ext:save-lisp-and-die "hello" :toplevel #'main :executable t)
   ```
2. Compile it with SBCL:
   ```sh
   sbcl --script hello.lisp
   ```
3. Run the generated binary:
   ```sh
   ./hello
   ```

---

This should get you started! Let me know if you need refinements or additions. 🚀



> Thank you for reading!  
> Find more content at <https://ryanfleck.ca/>  
> Source page: <https://ryanfleck.ca/chat-gpt/2025/common-lisp-hyper-tutorial/>  
> Site index: [llms.txt](https://ryanfleck.ca/llms.txt)