Where to learn how to practically use Common Lisp
I am a C++ programmer trying to learn Common Lisp. I have looked at some books like Land of Lisp and read numerous online articles about the various virtues of Lisp. However, I need some advice.
Almost everything I have read about Common Lisp has to do with how amazing it is and how amazingly fast you can get stuff done with it and how it amazingly solved many problems with modern programming languages 30 years ago. Also how amazing macros are, and how every every programming paradigm (OO, functional, actor based or whatever, etc) can be used in Lisp, and how lists are the ultimate data structure. Basically treating Lisp like a research language and saying how different and revolutionary it is.
And all that stuff is probably true, but the problem is I haven't seen much stuff how to do practical things like read a file and split it into words and do some processing on it. I'm not interested in learning Common Lisp for the sake of learning Common Lisp, but for the sake of getting thing that I used to do in C++ done faster and with fewer errors.
So my question is what is the best resource (be it a website, book, anything) that focuses on teaching how to use Common Lisp to do common programming tasks like
And also on a less immediately practical note, how to implement common data structures in lisp such as an heap, stack, binary search tree, etc. However that may be just using Lisp's list operations like car
and cdr
in the right way. I don't know.
I highly doubt that any of this (with the unlikely exception of the last two in the list) is impossible with Lisp or people wouldn't love it so much. And the aforementioned stuff that I've read mentions plenty of real world software written in Lisp (Yahoo! web store comes to mind).
However, having programming in a (the?) imperative language before, I am anxious to get to using what new knowledge I get to write real-world applications. So what's the quickest way to learn writing practical software with Lisp?
By the way, I have seen Peter Seibel's Practical Common Lisp but, judging by the TOC, it only touches on some of the things I would like to learn to use Lisp to do.
One more question if I may (sorry if this is combining two questions into one), where can I find a reference to Lisp's functions and stuff?
And I really want to like Lisp.
I would propose reading 'Practical Common Lisp', since it already answers some of your questions.
There are probably three to four books you should read :
Common Lisp Reference
Manuals
Now the next thing you should check out is the manual of your Lisp implementation. It describes a lot of specific extensions: networking, threads, ...
Documentation for Common Lisp implementations:
SLIME (the Emacs-based Lisp-IDE) has a SLIME User Manual.
Documentation for Common Lisp libraries:
Libraries
For libraries use
Now looking at some of your points:
See the files and streams dictionary in the HyperSpec. WITH-OPEN-STREAM, READ, READ-LINE, READ-CHAR, READ-BYTE, READ-SEQUENCE, ...
Use above. See also: WRITE and related.
See above. DIRECTORY, pathnames, ...
Use for example the CLSQL library.
See the manual of your Lisp or use one of the portable libraries. See Quicklisp.
See the manual of your Lisp or use one of the portable libraries. See Quicklisp.
Depends. See Quicklisp or an implementation specific library.
See Hyperspec for file and stream operations. WRITE-BYTE, READ-BYTE. Open a stream as a binary stream.
Use one of the existing tools for that. Study existing parsers. There are many parsers written in Lisp, but not much in books about that (other than natural language parsers, which are described in the AI literature).
Depends. See Quicklisp or an implementation specific library.
Depends. See Quicklisp or an implementation specific library. -> FFI
Final advice: Read code from other authors.
Study other Lisp code. There is enough very diverse Lisp code out there. From web servers to music composition software.
Check out Cliki the Common Lisp wiki it provides a list of libraries available for Common Lisp which will help you accomplish all your items.
Also, you're going to want to check out the Common Lisp Cookbook (there's also a more updated version). It has a bunch of code for common tasks such as reading a file one line at a time, and Foreign Function Interfaces for interacting with libraries written in C.
You can write extensions for Lisp in C depending on which implementation you're using. Emacs-Lisp for example allows you to do that though it isn't Common Lisp. Usually what you want to do is write the code in Common Lisp and then optimize it as much as possible using different Lisp compiler declarations, or the other method where you use a foreign function interface.
Threading depends on which implementation you use, but I think most of them have threads now.
Hunchentoot is one of the best Lisp web servers and is pretty easy to get started with. You don't have to write any threading code yourself, you just have to write the HTTP request handler functions.
Someone compiled a list of GUI options for Lisp: