SLIME on the console - linux

Does anyone have experience using SLIME on the console for Common Lisp? I'm trying to go through Practical Common Lisp but the commands in the book don't seem to work for the console version of emacs/SLIME. I suppose my question is: is there somewhere where I can find documentation specifically for SLIME on the console? Or if you have a suggestion for a completely different approach on the console, I'm all ears.

I assume you mean running slime with emacs on the console ie without X. Slime requires emacs (eq slime 'superior lisp interaction mode for emacs').
I ran it with emacs -nw (which just uses the terminal and no X facilities that I can see) and slime worked fine (Ubuntu 10.04 X86-64).
Are you running in emacs?
Is slime set up in your .emacs file?
Did you start slime via alt-X slim?
Tell us more about what you did and what you have set up and what output you get and we may be able to help more.

Related

OCaml with Cygwin problems

I recently started using OCaml on my Windows machine and I have been using cygwin for compilation and execution of my programs. I recently had to create a program which takes user input from stdin using Lexing.from_channel stdin. The Problem I am running into is that I type in the input, but nothing happens. After checking out some things I found that there is no indication the input is being finished so the program is just waiting on more input. I have tried ctrl-D after I type in the input and nothing happens and ctrl-z which just displays Stopped and ends the program. Additionally, when i use these keys cygwin will often crash. Does anyone have an idea on how to indicate end of input for user inputs in OCaml?
My personal recommendation: if you can access Unix or Mac OS X, use them. Using OCaml over Windows is pain unless you get paid for it. Using OCaml in a virtual Unix environment like VMWare is another option.
Currently we have 3 OCaml flavors in Windows: Native MS, Native MinGW and Cygwin. See http://caml.inria.fr/distrib/ocaml-4.01/notes/README.win32 for details.
Any question about OCaml in Windows, you must first state clearly which flavour of OCaml you use. I suspect you use MinGW OCaml over Cygwin. With this combination I have the exactly same troubles you have described.
Ctrl-D is not considered as closing stdin in MinGW OCaml, since it is Windows console app.
Ctrl-Z is to close stdin in MinGW OCaml, but it is first fetched by your Cygwin terminal, then it suspends the process
Once 'Stopped' by Ctrl-Z, normally the OCaml process and the terminal go into strange states and you have to kill them. (I want to walk away from it, rather than tracking what is really happening.)
If you execute your MinGW OCaml apps over Command Prompt, your stdin works fine.
If you prefer Cygwin and your work does not involve with selling your binary executables, using Cygwin OCaml is the way to go. But still, there are very few people working there. I am afraid that any Cygwin OCaml specific questions may not be answered even in StackOverflow.
Maybe my view is too pesimistic. I hope some OCaml + MingW experts would give some more insights.

Graphicall shell for Haskell under Linux

Is there some graphical shell like ghci for Haskell and Linux? I know about Winghci and it is very good interpreter but it is Windows only.
Regarding "what does WinGHCi do that GHCi does not?":
The command prompt, user input and program output are different colours. I can't begin to tell you how helpful this is when you're scrolling through huge pages of text trying to find the last command you typed. I wish more Haskell programs would produce coloured output...
You can load files using an actual GUI, rather than having to memorise a 200-mile long file path.
It has a whole bunch of buttons and menu items for common operations, which can be useful if you're new to GHCi and don't know the corresponding command names.
On Windows, terminal windows look horrifyingly ugly, while WinGHCi does not. Whether this problem exists on Linux is a matter of opinion.
Regarding the actual question asked: I'm not aware of any nice GUI tool for GHCi on Linux. Probably the best you can do is use the Emacs operating system; I'm sure somebody will have built some kind of GHCi support for that by now...
ghci runs fine on Linux, although I don't know of any graphical versions of it.
A few options if you want more features:
Use a powerful terminal emulator
Integrate ghci into your editor with something like 'Emacs Haskell Mode' or 'SHIM for Vim'
Have you heard of HUGS ? I only used it for Windows, but on the website you can download it for some Linux distributions, too.
It's a long time ago since I used it, but as far as I can remember it was an easy to use but powerful and fairly good documented interpreter.
hope this helps

Install lisp on my linux machine

I use Vim as my editor. "Practical common Lisp" suggest installing Lispbox, I don't know how to use emacs, don't know how to run lisp code with that T.T after that i find lisp plugin for vim called limp.vim with a long and hard install instruction :((
Finally i installed "Clisp" and i can run lisp code with a simple command:
clisp ~/test.lisp
But how to compile it? Is lisp a compiled language? sorry, i just don't know anything, i'm newbie in lisp
Can anybody tell me what exactly need to install lisp on my linux? What's SLIME, sbcl,.. etc.?
Install and learn the following things:
SBCL the compiler
install a binary from http://www.sbcl.org/platform-table.html Once your used to it, compile from source and keep the source around. This way you can easily jump to the definitions of functions of SBCL with M-. in Emacs.
Emacs
watch this screencast to see someone implementing a raytracer Raytracer in Common Lisp
quicklisp.lisp http://www.quicklisp.org/beta/
This is the new package management. When I started it wasn't there. Now we have it and you should use it. It makes things a lot easier.
Run 'sbcl --load quicklisp.lisp' and then enter (quicklisp-quickstart:install) press enter
and then run (ql:add-to-init-file)
SLIME runs within Emacs.
Try installing it with quicklisp. Read its manual and figure out what to write into your .emacs file so that it automatically starts when you open a lisp file. Optionally watch a screencast.
Paredit
Seriously, you have to learn that (even if the guy in the raytracing screencast didn't use it). You should start with ( , this will make two parenthesis. With M-( you can enclose an existing s-expression. C-k cuts the s-expression behind the cursor and with C-y you can insert it anywhere.
ASDF
This is the make for lisp. You should learn how to define a system in an ASDF file.
Reference
I printed this booklet, Common Lisp Quick Reference. It's very concise.
Lisp can be compiled but that is not "necessarily" so. Clisp is just one Lisp running on Linux. SBCL is another one. And SLIME is the interface from Emacs to one can say all Lisps on Linux.
You can use Slime with SBCL, CLisp, Lispworks and Franz Common Lisp.
You can even learn much of Lisp just by using Emacs. It has it's own Lisp-dialect Elisp, but you can use Common Lisp compatibility libraries also.
Emacs probably is a preferred IDE for Common Lisp because of it's use of an internal Lisp.
If you want one software to install you should check LispWorks or Allegro Common Lisp (formerly Franz Common Lisp).
Can anybody tell me what exactly need to install lisp on my linux?
The other answers have described what SLIME, sbcl etc. are. But I wanted to give a concise answer.
To install clisp on Ubuntu, just run sudo apt-get install clisp. Nothing else is necessary to run Lisp. For other distros find clisp on their relevant package managers. However do not be surprised not to find clisp on some distros, for example the Amazon Linux AMI appears not to have clisp. clisp ~/test.lisp is all you need to run Lisp.
Nowadays it is more popular to use SLIME and ASDF. As a beginner you will not need to use them yet. SLIME is a fancy editor for Lisp, and ASDF is a package manager. It is much easier to setup Clisp given that it literally takes just one line to install and one line to run. SLIME and ASDF are more involved and take more time to learn and setup. I personally would recommend starting off with using Clisp and only later on using SLIME and ASDF so that you will gain a better understanding of Lisp which will make using SLIME and ASDF much easier. When you are ready, then I recommend reading the documentation of SLIME and ASDF.
You can learn lisp using the idioms you're used to from other languages (editing, compiling, running). In the long run, lisp offers other choices, which you may come to prefer.
So long as Vim will balance ()'s as you type, it has the only feature you really need in your editor.
Eventually, you might well choose to look into SLIME (which needs emacs), but it's certainly not necessary to get started.
You can choose any 'Common Lisp' implementation (of which clisp appears to be one you already have). Some will compile to a standalone binary (as you may be used to from C like toolchains), but most will depend on the runtime the lisp comes with, even when the .lisp file is compiled (similar to Java, Python, etc).
You can lookup 'compile-file' in your lisp's documentation to see how to compile .lisp files. Common Lisp's include the compiler in the language runtime.

Linux programming - getting started, how?

I've taken the plunge and installed Linux (Linux Mint 9 if that's important) on one of the boxes - and I'd like to start some small-time programming... but where to start.
My background:
Mostly LOB-applications in C#/WPF
Some XAL-basic
A wee bit of VB/VBA and SilverLight
I would like to turn to a new programming language - but still focused on desktop applications.
What I need:
An editor - preferably with good intellisense
A programming languages and the resources to get started
If anyone can point me in the right direction, I'd be happy for a little push...
EDIT:
Thanks for all the advice - I've come up with the following:
I'll start out with Python - and use Vim for the editor
I'll definetly try out Vala and Perl later and have MonoDevelop as backup editor - and if all else fails, I'll turn to C++. I've upvoted all answers as they all helped me.
EDIT2:
Okay - Vim was a bit too hardcore... Installed Cream on top.
Unlike the Windows world, where everything is designed to be Windows-only, I think it is quite typical to find that the rest of the world designs software to specifications, not to implementations. If you are developing in Java, then it doesn't matter what platform you intend to use, and Eclipse and NetBeans provide excellent tooling for Java on all platforms, Linux included. If you are developing in C++, then Boost and Qt provide excellent cross-platform support. If you need to go outside of Boost or Qt, then before delving into Linux-specific features, it is best to target the Single UNIX Specification also known as IEEE Std. 1003.1 POSIX, which will ensure that your application not only runs on Linux, but also on any UNIX-compliant operating system (including Mac OS X, FreeBSD, Solaris, and others).
As for IDEs and other editors... I think most programmers on UNIX platforms build from the commandline (using CMake, Make, scons, or some other standard build tool); however, there are plenty of IDEs with support for those that can run such tools automatically. Anjuta C++ and KDevelop are probably the easiest IDEs to use on Linux. Emacs (emacs, emacs-gtk, xemacs) and Vim (vim, gvim) provide a great deal of power and flexibility, but take a little bit more time to get used to. You might also want to consider a basic text editor such as GEdit (Gnome) or Kate (KDE); GEdit, though billed as a simple text editor, supports some more advanced coding features via a number of plugins. I don't recall whether it supports autocompletion, but it does support line numbers, automatic indenting, using spaces instead of tabs, commenting a block of code en-masse, and executing a Makefile with a shortcut.
Depends on how much you want to learn (from the easiest option to the hardest one):
Just use C# via Mono - that gives you access to most of the POSIX interfaces via Mono.UNIX, access to GTK# so you can do desktop apps, access to many linux libraries, so you can do more advanced stuff / integrate better. (you can program in Monodevelop - it's a Sharpdevelop clone, kind of VS-ish)
Learn Vala - it's a language compiled down to C, very similar to C# but closer to the bare minimum. It's gathers anti-MS people who wanted a response to C# IMHO. (never really used it, but apparently there's a Vala plugin for Monodevelop and the language itself is becoming more popular)
Learn Python - it's a scripting language. It's got bindings to most popular libraries (also GTK and QT) (IDE: anything that can edit text - you won't get good intellisense from a dynamic language anyways)
Learn C++ and QT, or C and GTK - although those are very low level languages where you will spend a lot of time just getting used to the environment. (IDE: Anjuta, Kdevelop, Monodevelop with C++ plugin, Eclipse+CDT, emacs, vim, etc. - anything goes really)
If you want "something new", but don't want to spend loads of time learning a completely new environment, I'd recommend trying out Vala. If you're more curious about different styles, go for Python, which I think has a very good tutorial for new people (but not new to programming): Tutorial or Beginner's Guide. With Python you also have an advantage of having the whole environment available in packages in any distribution, no such luck with Vala (yet).
Try perl and python and see what appeals to you. Learn bash to get around happily at the command-line. If you're feeling adventurous, give C/C++ a shot.
As for editors, this will probably spark up a holy war, but if you're using at the command line, check out vim and emacs, pick one, and lament never making friends of those in the "enemy camp." :-)
I say Python + Emacs or gEdit (what ever suits you)
Linux Mint is a KDE environment, right? That would make it pretty convenient for you to get started writing KDE apps in C++. The Qt toolkit which KDE is based on is widely considered to be relatively developer-friendly, which should make it easy for you to get started.
If you want to go on that route, I'd suggest downloading KDevelop, which is KDE's IDE (optimized for developing KDE programs, but it can handle several different languages). Alternatively, you could use Eclipse, which has C++ capability. You can find tutorials on how to develop KDE apps at http://techbase.kde.org/Development/Tutorials. (Unfortunately I think those are not as good as the documentation they used to have before KDE 4 came out, but it should be enough to get you started.)
EDIT: Come to think of it, you may want to try your hand at writing some C++ console (non-GUI) applications first, since it's probably easier to get comfortable with basic C++ before you jump into GUI programming. Given your experience, it shouldn't be too hard to pick up. Unfortunately I don't know of any particularly good resources to learn C++ with, but I'm sure that information is somewhere on this site, and KDevelop or Eclipse would work fine as an IDE for simple C++ console apps as well.
Weird that nobody suggested ALP, even if it is a bit outdated, it teached me a lot of things regarding the UNIX way of programming.
First, Learning C is a MUST!
Perl is underused for most stuff and you'll want to learn BASH Shell Scripting instead.
Grock the C code of existing (stable, well-written software) example is the Linux kernel itself! Google "Linux LXR"
Once you learn the basics to C (in Linux) the manpages are an invaluable resource. Just do man printf for information on writing characters to the screen, for example.
If you are talking GRAPHICAL GUI Programs, you need to learn GTK+ or one of the many cross-platform GUI toolkits (e.g. wxWidgets). Do not learn to program the X Windows System directly unless you are crazy.
For text editors, I like Komodo Edit and SciTE.

Using Vim for Lisp development

I've been using Lisp on and off for a while but I'm starting to get more serious about doing some "real" work in Lisp. I'm a huge Vim fan and was wondering how I can be most productive using Vim as my editor for Lisp development. Plugins, work flow suggestions, etc. are all welcome.
Please don't say "use emacs" as I've already ramped up on Vim and I'm really enjoying it as an editor.
Limp aims to be a fully featured Common Lisp IDE for Vim. It defaults to SBCL, but can be changed to support most other implementations by replacing "sbcl" for your favourite lisp, in the file /usr/local/limp/latest/bin/lisp.sh
When discussing Lisp these days, it is commonly assumed to be Common Lisp, the language standardized by ANSI X3J13 (see the HyperSpec, and Practical Common Lisp for a good textbook) with implementations such as GNU Clisp, SBCL, CMUCL, AllegroCL, and many others.
Back to Limp. There are other solutions that are more light-weight, or try to do other things, but I believe in providing an environment that gives you things like bracket matching, highlighting, documentation lookup, i.e. making it a turn-key solution as much as possible.
In the Limp repository you'll find some of the previous work of the SlimVim project, namely the ECL (Embeddable Common Lisp) interface, merged with later releases (7.1); Simon has also made patches to 7.2 available yet to be merged. The ECL interface is documented in if_ecl.txt.
Short-term work is to do said merging with 7.2 and submit a patch to vim_dev to get it merged into the official Vim tree.
Which leads us to the long-term plans: having Lisp directly in Vim will make it convenient to start working on a SWANK front-end (the part of SLIME that runs in your Lisp, with slime.el being the part that runs in the editor - the frontend).
And somewhere in between, it is likely that all of Limp will be rewritten in Common Lisp using the ECL interface, making Limp easier to maintain (VimScript isn't my favourite) and being easier for users to customize.
The official Limp site goes down from time to time, but as pointed out, the download at Vim.org should always work, and the support groups limp-devel and limp-user are hosted with Google Groups. Don't hesitate to join if you feel you need a question answered, or perhaps even want to join in on development. Most of the discussion takes place on the limp-devel list. If you're into IRC, I'm in #limp on irc.freenode.net as 'tic'.
Good luck!
You might give slimv a break.
Here's a cool diagram by Xach that sums up the current situation.
Here we are 9 years later, and now we have Vim 8 and Neovim, both providing the ability to interact with plugins asynchronously.
vlime is an excellent, feature-rich plugin that takes advantage of the new async interface to provide a SLIME-like dev environment for Common Lisp.
Check out the Limp plug-in:
http://www.vim.org/scripts/script.php?script_id=2219
SLIME for EMACS is a wonderful tool for LISP programming. The best part is sending code written in your editor straight to a live LISP session. You can get similar behavior out of Vim using the tips here:
http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/
I adjusted my own script so that I can send to either a SBCL or Clojure session. It makes you much more productive and takes advantage of the REPL.
":set lisp" starts the lisp indentation mode for Vim. But it won't work with some dialects like Clojure. For Clojure, use VimClojure.
Some people like LIMP also.
:set lisp
Vim has a mode to help you indent your code by Lisp standards.
Also, I modify the lispwords to change how vim indents my code.
:setl lw-=if (in ~/.vim/ftplugin/lisp.vim)
You can give Emacs with Vim emulation a try, is not perfect, but it may be somewhat familiar. I think Lisp shines if you use something like Slime or DrScheme doing iterative development, all other editors feel just wrong.
Vim add-ons: Rainbow Parentheses, Lisp syntax
SBCL add-ons: rlwrap, sb-aclrepl
Workflow: Ion3 (or some other tiled WM) with multiple terminal windows.
Edit Lisp in Vim
Switch to Lisp window (using the keyboard of course)
Use C-r to recall the line to reload the ASDF system in question so your changes become active.
Use X Window copy/paste for small snippets/changes.
Use DESCRIBE, TRACE and APROPOS heavily.
Repeat.
There seem to have been attempts at having a SLIME-like integration of Lisp in Vim, but none have really gone as far as needed to be really useful. I think ECL's integration has been done, though, but not committed upstream.
You should find all relevant links from Cliki's page about Vim.
I know you said not to tell you to use Emacs.
Use Emacs.
Serious, the SLIME setup for Emacs is pretty much the standard development platform for Lisp, and for very good reason.

Resources