Getting Started with Lisp

There are good reasons why you want to learn Lisp. As Paul Graham said, the reason why you want to learn it is the same as the reason why you want to learn Latin. You probably won’t use Latin. But, the knowledge will enrich your experience with the language you use daily. You don’t need to learn Lisp to write the next big app or get your dream programming job, but knowing it will make you a better programmer.

Here are some inspirations you need to get started with Lisp.

Ok, now you are inspired and want to learn Lisp. Then, the problem is that Lisp has dialects. We need to choose one.

Lisp these days has three major dialects, Common Lisp, Scheme, and Clojure. They are similar and different. Here are some of the important differences that you may want to consider when you choose which one. At the end of the day, it really doesn’t matter which one you pick unless you need to work on a project that uses one of them. If you are learning it to broaden your programming knowledge, any of them is fine. In this post, I chose Common Lisp because I don’t want to have anything to do with JVM and it seems to be used in a real world scenario more.

Common Lisp
– Paradigm agnostic (both functional and OOP).
– Used more in real world problems.

Scheme
– Similar to Common Lisp.
– Used more in an academic context, like computer science and programming language research.

Clojure
– Favours functional programming.
– Runs on JVM (this is good and bad…)

Get started with Common Lisp

(1) Install SBCL

Use command line for Linux and Mac. Use LispStick for Windows. SBCL (Steel Bank Common Lisp) is a high performance Common Lisp compiler. It provides an interactive environment and runs Lisp through the command line.

# mac
brew install sbcl

# linux
sudo apt-get install sbcl
```

(2) Install Quicklisp (package manager)

curl -o /tmp/ql.lisp http://beta.quicklisp.org/quicklisp.lisp

sbcl --no-sysinit --no-userinit --load /tmp/ql.lisp \
       --eval '(quicklisp-quickstart:install :path "~/.quicklisp")' \
       --eval '(ql:add-to-init-file)' \
       --quit
```

(3) Run it in an interactive mode

We can just type `sbcl` in the bash. Then run whatever. Here is the hello world!

(format t "Hello World")

You can exit from REPL by calling quit.

(quit)

(4) Run it from a file

Create a file with .lisp. For an IDE, VS code with lips extension will be sufficient to start with.

fib.lisp

(defun fib(n)
  "Retun the nth Fibonaccie number."
  (if (< n 2)
    n
    (+ (fib ( - n 1))
      (fib (- n 2))
    )
  )
)

Then, run the function with `sbcl`

sbcl --load fib.lisp

Then, run the function in the console.

(fib 30)

(5) Compiling Lisp

Lisp is both compiled and interpreted language. We can run it interpreted or compiled.

Start the REPL and this will run the function in an interpreted way.

(load "fib.lisp")

This will compile the file in the same folder. It will create `fib.fasl` file.

(load (compile-file "fib.lisp"))

Once you have the file, you can load the compiled file.

sbcl --load fib.fasl

Ok, that’s the basic. This will give you enough to get started with Lisp!

Git
How to specify which Node version to use in Github Actions

When you want to specify which Node version to use in your Github Actions, you can use actions/setup-node@v2. The alternative way is to use a node container. When you try to use a publicly available node container like runs-on: node:alpine-xx, the pipeline gets stuck in a queue. runs-on is not …

AWS
Using semantic-release with AWS CodePipeline and CodeBuild

Here is the usual pattern of getting the source from a git repository in AWS CodePipeline. In the pipeline, we use AWS CodeStart to connect to a repo and get the source. Then, we pass it to the other stages, like deploy or publish. For some unknown reasons, CodePipeline downloads …

DBA
mysqldump Error: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109)

mysqldump 8 enabled a new flag called columm-statistics by default. When you have MySQL client above 8 and try to run mysqldump on older MySQL versions, you will get the error below. mysqldump: Couldn’t execute ‘SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM ‘$”number-of-buckets-specified”‘) FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = ‘myschema’ AND TABLE_NAME = ‘craue_config_setting’;’: Unknown …