A very hard start (How to compile and execute CCL)
-
- Posts: 21
- Joined: Wed Jul 29, 2015 7:25 am
A very hard start (How to compile and execute CCL)
Hello everyone, I'm an italian student of information technology, trying to walking on my own through the hard and full of obstacles path of the new lisp programmer. I've started my study just a couple of day ago following a very good manual but, unfortunately, I'm now lost on a dead end. After have spent googling all the day along with a very very low success, I've registered myself here hoping to find the help I'm searching.
Well... I don't think to have a big deal to solve... however, I have no idea how to face it. After have been approaching Lisp (Common Lisp) from a theorical point of view, I wuold like now to practice it. I downloaded the interpreters for Clozure CL and for SBCL but, actually, I can just write my programs directly in the REPL. I wuold really like to compile and load an external source, but I wasn't been able to find any documentation or explanation about it. Could you maybe give me any sort of help? Actually I'm trying to use LispBox with Clozure CL, as it seemed to me to be the simpliest approach... but I'm open to any suggestion you can give me.
Greetings and many thanks.
Well... I don't think to have a big deal to solve... however, I have no idea how to face it. After have been approaching Lisp (Common Lisp) from a theorical point of view, I wuold like now to practice it. I downloaded the interpreters for Clozure CL and for SBCL but, actually, I can just write my programs directly in the REPL. I wuold really like to compile and load an external source, but I wasn't been able to find any documentation or explanation about it. Could you maybe give me any sort of help? Actually I'm trying to use LispBox with Clozure CL, as it seemed to me to be the simpliest approach... but I'm open to any suggestion you can give me.
Greetings and many thanks.
Re: A very hard start (How to compile and execute CCL)
Hi J.Owlsteam, welcome to the wonderful world of Lisp!
See COMPILE-FILE and LOAD how to compile and load Lisp files from the REPL, but this is a very tedious way.
The most-often-used combination of Lisp tools are:
There is a list of tutorials in the CLiki under Getting Started.
- edgar
See COMPILE-FILE and LOAD how to compile and load Lisp files from the REPL, but this is a very tedious way.
The most-often-used combination of Lisp tools are:
- Emacs + SLIME for editing, compiling, and testing code. There is also Vim + slimv, but Emacs + SLIME is used much more often.
- ASDF for managing Lisp projects (called "systems" in Lisp) that consist of more than one Lisp file. ASDF is something like "make" for C/C++ or "ant" for java.
- Quicklisp for downloading, compiling and loading external libraries. Quicklisp internally uses ASDF to manage Lisp systems. Don't be afraid of the "beta" in its version number, Quicklisp is very reliable.
There is a list of tutorials in the CLiki under Getting Started.
- edgar
-
- Posts: 21
- Joined: Wed Jul 29, 2015 7:25 am
Re: A very hard start (How to compile and execute CCL)
Many many thanks, the guide in CLiki was very clear and useful, finally I succeded in going through the setting of emacs+slime also if... it appears that Listbox had already done it by itself, but now I'm a bit more conscious of that... well... it also appears that I won't be able to procede any further withouth learning to use this emacs+slime. If possible, I wuold like to avoid that since it won't be a real necessity... it seems a little heavy to approach and I don't need many development tools; well, If I could just put some files together and calling them with a command in the repl, I wuold be more than happy
About that, I gave a look to the functions you suggest me and I managed to use them with one simple file, so it is just much much useful, thanks you I guess the next step is searching about this ASDF, if I want more files to call each other... I'll try to go on in my reasearch!
About that, I gave a look to the functions you suggest me and I managed to use them with one simple file, so it is just much much useful, thanks you I guess the next step is searching about this ASDF, if I want more files to call each other... I'll try to go on in my reasearch!
Re: A very hard start (How to compile and execute CCL)
When I started to write my own Lisp programs I just wrote the entire code into *one* single file that I then loaded from the REPL with:
The default directory where LOAD looks for files is stored in a variable named *DEFAULT-PATHNAME-DEFAULTS*. But the Common Lisp pathname system is a bit over-engineered (to say it carefully), so only try to mess with relative file and directory names when you have mastered the basics.
You don't even need to explicitely compile your Lisp code, you can load and execute plain source code files. Of course compiling can make the execution speed faster (if the Lisp implementation compiles to native machine code) or only the loading faster (if the implementation compiles to virtual byte code).
Quicklisp is very handy to load and manage Lisp libraries from the internet. Quicklisp is much easier to use than ASDF. Quicklisp has a quickproject option that generates boilerplate ASDF definitions for small and medium Lisp projects what saves you from writing your own ASDF stuff.
You only need ASDF when your projects become so big that the order in which the different Lisp files are loaded becomes important. After more than twenty years of Lisp programming I still need to look-up all the details in the manual whenever I have to write an ASDF system definition.
The most up-to-date comparison of the different Common Lisp implementations are:
Code: Select all
(load "/full/path/to/my-file.lisp")
You don't even need to explicitely compile your Lisp code, you can load and execute plain source code files. Of course compiling can make the execution speed faster (if the Lisp implementation compiles to native machine code) or only the loading faster (if the implementation compiles to virtual byte code).
Quicklisp is very handy to load and manage Lisp libraries from the internet. Quicklisp is much easier to use than ASDF. Quicklisp has a quickproject option that generates boilerplate ASDF definitions for small and medium Lisp projects what saves you from writing your own ASDF stuff.
You only need ASDF when your projects become so big that the order in which the different Lisp files are loaded becomes important. After more than twenty years of Lisp programming I still need to look-up all the details in the manual whenever I have to write an ASDF system definition.
The most up-to-date comparison of the different Common Lisp implementations are:
- CLiki: Comparison of actively developed Common Lisp implementations provides a quick overview
- Dan Weinreb's Lisp Survey has more detailed tests and explanations
-
- Posts: 21
- Joined: Wed Jul 29, 2015 7:25 am
Re: A very hard start (How to compile and execute CCL)
Hello Edgar, I've followed all your suggestions as they appear to fit perfectly with my idea of a plain start. Thanks to your help I've been able to start my practice without any fear so many thanks again!
I wuold like to ask you just one little more question... well, before Lisp I was used to Java and object oriented programming. Now, withouth my objects, I feel myself a little unstructured... My manual provides a short introduction to the use of structures, that are interesting, but yet, pheraphs, a little incomplete... However I've read also about the existence of an object environment, CLOS, so I wuold like to approach it as next step. So what I wuold like to ask you: do you think that the approach to this particular topic should be preceded by some more advanced practice, or are the basics enogh for it? And in that case, is there any particular text/manual (also non-online) you could suggest to me?
I wuold like to ask you just one little more question... well, before Lisp I was used to Java and object oriented programming. Now, withouth my objects, I feel myself a little unstructured... My manual provides a short introduction to the use of structures, that are interesting, but yet, pheraphs, a little incomplete... However I've read also about the existence of an object environment, CLOS, so I wuold like to approach it as next step. So what I wuold like to ask you: do you think that the approach to this particular topic should be preceded by some more advanced practice, or are the basics enogh for it? And in that case, is there any particular text/manual (also non-online) you could suggest to me?
Re: A very hard start (How to compile and execute CCL)
It's nearly impossible to write a Common Lisp program without using CLOS but most people don't know it.
For example, the different number types (integer, float, etc.) are system classes and nearly all math functions are generic functions that specialize their arguments on the number classes and then internally call the respective methods. That's how the "type contagion" (automatic type conversion according to the arguments) works.
This means that if you write (+ 1 1), you already have written an OOP program.
What makes CLOS different from other OOP systems is that classes and methods are two completely separate things that are not even necessarily related to each other. There can be classes without methods and methods without classes. It's up to the programmer to decide what makes sense.
The best CLOS tutorials I know are:
The standard state-of-the-art CLOS book is:
The most advanced CLOS book is:
If you come from Java then I recommend Practical Common Lisp for learning Lisp. It's written by Peter Seibel, who is a Java and Lisp programmer (and some other languages).
- edgar
For example, the different number types (integer, float, etc.) are system classes and nearly all math functions are generic functions that specialize their arguments on the number classes and then internally call the respective methods. That's how the "type contagion" (automatic type conversion according to the arguments) works.
This means that if you write (+ 1 1), you already have written an OOP program.
What makes CLOS different from other OOP systems is that classes and methods are two completely separate things that are not even necessarily related to each other. There can be classes without methods and methods without classes. It's up to the programmer to decide what makes sense.
The best CLOS tutorials I know are:
- Joe Marshall: Warp Speed Introduction to CLOS - very simple and very fast, good for a first overview
- Jeff Dalton: Brief Guide to CLOS - all the basics plus multiple inheritance and method combination
- Nick Levie's Fundamentals of CLOS is the most complete tutorial, but the longest, too
The standard state-of-the-art CLOS book is:
The most advanced CLOS book is:
- Kiczales, Rivieres, Bobrow: The Art of the Meta Object Protocol
If you come from Java then I recommend Practical Common Lisp for learning Lisp. It's written by Peter Seibel, who is a Java and Lisp programmer (and some other languages).
- edgar
-
- Posts: 21
- Joined: Wed Jul 29, 2015 7:25 am
Re: A very hard start (How to compile and execute CCL)
Very very interesting... redefine classes at runtime? I'm already loving it although I think I could wait for it... at the moment I'm studying on "Common Lisp - A gentle introduction to symbolic computation", but I see that Practical Common Lisp covers very interesting topics that I look at as "advanced", do you think it could be useful to practice on both or wuold I have a bigger profit going immediately after the clos? (actually I'm almost finished with the gentle introduction)
In any case, I'll give a look to the tutorials before to start and, as ever, many thanks, expecially for the OOP implementation perspective
In any case, I'll give a look to the tutorials before to start and, as ever, many thanks, expecially for the OOP implementation perspective