From: javuchi
Subject: To use or not to use CLOS
Date: 
Message-ID: <m21xp7on5c.fsf@servidor.kalandra>
I must admit that I'm completely a newbie in Lisp, as I've been writing C and
(some) C++ for years.
I don't like the way in wich C++ resolves object programming, although
sometimes I'm forced to use object oriented programming in C, in the same way
as GTK+ does.
Now I emprend a (personal) project and would like to start it from the very
beginning in Lisp (my first project in this language).
My simple question, and I want to ear answers from all you experts, is: do
you recomend me CLOS or perhaps consider that using simple structure and
Lisp facilities would be more than enough? Please, take in consideration that
my project will consume much CPU and need efficency (it will be a multimedia
program with real time responsive).

Thanks.

From: Thomas F. Burdick
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <xcvsmhn9xp3.fsf@famine.OCF.Berkeley.EDU>
javuchi <······@nospam.com> writes:

> I must admit that I'm completely a newbie in Lisp, as I've been writing C and
> (some) C++ for years.
> I don't like the way in wich C++ resolves object programming, although
> sometimes I'm forced to use object oriented programming in C, in the same way
> as GTK+ does.
> Now I emprend a (personal) project and would like to start it from the very
> beginning in Lisp (my first project in this language).
> My simple question, and I want to ear answers from all you experts, is: do
> you recomend me CLOS or perhaps consider that using simple structure and
> Lisp facilities would be more than enough? Please, take in consideration that
> my project will consume much CPU and need efficency (it will be a multimedia
> program with real time responsive).

Yes, use CLOS.  CLOS is basically generic functions, and the ability
to define STANDARD-CLASS classes.  Neither of those is necessarily
slow.  Use DEFCLASS and DEFMETHOD, and if profiling shows a part of
your program to be too slow, then start thinking about
micro-optimizing that part.  You can always change select classes to
be STRUCTURE-CLASSes, and you can rewrite certain generic functions
into ordinary functions.  If you don't try to eschew CLOS features,
you'll probably get to the point of profiling your application much
sooner, thanks to the productivity gains.

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Christopher C. Stacy
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <u8yjfbwf8.fsf@news.dtpq.com>
>>>>> On 06 Feb 2004 23:31:43 +0100, javuchi  ("javuchi") writes:

 javuchi> I must admit that I'm completely a newbie in Lisp, as I've
 javuchi> been writing C and (some) C++ for years.

 javuchi> I don't like the way in wich C++ resolves object
 javuchi> programming, although sometimes I'm forced to use object
 javuchi> oriented programming in C, in the same way as GTK+ does.

 javuchi> Now I emprend a (personal) project and would like to start
 javuchi> it from the very beginning in Lisp (my first project in this
 javuchi> language).

 javuchi> My simple question, and I want to ear answers from all you
 javuchi> experts, is: do you recomend me CLOS or perhaps consider
 javuchi> that using simple structure and Lisp facilities would be
 javuchi> more than enough? Please, take in consideration that my
 javuchi> project will consume much CPU and need efficency (it will be
 javuchi> a multimedia program with real time responsive).

It's not a simple question, because we don't know enough about 
your program or where you think you migbt want to be using objects.
We also don't know how well CLOS performs on the particular Lisp that
you will be using (since we don't know what platforms you're on.)
We also don't know what of graphics library you are planning on
using, and whether it's going to require the user of objects.

CLOS is not supposed to be too slow to use.
From: javuchi
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <m2smhnn48e.fsf@servidor.kalandra>
······@news.dtpq.com (Christopher C. Stacy) writes:

> It's not a simple question, because we don't know enough about 
> your program or where you think you migbt want to be using objects.
> We also don't know how well CLOS performs on the particular Lisp that
> you will be using (since we don't know what platforms you're on.)
> We also don't know what of graphics library you are planning on
> using, and whether it's going to require the user of objects.
> 
> CLOS is not supposed to be too slow to use.


I'll be using CMUCL on Linux (x86). The application will be somewhat related
to audio, not graphics.

javuchi.
From: Fred Gilham
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <u78yjeria5.fsf@snapdragon.csl.sri.com>
javuchi <······@nospam.com> writes:

> ······@news.dtpq.com (Christopher C. Stacy) writes:
> 
> > It's not a simple question, because we don't know enough about 
> > your program or where you think you migbt want to be using objects.
> > We also don't know how well CLOS performs on the particular Lisp that
> > you will be using (since we don't know what platforms you're on.)
> > We also don't know what of graphics library you are planning on
> > using, and whether it's going to require the user of objects.
> > 
> > CLOS is not supposed to be too slow to use.
> 
> 
> I'll be using CMUCL on Linux (x86). The application will be somewhat related
> to audio, not graphics.

