How to set up a Common Lisp development environment for OSX? (Programming Newbie)
Asked Answered
H

2

6

So, I am very new to programming. I would like to learn Common Lisp. A few years ago, I used IDLE to write and run Python code. All it involved was downloading and installing one piece of software before I was ready to learn some Python.

With Common Lisp, things seem to be a lot more complex. I need to install:

  • GNU Emacs - some sort of text editor which I have to run in Terminal
  • SBCL - the compiler
  • SLIME - an add-on to Emacs, which lets me code in Common Lisp (????)
  • Quicklisp
  • The list seems to go on forever

Could somebody make this a simpler process for me to follow?

I installed SBCL and emacs both with the help of Homebrew. Now I'm just trying to get SLIME to work with everything.

Following the instructions from this site https://gist.github.com/CodeOmar/9477900#install-slime, I attempted to install quicklisp. But I can't activate SLIME. When I launch emacs, [M-x package-install RET slime RET], it says 'no match'.

Answer this question like I'm an 8 year old, please. If there is an easier way to set up a working Common Lisp environment, I would be glad to hear it.

Hyperbolism answered 14/12, 2015 at 8:59 Comment(3)
emacs uses lisp but isn't lisp. You can use any editor.Tiernan
I installed Slime from quicklisp ((ql:quickload "quicklisp-slime-helper")) after may failed attempts to do it manually.Casilde
Two years later: I suggest this list of available editors and this getting started guide on the Common Lisp Cookbook.Omnidirectional
H
4

The simplest way, in my opinion, to approach Common Lisp in the Mac OS X environment, is to install from the Apple Store the fine Clozure CL implementation. It is a full implementation of standard ANSI Common Lisp with a very simple, Mac-friendly IDE. When you have mastered the language, you can install Emacs with Slime, and choose to stay with Clozure CL or pass to SBCL (or use some other implementation).

Edited

Another possibility is to go with the integrated environment provided by the free versions of the commercial implementations, either from Franz (Allegro CL, Free Express Edition), or from LispWorks (LispWorks personal edition). They have limitations, however, and Allegro CL requires a non immediate installation. Moreover, they are best used with some advanced knowledge of Common Lisp.

Haematic answered 14/12, 2015 at 9:35 Comment(6)
Note that Allegro CL does not offer a native Mac integrated environment. The integrated environment is based on X11 and Gtk. It's same as the one for Unix/Linux. Allegro CL has a native environment for MS Windows and X11/Gtk. Thus only Clozure CL and LispWorks support a native integrated environment on the Mac, based on Apple's Cocoa libraries.Chambliss
@RainerJoswig you are right, but AllegroCL can be used also on Mac if XQuartz is installed.Haematic
You need to install GTK+, too. See: franz.com/support/documentation/10.0/doc/… See also how to update to Mac OS X 10.10 and that Allegro CL must be non-SMP to run the IDE... Basically nothing for a beginner...Chambliss
This is installed automatically by Allegro CL at start time (see documentation)Haematic
Recommendation questions are off-topic on Stack Overflow, so I don't want to encourage this kind of question and answer, but in a comment I don't mind saying at all that I used LispWorks on OSX for a number of years, and was very pleased with it. Moreover, I don't think it requires an advanced knowledge of Common Lisp; in some university courses, we recommended it to students in programming classes because it was so quick and easy to get up and running on the major desktop platforms (Windows, Linux, & OS X). That said, I use Emacs, SLIME, & CL-of-choice too, and it's worth the learning curve.Sciamachy
@JoshuaTaylor: full agreement. Plus: Additionally I also use Clozure CL with its native IDE.Chambliss
C
2

There used to be a "batteries included" distribution that accompanied Practical Common Lisp. I don't think it's particularly current, but I could be wrong.

Here's how I set up my lemon oder Emacs environment; I have a similar installation for VIM and SLIMV. Caveat: I have several CL implementations installed in nonstandard places.

(a) Use git to clone the current SLIME (mine happens to be in ~/elisp/slime, add your own seasoning to suite your tastes):

$ mkdir ~/elisp
$ cd ~/elisp
$ git clone https://github.com/slime/slime.git

(b) Add the following snippet to your .emacs:

;; Setup SLIME
;; Use the copy in my home directory.
(let ((my-slime-directory (expand-file-name "~/elisp/slime")))
(add-to-list 'load-path my-slime-directory)
(setq slime-backend (expand-file-name "swank-loader.lisp" my-slime-directory)))

;; If you installed your CL in a "standard place", such as /opt/local/bin,
;; you can delete the following form/6 lines. If you have multiple CLs installed,
;; this is an example of how you enumerate them; C-u M-x slime then lets
;; select one by name. Default is the first CL implementation in the list.
(setf slime-lisp-implementations
   `((ccl64 (,(expand-file-name "~/.local/bin/ccl64"))
             :env (,(concat "CCL_DEFAULT_DIRECTORY=" (expand-file-name "~/ccl"))))
     (clisp ("clisp"))
     (ecl (,(expand-file-name "~/ecl-experimental/bin/ecl")))
     (sbcl (,(expand-file-name "~/.local/bin/sbcl")))))

;; Mac OSX owns C-up and C-down, so arrange for history
;; navigation to do something useful via C-c p and C-c n.
(eval-after-load 'slime
  `(progn
     (define-key slime-prefix-map "p" 'slime-repl-backward-input)
     (define-key slime-prefix-map "n" 'slime-reply-forward-input)))

;; Useful slime custribs
(require 'slime-autoloads)
(add-to-list 'slime-contribs 'slime-repl)
(add-to-list 'slime-contribs 'slime-autodoc)
(add-to-list 'slime-contribs 'slime-fancy)

(c) If you need or want MELPA, this is what you should have in your .emacs:

;; Package and MELPA package archive setup:
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)

(d) Fire up Emacs and M-x slime.

HTH. :-)

Cosentino answered 16/12, 2015 at 18:2 Comment(1)
Hmm. All I need is a good excuse to create a Docker template.Cosentino

© 2022 - 2024 — McMap. All rights reserved.