views:

1204

answers:

4

I've decided to get back into LISP (haven't used it since my AI classes) to get more comfortable with functional programming in general, so I downloaded Lisp In A Box (which we actually used in a previous class) which comes with CLISP and Emacs.

When I run it, it says:

Connected on port 1617. Take this REPL, brother, and may it serve you well.

What the? So I looked on the Lisp In A Box webpage more closely and found this:

SLIME is an integrated development environment for Emacs which interfaces with a Common Lisp implementation over a network socket. Lots of information about SLIME can be found at the SLIME node on CLiki. The manual for SLIME is available in PDF format online.

I somewhat understand what SLIME is (some sort of extension to emacs, right?) But why in the world is a text editor starting its own server and connecting to it?

+8  A: 

The purpose is so that Lisp will be running in parallel.

Slime connects to the session and then you can have the same environment, definitions, etc from many different windows (or machines even). This means that you can start up your application and debug it on the fly, for instance.

For further information, look at this blog.

dsm
Typically an IDE would run an external compiler/interpreter, or capture stdin and stdout to provide a REPL. What SLIME is doing just seems ridiculous. Why would anyone want to connect to a LISP interpreter over a network?
Cybis
Why not? I can think of several reasons why I'd want to connect to a remote Lisp process.
Kyle Cronin
+1  A: 

You get a REPL (read-evaluate-print-loop) running in parallel, so that you can compile and test code snippets on the fly from your editor. "Practical Common Lisp" (freely available on the web) has a good explanation for this, and it is a very good book for learning Lisp.

Svante
+5  A: 

Sockets are more flexible than pipes. For one, SLIME lets you connect to Swank servers on the network, which is very useful for doing live fixes on remote machines with long-running processes (such as web servers). Given this, why would you add another layer of complexity by abstracting communication in such a way as to support both pipes and sockets? It's not like pipes are any simpler to program than sockets, anyway.

Matthias Benkard
Slime was meant to interface with a Swank server, which allows for debugging and patching a live, long-running process on-the-fly, correct? Isn't this dangerous? I certainly wouldn't want to just write and execute code on-the-fly, on a production web server, potentially causing it all to crash.
Cybis
Furthermore, isn't this a security issue? Anyone could connect to the process and execute arbitrary LISP code. Why wouldn't there by some sort of authentication/authorization mechanism for this, if that's what swank was meant for?
Cybis
Of course, changing stuff on the fly is dangerous, but killing the process and restarting it isn't any better, no? In both cases, you'd hope that you've tested the change somewhere else before committing it. :)
Matthias Benkard
Second, it's true that sockets are more of a security issue than pipes, but Swank usually listens on 127.0.0.1. Therefore, you'd probably (have to) open an ssh tunnel to the server as needed. It would still be an issue on a shared server, though, where you can't restrict access from 127.0.0.1.
Matthias Benkard
By the way, I've been thinking for a while that support for named pipes would be nice to have, as one could use them to restrict access by file permissions on a shared server.
Matthias Benkard
+2  A: 

Well, Slime starts Lisp process to give you integrated development environment. So that you can test and debug your code on the fly and also be able to inspect objects. I think architecture with sockets was chosen for better portability between different lisps (Btw, Slime also supports Clojure and MIT Scheme ) and OS-es (Slime works on Windows too). Also it allows cross-platform development - you can test your software on target architecture from your Emacs.

So I think, that this decision is great, you just should not put swank (Slime back-end) on production servers.

Anton Nazarov