There are some audio-related programs, "Common Music" and "Common Lisp
Music", that are both written in Lisp and both use CLOS a fair amount.


-- 
Fred Gilham                     ······@csl.sri.com
"I'm an expert at installing free software.  I've installed software
packages that had 412 steps, the first two of which were 'Remove small
children and animals from the premises' and 'Don protective gloves and
mask'.  If you made a mistake you had to go back to the very
beginning, including getting the kids and pets back in the house."
From: javuchi
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <m2oes99ex8.fsf@servidor.kalandra>
Fred Gilham <······@snapdragon.csl.sri.com> writes:

> > I'll be using CMUCL on Linux (x86). The application will be somewhat related
> > to audio, not graphics.
> 
> There are some audio-related programs, "Common Music" and "Common Lisp
> Music", that are both written in Lisp and both use CLOS a fair amount.

Great!!!
I'm looking now at CLM (yes, this time Google made a good response), and found,
for example, this macro:

(definstrument name (args) (setup code (run run-time code)))

being "run" almost any standar function of CL. This solutions seems to be
really clever and imposible in other languages like C.

This demonstrate me two things:
- The first: I need much more time to really start thinking in Lisp mode, as
        I would start coding my application in a radical different way (just
        as in C, with structures)
- The second: Lisp is incredible!!

Fred, have you ever used these libraries?

-- 
�� javuchi ��
From: Henrik Motakef
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <x7y8rf6wj4.fsf@crocket.internal.henrik-motakef.de>
javuchi <······@nospam.com> writes:

> > CLOS is not supposed to be too slow to use.
> 
> I'll be using CMUCL on Linux (x86). The application will be somewhat related
> to audio, not graphics.

CMUCL has pretty good CLOS performance. And it also has some helpfull
extensions that don't require to completely drop CLOS in case of
performance problems, see section 2.21 of the CMUCL user manual.
From: Joe Marshall
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <r7x74t6n.fsf@comcast.net>
javuchi <······@nospam.com> writes:

> Now I emprend a (personal) project and would like to start it from the very
> beginning in Lisp (my first project in this language).
> My simple question, and I want to ear answers from all you experts, is: do
> you recomend me CLOS or perhaps consider that using simple structure and
> Lisp facilities would be more than enough? Please, take in consideration that
> my project will consume much CPU and need efficency (it will be a multimedia
> program with real time responsive).

I would recommend using CLOS on those parts of the project that `fit'
within the CLOS paradigm.

-- 
~jrm
From: javuchi
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <m2oesbmxmh.fsf@servidor.kalandra>
Joe Marshall <·············@comcast.net> writes:

> I would recommend using CLOS on those parts of the project that `fit'
> within the CLOS paradigm.

And how do you define the CLOS paradigm?

javuchi.
From: Joe Marshall
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <ad3v42aj.fsf@comcast.net>
javuchi <······@nospam.com> writes:

> Joe Marshall <·············@comcast.net> writes:
>
>> I would recommend using CLOS on those parts of the project that `fit'
>> within the CLOS paradigm.
>
> And how do you define the CLOS paradigm?

If you have an obvious type hierarchy where the subtypes are
specializations of the supertypes and there are functions that apply
across a large number of the types.

I know that's kind of vague.  You shouldn't go out of your way to turn
everything into a class just because you can. 

-- 
~jrm
From: Dave Roberts
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <kTgVb.633$032.16007@attbi_s53>
Joe Marshall wrote:

> javuchi <······@nospam.com> writes:
> 
>> Joe Marshall <·············@comcast.net> writes:
>>
>>> I would recommend using CLOS on those parts of the project that `fit'
>>> within the CLOS paradigm.
>>
>> And how do you define the CLOS paradigm?
> 
> If you have an obvious type hierarchy where the subtypes are
> specializations of the supertypes and there are functions that apply
> across a large number of the types.
> 
> I know that's kind of vague.  You shouldn't go out of your way to turn
> everything into a class just because you can.

While I'm too much of a newbie to know for sure, this seems like one of
Lisp/CLOS's greatest strengths. You can use OOP for the parts of the
program to which it is well suited, and totally ignore it when it doesn't.
This flexibility seems very nice. Again, I have only been introduced to a
very small part of CLOS, but what I have seen has convinced me that there
is a lot of power there.

-- Dave
From: Joe Knapka
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <m3bro2wqib.fsf@localhost.localdomain>
Dave Roberts <·····@re-move.droberts.com> writes:

> Joe Marshall wrote:
> 
> > javuchi <······@nospam.com> writes:
> > 
> >> Joe Marshall <·············@comcast.net> writes:
> >>
> >>> I would recommend using CLOS on those parts of the project that `fit'
> >>> within the CLOS paradigm.
> >>
> >> And how do you define the CLOS paradigm?
> > 
> > If you have an obvious type hierarchy where the subtypes are
> > specializations of the supertypes and there are functions that apply
> > across a large number of the types.
> > 
> > I know that's kind of vague.  You shouldn't go out of your way to turn
> > everything into a class just because you can.
> 
> While I'm too much of a newbie to know for sure, this seems like one of
> Lisp/CLOS's greatest strengths. You can use OOP for the parts of the
> program to which it is well suited, and totally ignore it when it doesn't.

Even better, OO can be applied uniformly to *every* entity in your
system (not just the ones you bother to define as *classes*),
including native types. *That* is OO done right -- "everything is an
object", for sure, and can be treated as such, but you don't have
to care unless it's convenient to do so.

> This flexibility seems very nice. Again, I have only been introduced to a
> very small part of CLOS, but what I have seen has convinced me that there
> is a lot of power there.

Likewise.

Cheers,

-- Joe Knapka

-- 
Barney comes to play with us whenever we may need him;
Someday we will hunt him down and chop him up and eat him!
   -- Annze, age 7
--
If you really want to get my attention, send mail to
jknapka .at. kneuro .dot. net.
From: John M. Adams
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <oqan07uuqhj.fsf@RAKTABIJA.stsci.edu>
javuchi <······@nospam.com> writes:

> I must admit that I'm completely a newbie in Lisp, as I've been
> writing C and (some) C++ for years.  I don't like the way in wich
> C++ resolves object programming, although sometimes I'm forced to
> use object oriented programming in C, in the same way as GTK+ does.
> Now I emprend a (personal) project and would like to start it from
> the very beginning in Lisp (my first project in this language).  My
> simple question, and I want to ear answers from all you experts, is:
> do you recomend me CLOS or perhaps consider that using simple
> structure and Lisp facilities would be more than enough?

I'd suggest ignoring CLOS at first, unless you find yourself
conceptualizing the problem in a strongly hierarchical way.  I use
CLOS heavily at work, but we have massive systems.  Sure, if you know
CLOS, its easy to use it in a lightweight fashion.  But if you are new
to Lisp, it could be a distraction to try to wrap your head around
CLOS.  Plus, it is worthwhile to learn the defstruct facilities.

On the other hand.  CLOS is also worth knowing.  There is more than
one reasonable learning approach for you.  Reasonable people can
disagree here.  Use your intuition.

-- 
John M. Adams
From: javuchi
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <m2k72x9eoo.fsf@servidor.kalandra>
·······@stsci.edu (John M. Adams) writes:

> I'd suggest ignoring CLOS at first, unless you find yourself
> conceptualizing the problem in a strongly hierarchical way.  I use
> CLOS heavily at work, but we have massive systems.  Sure, if you know
> CLOS, its easy to use it in a lightweight fashion.  But if you are new
> to Lisp, it could be a distraction to try to wrap your head around
> CLOS.  Plus, it is worthwhile to learn the defstruct facilities.

Yes, you are right. But if I emprend a new piece of software, I'd like it
to be complete from the very beginning. I need a lot of experimentation first,
so the first thing to do is give time to myself. I've used C to much in the
past, my mind needs to acommodate to this new situation.

> On the other hand.  CLOS is also worth knowing.  There is more than
> one reasonable learning approach for you.  Reasonable people can
> disagree here.  Use your intuition.

Thanks John.


-- 
�� javuchi ��
From: Frode Vatvedt Fjeld
Subject: Re: To use or not to use CLOS
Date: 
Message-ID: <2hznbmqx5w.fsf@vserver.cs.uit.no>
javuchi <······@nospam.com> writes:

> [..] My simple question, and I want to ear answers from all you
> experts, is: do you recomend me CLOS or perhaps consider that using
> simple structure and Lisp facilities would be more than enough?

I'm beginning to suspect that it's rather unfortunate that the name
"CLOS" exists. Because there really is no such thing. When this name
is used, it refers very loosely to some aspects of Common Lisp. So my
recommendation is to ignore any considerations of whether or not to
use CLOS, because it's a contrived issue.

> Please, take in consideration that my project will consume much CPU
> and need efficency (it will be a multimedia program with real time
> responsive).

A general wisdom is that Common Lisp qua language is more optimized
for writing correct programs than speed-efficient programs. Writing
speedy programs in CL is far from impossible, but there are numerous
pitfalls that inexperienced CL programmers can easily to fall into.

From what I gather of your immediate problem, I believe one can
generally expect defstruct to provide slightly improved speed over
defclass. Still I would advise you to use defclass because of its many
superior properties, particularly during development. Only use
defstruct as an optimization strategy of last resort (i.e. don't use
it).

-- 
Frode Vatvedt Fjeld