From: gavino
Subject: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1151966832.381939.34780@m79g2000cwm.googlegroups.com>
Why is lisp more "powerful" than those other languages and Why is it
more rpactical to get lots fo work done?

-A linux admin trying to decide what programming tools to learn

From: Rob Warnock
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <DI-dnd0QFYz0TDTZnZ2dnUVZ_uudnZ2d@speakeasy.net>
gavino <········@yahoo.com> wrote:
+---------------
| Why is lisp more "powerful" than those other languages and
| Why is it more rpactical to get lots fo work done?
| -A linux admin trying to decide what programming tools to learn
+---------------

In addition to what Kenny said, consider what happens six weeks
or six months or six years from now when you have to go in and
make a fix or add a feature to a sizable script you wrote today.
Lisp [and I include both Common Lisp & Scheme here] is *so* much
more readable/maintainable "later", in my personal experience.
YMMV.


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Ken Tilton
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <e6kqg.761$du3.92@fe08.lga>
gavino wrote:
> Why is lisp more "powerful" than those other languages and Why is it
> more rpactical to get lots fo work done?
> 
> -A linux admin trying to decide what programming tools to learn
> 

(a) Learn Lisp
(b) You asked two diff questions, possibly three (I do not know enough 
Perl to say). Java is definitely constipated, Python and Ruby are not, 
but they are not Lisp.
(c) Have you done the first chapter of tutorials in each of the three? 
That would tell you a lot.

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: klaus
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1151990711.857363.217950@75g2000cwc.googlegroups.com>
gavino schrieb:

> Why is lisp more "powerful" than those other languages and Why is it
> more rpactical to get lots fo work done?
>
> -A linux admin trying to decide what programming tools to learn
>
for a sysdamin, lightweight scripting labguages with decent OS
interface are better.
TCL, Ruby, Python, ....  are all great choices. 

-klaus.
From: Yves Vandriessche
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <e8d89b$t1f$1@ikaria.belnet.be>
klaus wrote:
> gavino schrieb:
> 
>> Why is lisp more "powerful" than those other languages and Why is it
>> more rpactical to get lots fo work done?
>>
>> -A linux admin trying to decide what programming tools to learn
>>
> for a sysdamin, lightweight scripting labguages with decent OS
> interface are better.
> TCL, Ruby, Python, ....  are all great choices. 
> 
> -klaus.
> 

Newlisp certainly fixes this, you have a full OS interface you would 
expect from bash/tcl.
From: Stefan Scholl
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <0T39g5n4I2lrNv8%stesch@parsec.no-spoon.de>
Yves Vandriessche <·················@uhasselt.be> wrote:
> klaus wrote:
>> for a sysdamin, lightweight scripting labguages with decent OS
>> interface are better.
>> TCL, Ruby, Python, ....  are all great choices. 
> 
> Newlisp certainly fixes this, you have a full OS interface you would 
> expect from bash/tcl.

Something like "clisp -K full"? :-)
From: funkyj
Subject: pointless rant against newlisp and other tangents.
Date: 
Message-ID: <1152124583.818536.36020@j8g2000cwa.googlegroups.com>
Yves Vandriessche wrote:
> klaus wrote:
> > gavino schrieb:

> > for a sysdamin, lightweight scripting labguages with decent OS
> > interface are better.
> > TCL, Ruby, Python, ....  are all great choices.
> >
> > -klaus.
> >
>
> Newlisp certainly fixes this, you have a full OS interface you would
> expect from bash/tcl.

<rant>
Newlisp, UGH.  The fact that Newlisp has quite a few gratuitious
semantic differences from CL really turns me off (e.g. why timewarp
back to the 70s/80s and have all dynamic variables!?).

I would have been much happier of the Newlisp folks had simply put
their energy into modifying an existing CL implementation (e.g. CLisp)
to be better suited for scripting.

I do not want to have to know MORE languages, I want to know FEWER
languages with deeper knowledge.  Having to learn the gratuitious
differences between newlisp and CL is like having to remember TCL
syntax -- it is a waste of brain cells.

Thankfully Python has enough features that I've been able to forget
much of what I've learned about Perl and TCL.

I'm also annoyed that Emacs Lisp is not Common Lisp based but since
emacs won the editor war with HEMLOCK by a overwhelming landslide I am
stuck with using the emacs 'cl' compability package and gritting my
teeth at the remaining differences.
</rant>

  --fj
From: gavino
Subject: Re: pointless rant against newlisp and other tangents.
Date: 
Message-ID: <1152131324.690314.196850@m73g2000cwd.googlegroups.com>
Robert Dodier" <·············@gmail.com>  Add to Address Book  Add
Mobile Alert
Yahoo! DomainKeys has confirmed that this message was sent by
gmail.com. Learn more
To: "gavino" <········@yahoo.com>
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: Wed, 05 Jul 2006 19:28:13 -0000

Hello,

> Why is lisp more "powerful" than those other languages and Why is it
> more rpactical to get lots fo work done?
>
> -A linux admin trying to decide what programming tools to learn


If you need programming tools for admin work -- python + bash.
I hate perl. I like Lisp but it is useless for admin stuff.

For other stuff -- Lisp is OK for small projects but it doesn't
encourage encapsulation so big programs turn into a mess.

I have done a lot of programming and some system admin stuff
over a period of about 20 years. YMMV.

Robert Dodier



funkyj wrote:
> Yves Vandriessche wrote:
> > klaus wrote:
> > > gavino schrieb:
>
> > > for a sysdamin, lightweight scripting labguages with decent OS
> > > interface are better.
> > > TCL, Ruby, Python, ....  are all great choices.
> > >
> > > -klaus.
> > >
> >
> > Newlisp certainly fixes this, you have a full OS interface you would
> > expect from bash/tcl.
>
> <rant>
> Newlisp, UGH.  The fact that Newlisp has quite a few gratuitious
> semantic differences from CL really turns me off (e.g. why timewarp
> back to the 70s/80s and have all dynamic variables!?).
>
> I would have been much happier of the Newlisp folks had simply put
> their energy into modifying an existing CL implementation (e.g. CLisp)
> to be better suited for scripting.
>
> I do not want to have to know MORE languages, I want to know FEWER
> languages with deeper knowledge.  Having to learn the gratuitious
> differences between newlisp and CL is like having to remember TCL
> syntax -- it is a waste of brain cells.
>
> Thankfully Python has enough features that I've been able to forget
> much of what I've learned about Perl and TCL.
>
> I'm also annoyed that Emacs Lisp is not Common Lisp based but since
> emacs won the editor war with HEMLOCK by a overwhelming landslide I am
> stuck with using the emacs 'cl' compability package and gritting my
> teeth at the remaining differences.
> </rant>
> 
>   --fj
From: ········@gmail.com
Subject: Re: pointless rant against newlisp and other tangents.
Date: 
Message-ID: <1152131983.081588.271070@m73g2000cwd.googlegroups.com>
> Lisp is OK for small projects but it doesn't
> encourage encapsulation so big programs turn into a mess.

This is nonsense ; macros are the most powerful encapsulation method on
the face of the earth! The BioBike/KnowOS system is ~5000 defuns and
~600 macros in hundreds of files. (Calculated by find|grep|grep|wc; all
numbers approx.) One can argue whether it's a mess or not, but I have a
500 line Java system that I find *much* harder to work with than
BioBike!
From: Tragick
Subject: Re: pointless rant against newlisp and other tangents.
Date: 
Message-ID: <1152174571.681221.292310@a14g2000cwb.googlegroups.com>
········@gmail.com wrote:
> > Lisp is OK for small projects but it doesn't
> > encourage encapsulation so big programs turn into a mess.
>
> This is nonsense ; macros are the most powerful encapsulation method on
> the face of the earth! The BioBike/KnowOS system is ~5000 defuns and
> ~600 macros in hundreds of files. (Calculated by find|grep|grep|wc; all
> numbers approx.) One can argue whether it's a mess or not, but I have a
> 500 line Java system that I find *much* harder to work with than
> BioBike!

Jeff,

I would strongly advise you to move your work to a modern development
environment such as Microsoft's .Net platform.  The last three years
have seen some remarkable advances in programming language technology.
A great deal of serious development is being done today with C#.  If I
recall correctly, it also possess a macro substitution facility (and
you're right, it really is a neat trick).

Here's the pertinent link:
http://msdn.microsoft.com/netframework/
If you can't find what you're looking for, it's probably because you
aren't looking hard enough.

Good luck with your motorcycle project.

Tragick
From: Tayssir John Gabbour
Subject: Re: pointless rant against newlisp and other tangents.
Date: 
Message-ID: <1152177198.375827.44060@m79g2000cwm.googlegroups.com>
········@gmail.com wrote:
> This is nonsense ; macros are the most powerful encapsulation method on
> the face of the earth! The BioBike/KnowOS system is ~5000 defuns and
> ~600 macros in hundreds of files. (Calculated by find|grep|grep|wc; all
> numbers approx.) One can argue whether it's a mess or not, but I have a
> 500 line Java system that I find *much* harder to work with than
> BioBike!

Isn't over 10% of the codebase being macros a bit unusual? Particularly
considering that a bunch of defuns probably exist just to support the
macros?

In a recent 4-week stretch of writing Common Lisp every day, I produced
not a single macro. (I wrote one, but realized it was gratuitous.) But
then again, an OS like KnowOS has different requirements from an app,
as OSes generalize over a broad range of apps, whereas I was producing
a specific, targetted artifact...

Tayssir
From: Rob Thorpe
Subject: Re: pointless rant against newlisp and other tangents.
Date: 
Message-ID: <1152204313.045758.173380@m73g2000cwd.googlegroups.com>
Tayssir John Gabbour wrote:
> ········@gmail.com wrote:
> > This is nonsense ; macros are the most powerful encapsulation method on
> > the face of the earth! The BioBike/KnowOS system is ~5000 defuns and
> > ~600 macros in hundreds of files. (Calculated by find|grep|grep|wc; all
> > numbers approx.) One can argue whether it's a mess or not, but I have a
> > 500 line Java system that I find *much* harder to work with than
> > BioBike!
>
> Isn't over 10% of the codebase being macros a bit unusual? Particularly
> considering that a bunch of defuns probably exist just to support the
> macros?

I'd agree with that.  Looking at GNU Emacs 21.3 there are:-
20491 defuns
6832 defvars
846 defmacros
~6000 def* - Where the def* is usage of a macro

Emacs is not CL, you would expect CL programs to have more, but not
that many more.
From: Marco Baringer
Subject: Re: pointless rant against newlisp and other tangents.
Date: 
Message-ID: <m28xn6ejky.fsf@bese.it>
"Rob Thorpe" <·············@antenova.com> writes:

> Tayssir John Gabbour wrote:
>> ········@gmail.com wrote:
>> > This is nonsense ; macros are the most powerful encapsulation method on
>> > the face of the earth! The BioBike/KnowOS system is ~5000 defuns and
>> > ~600 macros in hundreds of files. (Calculated by find|grep|grep|wc; all
>> > numbers approx.) One can argue whether it's a mess or not, but I have a
>> > 500 line Java system that I find *much* harder to work with than
>> > BioBike!
>>
>> Isn't over 10% of the codebase being macros a bit unusual? Particularly
>> considering that a bunch of defuns probably exist just to support the
>> macros?

the app i'm currently running on + ucw + arnesi + yaclml:

total ".*(def" lines:  2442
defun:  452
defgeneric:  150
defmethod:  604
defclass:  262
defmacro:  152

-- 
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen
From: JP Massar
Subject: Re: pointless rant against newlisp and other tangents.
Date: 
Message-ID: <4t9ra2lg3169riotooa37a24stkcjsv9e4@4ax.com>
On 6 Jul 2006 02:13:18 -0700, "Tayssir John Gabbour"
<···········@yahoo.com> wrote:

>········@gmail.com wrote:
>> This is nonsense ; macros are the most powerful encapsulation method on
>> the face of the earth! The BioBike/KnowOS system is ~5000 defuns and
>> ~600 macros in hundreds of files. (Calculated by find|grep|grep|wc; all
>> numbers approx.) One can argue whether it's a mess or not, but I have a
>> 500 line Java system that I find *much* harder to work with than
>> BioBike!
>
>Isn't over 10% of the codebase being macros a bit unusual? Particularly
>considering that a bunch of defuns probably exist just to support the
>macros?
 
I suspect (having written most of it) that the number of lines of code
in the bodies of the macros vs. the number of lines of code in the
bodies of the defuns is skewed more towards the defuns.
From: Rob Thorpe
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152015078.729198.119060@m73g2000cwd.googlegroups.com>
gavino wrote:
> Why is lisp more "powerful" than those other languages and Why is it
> more rpactical to get lots fo work done?
>
> -A linux admin trying to decide what programming tools to learn

There are several lisp that are suitable for scripting for an admin.
For example CLisp and Newlisp.  Dialect of the language scheme, which
is a type of lisp, such as Gauche, Scsh and guile are also fairly
suitable.

For small admining task though they don't AFAIK offer much more than
Python, Perl or Ruby do.  The benefits of Lisp start to be felt in
larger programs.  With knowledgable programming its often possible to
make a >1000 line program clearer and simpler in lisp than in other
languages.
From: Pascal Bourguignon
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <87hd1xtv8w.fsf@thalassa.informatimago.com>
"Rob Thorpe" <·············@antenova.com> writes:

> gavino wrote:
>> Why is lisp more "powerful" than those other languages and Why is it
>> more rpactical to get lots fo work done?
>>
>> -A linux admin trying to decide what programming tools to learn
>
> There are several lisp that are suitable for scripting for an admin.
> For example CLisp and Newlisp.  Dialect of the language scheme, which
> is a type of lisp, such as Gauche, Scsh and guile are also fairly
> suitable.
>
> For small admining task though they don't AFAIK offer much more than
> Python, Perl or Ruby do.  The benefits of Lisp start to be felt in
> larger programs.  With knowledgable programming its often possible to
> make a >1000 line program clearer and simpler in lisp than in other
> languages.

There's also a snowball effect.  Once a few admins will have written a
couple of clisp libraries it'll become even easier to do
administration with clisp.

For a start, you may fetch my com.informatimago.common-lisp ASDF system
which contains a few packages to read /etc/{passwd,group,aliases}.

http://www.informatimago.com/develop/lisp/index.html#common-lisp


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

The world will now reboot.  don't bother saving your artefacts.
From: Tim Bradshaw
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152015529.826338.78750@v61g2000cwv.googlegroups.com>
gavino wrote:
> Why is lisp more "powerful" than those other languages and Why is it
> more rpactical to get lots fo work done?
>
> -A linux admin trying to decide what programming tools to learn

>From the point of view of being a *nix SA, the things that matter for a
programming language (other than the standard things like not requiring
you to manage memory yourself, having bounds checks, etc etc) are:

* it needs to talk to the OS like a native - so things like running
programs and watching their output, grovelling over the filesystem,
reading & parsing random line-based config files need to be easy, and
standard;
* it should be easy to write programs that handle exceptional cases
(`oops, this write just failed');
* should exist everywhere;
* should not randomly change from time to time, breaking all your code.

Perl and Python are good at the first, Java is OK nowadays.
Python, Java and CL are good at the second, Perl is not (no exceptions,
so you need to litter your code with `x || handle_error(...)' which is
horrible and most people don't do it).
Perl is very good at the third, Python less so, Java is OK if you are
happy to drop a Sun JRE on the box (this is just trivial on any Linux
I've used in the last 5 years). CL used to be terrible but may now be
better.
Perl has a history of being awful at ther fourth, but has been fairly
stable for some long time now.  Perl 6 would be very bad news for this
aspect I suspect.  Python has also been horrible but perhaps now is
better.  Java is pretty good (but versions before 5 were not really
great in terms of features).  Lisp is stable as anything in the
language, but the Unix interface (which counts, a lot) is vaporous I
suspect.

What I do now is Java for things I would once have written in C
(anything that wants to do lots of random networky stuff etc), and Perl
for things that need to talk to the system a lot.  I couldn't use Java
if it wasn't for eclipse, but the object-code portability is great (I
write on a PPC mac and deploy the binaries on Windows, Solaris and
Linux boxes, and it all just works).  Perl I basically hate, but it's
always there and Python isn't.

Why you should still learn Lisp: it will teach you about programming in
a way that none of the other languages will.

--tim
From: Michael J. Forster
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <2006070407091016807-mike@sharedlogicca>
On 2006-07-03 17:47:12 -0500, "gavino" <········@yahoo.com> said:

> Why is lisp more "powerful" than those other languages and Why is it
> more rpactical to get lots fo work done?
> 
> -A linux admin trying to decide what programming tools to learn

Your question is vague, so I'll assume you're asking about the use of 
Lisp for system administration.  If you were asking about software 
development, I would respond with a thundering 'Yes', and you would 
only need google this group further to see why.

For Unix system administration (I don't touch Windows much these days), 
Lisp is a viable tool.  In fact, we write all of our custom server 
administration scripts in CLISP [1] instead of sh, Perl, or Python.
Were we only sysadmins, we might be less motivated to do so, but as 
software developers and sysadmins we can tackle a greater range of 
tasks with Lisp than with the others (including Ruby, C/C++, and Java). 
 Even if you're concerned about being ostracised by a sysadmin 
community dominated by the sh, Perl, and Python mindsets, learning Lisp 
will broaden your perspective.

My recommendation is to look at the CLISP implementation [1].  While I 
don't recommend replacing your login shell with it, replacing #!/bin/sh 
with #!/path/to/clisp -K full is reasonable [2].  You might want to 
look at scsh, the Scheme shell, too [3, 4].  Scheme is a dialect of 
Lisp.

Cheers,

Mike

[1] http://clisp.cons.org/
[2] http://clisp.cons.org/clash.html
[3] http://www.scsh.net/
[4] http://www.samag.com/documents/s=1824/sam0201b/0201b.htm

-- 
Michael J. Forster <····@sharedlogic.ca>
From: gavino
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152085078.766278.136250@p79g2000cwp.googlegroups.com>
I am aiming far boyond sys admin-ing.  So the thundering YES is good to
hear.  What do you say are best manuals to read to learn clsip?  or is
scsh nicer?

Michael J. Forster wrote:
> On 2006-07-03 17:47:12 -0500, "gavino" <········@yahoo.com> said:
>
> > Why is lisp more "powerful" than those other languages and Why is it
> > more rpactical to get lots fo work done?
> >
> > -A linux admin trying to decide what programming tools to learn
>
> Your question is vague, so I'll assume you're asking about the use of
> Lisp for system administration.  If you were asking about software
> development, I would respond with a thundering 'Yes', and you would
> only need google this group further to see why.
>
> For Unix system administration (I don't touch Windows much these days),
> Lisp is a viable tool.  In fact, we write all of our custom server
> administration scripts in CLISP [1] instead of sh, Perl, or Python.
> Were we only sysadmins, we might be less motivated to do so, but as
> software developers and sysadmins we can tackle a greater range of
> tasks with Lisp than with the others (including Ruby, C/C++, and Java).
>  Even if you're concerned about being ostracised by a sysadmin
> community dominated by the sh, Perl, and Python mindsets, learning Lisp
> will broaden your perspective.
>
> My recommendation is to look at the CLISP implementation [1].  While I
> don't recommend replacing your login shell with it, replacing #!/bin/sh
> with #!/path/to/clisp -K full is reasonable [2].  You might want to
> look at scsh, the Scheme shell, too [3, 4].  Scheme is a dialect of
> Lisp.
>
> Cheers,
>
> Mike
>
> [1] http://clisp.cons.org/
> [2] http://clisp.cons.org/clash.html
> [3] http://www.scsh.net/
> [4] http://www.samag.com/documents/s=1824/sam0201b/0201b.htm
> 
> -- 
> Michael J. Forster <····@sharedlogic.ca>
From: Lars Rune Nøstdal
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152091243.541505.142680@j8g2000cwa.googlegroups.com>
gavino wrote:
> I am aiming far boyond sys admin-ing.  So the thundering YES is good to
> hear.  What do you say are best manuals to read to learn clsip?  or is
> scsh nicer?

Practical Common Lisp is good: http://www.gigamonkeys.com/book/

The site also links to "Lispbox" - which is an easy download containing
CLISP (and Emacs+Slime) with all you require to get going fast.

..and yes; Common Lisp is way better that both Java, Perl, Python or
Ruby. Try it out, and you'll see why. :)

http://wiki.alu.org/The_Road_to_Lisp_Survey
http://wiki.alu.org/RtL_Highlight_Film

-- 
mvh, Lars Rune Nøstdal
http://lars.nostdal.org/
From: gavino
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152131389.249441.214950@75g2000cwc.googlegroups.com>
Robert Dodier" <·············@gmail.com>  Add to Address Book  Add
Mobile Alert
Yahoo! DomainKeys has confirmed that this message was sent by
gmail.com. Learn more
To: "gavino" <········@yahoo.com>
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: Wed, 05 Jul 2006 19:28:13 -0000

Hello,

> Why is lisp more "powerful" than those other languages and Why is it
> more rpactical to get lots fo work done?
>
> -A linux admin trying to decide what programming tools to learn


If you need programming tools for admin work -- python + bash.
I hate perl. I like Lisp but it is useless for admin stuff.

For other stuff -- Lisp is OK for small projects but it doesn't
encourage encapsulation so big programs turn into a mess.

I have done a lot of programming and some system admin stuff
over a period of about 20 years. YMMV.

Robert Dodier



Lars Rune Nøstdal wrote:
> gavino wrote:
> > I am aiming far boyond sys admin-ing.  So the thundering YES is good to
> > hear.  What do you say are best manuals to read to learn clsip?  or is
> > scsh nicer?
>
> Practical Common Lisp is good: http://www.gigamonkeys.com/book/
>
> The site also links to "Lispbox" - which is an easy download containing
> CLISP (and Emacs+Slime) with all you require to get going fast.
>
> ..and yes; Common Lisp is way better that both Java, Perl, Python or
> Ruby. Try it out, and you'll see why. :)
>
> http://wiki.alu.org/The_Road_to_Lisp_Survey
> http://wiki.alu.org/RtL_Highlight_Film
> 
> -- 
> mvh, Lars Rune Nøstdal
> http://lars.nostdal.org/
From: Rob Thorpe
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152176268.978991.69260@75g2000cwc.googlegroups.com>
gavino wrote:
> Robert Dodier" <·············@gmail.com>  Add to Address Book  Add
> Mobile Alert
> Yahoo! DomainKeys has confirmed that this message was sent by
> gmail.com. Learn more
> To: "gavino" <········@yahoo.com>
> Subject: Re: Why is lisp better than java perl or python or ruby?
> Date: Wed, 05 Jul 2006 19:28:13 -0000
>
> Hello,
>
> > Why is lisp more "powerful" than those other languages and Why is it
> > more rpactical to get lots fo work done?
> >
> > -A linux admin trying to decide what programming tools to learn
>
>
> If you need programming tools for admin work -- python + bash.
> I hate perl. I like Lisp but it is useless for admin stuff.
>
> For other stuff -- Lisp is OK for small projects but it doesn't
> encourage encapsulation so big programs turn into a mess.
>
> I have done a lot of programming and some system admin stuff
> over a period of about 20 years. YMMV.

I don't think the person who gave you that reply learnt lisp very well.

Common Lisp has all the features needed to build encapsulated programs,
it has separate modules, nested function, and -if you like- objects.
The presence of macros also means that you can create your own
encapsulation facilities if you need others.

Languages generally don't encourage or discourage encapsulation.  They
just provide facilities to allow it, some provide more, some provide
less.  C for example provides fewer than CL, but that does not mean
that any C program is necessarily messy, though C programs often are.
I've written modular C programs and there are many others around.

The modularity of a program is primarily down to the programmer.
From: Michael J. Forster
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <2006070611124116807-mike@sharedlogicca>
On 2006-07-06 03:57:49 -0500, "Rob Thorpe" <·············@antenova.com> said:

> gavino wrote:
>> Robert Dodier" <·············@gmail.com>  Add to Address Book  Add
>> Mobile Alert
>> Yahoo! DomainKeys has confirmed that this message was sent by
>> gmail.com. Learn more
>> To: "gavino" <········@yahoo.com>
>> Subject: Re: Why is lisp better than java perl or python or ruby?
>> Date: Wed, 05 Jul 2006 19:28:13 -0000
>> 
>> Hello,
>> 
>>> Why is lisp more "powerful" than those other languages and Why is it
>>> more rpactical to get lots fo work done?
>>> 
>>> -A linux admin trying to decide what programming tools to learn
>> 
>> 
>> If you need programming tools for admin work -- python + bash.
>> I hate perl. I like Lisp but it is useless for admin stuff.
>> 
>> For other stuff -- Lisp is OK for small projects but it doesn't
>> encourage encapsulation so big programs turn into a mess.
>> 
>> I have done a lot of programming and some system admin stuff
>> over a period of about 20 years. YMMV.
> 
> I don't think the person who gave you that reply learnt lisp very well.

That's an understatement.  I strongly suspect the 'lot' of programming
and sysadmin work he did was confined to the first and last weeks of the
twenty years.

To the OP: As I said, we have successfully replaced sh, Perl, and Python
with CLISP (a particular Common Lisp implementation) for our sysadmin
tasks.  We harvest mail and web server logs with it; we write CGI web
control panels for services with it; we write dot-qmail mail delivery filters
with it; and the list goes on.

As for software development, no other language we have tried (i.e. Perl,
Python, Ruby, PHP, Java, C/C++, C#, Smalltalk) allows us to do everything
that we can do in Lisp (e.g. sysadmin scripts , web apps, shipped-as-binary
desktop apps, embedded device apps, domain specific languages).  It's no
secret that more and more applications are being written using 'dynamic'
languages -- as Perl, Python, and Ruby are often called.  What might be a
secret to many is that these languages are merely stop-overs along the road
to Lisp.  I just decided to not waste any further time and sprinted to 
the oasis
at the end :-)

As a starting point, you can't beat Peter Seibel's Practical Common Lisp [1],
and you can find some good libs and whatnot on Cliki [2] and the Common
Lisp Directory [3], among other places.

[1] http://www.gigamonkeys.com/book/
[2] http://www.cliki.net/
[3] http://www.cl-user.net/

Cheers,

Mike

-- 
Michael J. Forster <····@sharedlogic.ca>
From: William James
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152256938.095864.85670@s53g2000cws.googlegroups.com>
Lars Rune Nøstdal wrote:

> ..and yes; Common Lisp is way better that both Java, Perl, Python or
> Ruby. Try it out, and you'll see why. :)

Really?  Then this problem should be utterly trivial for you.

A file contains lines like

06-Jul.14:10 .....
06-Jul.09:58 .....
13-Jun.09:27 ..... 

Sort them by date and time.
From: Lars Rune Nøstdal
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152265720.775983.110370@k73g2000cwa.googlegroups.com>
William James wrote:
> Lars Rune Nøstdal wrote:
>
> > ..and yes; Common Lisp is way better that both Java, Perl, Python or
> > Ruby. Try it out, and you'll see why. :)
>
> Really?  Then this problem should be utterly trivial for you.
>
> A file contains lines like
>
> 06-Jul.14:10 .....
> 06-Jul.09:58 .....
> 13-Jun.09:27 .....
>
> Sort them by date and time.

.. not that this short of "contest" in any way could prove why I prefer
Common Lisp, even if it this example _was_ way "better" than some
Perl-way of doing this (imagine it, if you mean otherwise - and try to
imagine why I do not care) ..  First try:


(require :local-time)
(require :cl-ppcre)

(defpackage TimeTest
  (:use :local-time :cl :cl-ppcre))
(in-package :TimeTest)



(defmacro awhile (result-symbol expr &body body)
  `(do ((,result-symbol ,expr ,expr))
    ((not ,result-symbol))
    ,@body))



(defparameter *file*
  "06-Jul.14:10
06-Jul.09:58
13-Jun.09:27")



(defun parse-stream-to-dates (fs)
  "Retuns a list of dates."
  (let ((dates nil))
    (awhile date (split "-|:|\\." (read-line fs nil nil))
      (setf (first date) (parse-integer (first date)))
      (setf (second date) (position (second date) +short-month-names+
:test #'string-equal))
      (setf (third date) (parse-integer (third date)))
      (setf (fourth date) (parse-integer (fourth date)))
      (push date dates))
    (nreverse dates)))



(defun date->local-time (date)
  (encode-local-time
   0 0 ;; Dummy data (ms and ss).
   (fourth date)
   (third date)
   (first date)
   (second date)
   2006)) ;; Dummy data (year).



(defun start (time-predicate)
  (sort (parse-stream-to-dates (make-string-input-stream *file*))
        (lambda (date1 date2)
          (funcall time-predicate (date->local-time date1)
(date->local-time date2)))))


#|
TimeTest> (start 'local-time>)
((6 7 14 10) (6 7 9 58) (13 6 9 27))
TimeTest> (start 'local-time<)
((13 6 9 27) (6 7 9 58) (6 7 14 10))
|#


-- 
mvh, Lars Rune Nøstdal
http://lars.nostdal.org/
From: Lars Rune Nøstdal
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152266452.588170.70640@m79g2000cwm.googlegroups.com>
maybe:

(defun parse-stream-to-dates (fs)
  "Retuns a list of dates."
  (let ((dates nil))
    (awhile date (split "-|:|\\." (read-line fs nil nil))
      (push (list (parse-integer (first date))
                  (position (second date) +short-month-names+
                            :test #'string-equal)
                  (parse-integer (third date))
                  (parse-integer (fourth date)))
            dates))
    (nreverse dates)))

..or not repeating setf would be nicer..

(defun parse-stream-to-dates (fs)
  "Retuns a list of dates."
  (let ((dates nil))
    (awhile date (split "-|:|\\." (read-line fs nil nil))
      (setf (first date) (parse-integer (first date))
            (second date) (position (second date) +short-month-names+
                                    :test #'string-equal)
            (third date) (parse-integer (third date))
            (fourth date) (parse-integer (fourth date)))
      (push date dates))
    (nreverse dates)))

-- 
mvh, Lars Rune Nøstdal
http://lars.nostdal.org/
From: Lars Rune Nøstdal
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152268197.943085.145800@b28g2000cwb.googlegroups.com>
..*shrug* .. or maybe:

(defun parse-stream-to-dates (fs)
  "Returns a list of dates."
  (let ((dates nil))
    (awhile date (split "-|:|\\." (read-line fs nil nil))
      (push (encode-local-time
             0 0 ;; Dummy data (ms and ss).
             (parse-integer (fourth date))
             (parse-integer (third date))
             (parse-integer (first date))
             (position (second date) +short-month-names+ :test
#'string-equal)
             2006) ;; Dummy data (year).
            dates))
    (nreverse dates)))



(defun start (time-predicate)
  (dolist (date (sort (parse-stream-to-dates (make-string-input-stream
*file*))
                      time-predicate))
    (format t "~A~%" date)))

-- 
mvh, Lars Rune Nøstdal
http://lars.nostdal.org/
From: Lars Rune Nøstdal
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152266932.355846.121750@m73g2000cwd.googlegroups.com>
..objects prints like this:

....
(defun start (time-predicate)
  (dolist (date (sort (parse-stream-to-dates (make-string-input-stream
*file*))
                      (lambda (date1 date2)
                        (funcall time-predicate (date->local-time
date1) (date->local-time date2)))))
    (format t "~A~%" (date->local-time date))))


#|
TimeTest> (start 'local-time>)
2006-07-06T14:10:00.000
2006-07-06T09:58:00.000
2006-06-13T09:27:00.000
nil
TimeTest> (start 'local-time<)
2006-06-13T09:27:00.000
2006-07-06T09:58:00.000
2006-07-06T14:10:00.000
nil
|#

-- 
mvh, Lars Rune Nøstdal
http://lars.nostdal.org/
From: Rob Warnock
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <ct-dna3qVNVGtzPZnZ2dnUVZ_rOdnZ2d@speakeasy.net>
William James <·········@yahoo.com> wrote:
+---------------
| Lars Rune N�stdal wrote:
| > ..and yes; Common Lisp is way better that both Java, Perl,
| > Python or Ruby. Try it out, and you'll see why. :)
| 
| Really?  Then this problem should be utterly trivial for you.
| A file contains lines like
|   06-Jul.14:10 .....
|   06-Jul.09:58 .....
|   13-Jun.09:27 ..... 
| Sort them by date and time.
+---------------

Perhaps not *utterly* trivial, but it's fairly simple all the same:  ;-}

    > (defun my-parse-time (string)
	;; Some mimimal error checking
	(loop for (c i) in '((#\- 2) (#\. 6) (#\: 9) (#\space 12))
	  unless (eql c (char string i))
	    do (error "Bad punctuation in input string: ~s" string))
	;; Could use a hash table, but the list *is* quite short
	(let* ((months '("Jan" "Feb" "Mar" "Apr" "May" "Jun"
			 "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
	       (month (position (subseq string 3 6) months :test #'equalp))
	       (date (parse-integer string :end 2))
	       (hour (parse-integer string :start 7 :end 9))
	       (minute (parse-integer string :start 10 :end 12)))
	  (unless month
	    (error "Bad month format in input string: ~s" string))
	  ;; This result doesn't have to be the correct year, just monotonic
	  (encode-universal-time 0 minute hour date month 2006)))

    MY-PARSE-TIME
    > (let ((lines (list "06-Jul.14:10 ....."
		         "06-Jul.09:58 ....."
		         "13-Jun.09:27 .....")))
        (format t "~{~s~%~}" (sort lines #'< :key 'my-parse-time))
	(values))			; [suppress printing the value]
    "13-Jun.09:27 ....."
    "06-Jul.09:58 ....."
    "06-Jul.14:10 ....."
    > 

And if you insist on the lines really  being in a file first, and
being printed without the quotes around them, then:

    > (with-open-file (s "foo.txt")
	(let ((lines (loop for line = (read-line s nil nil)
			   while line
		       collect line)))
          (format t "~{~a~%~}" (sort lines #'< :key 'my-parse-time))
	  (values)))
    13-Jun.09:27 .....  
    06-Jul.09:58 .....
    06-Jul.14:10 .....
    > 

If you want the result to go into another file, we can do that too:

    > (with-open-file (in "foo.txt")
	(with-open-file (out "foo.out" :direction :output
				       :if-exists :supersede)
	  (let ((lines (loop for line = (read-line in nil nil)
			     while line
			 collect line)))
	    (format out "~{~a~%~}" (sort lines #'< :key 'my-parse-time)))))

    NIL
    > (quit)
    $ cat foo.out
    13-Jun.09:27 .....  
    06-Jul.09:58 .....
    06-Jul.14:10 .....
    $ 


-Rob

p.s. Note: The values-suppression trick is non-standard, but works
in a number of CL implementations [CMUCL & CLISP, for two].

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Rob Thorpe
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152282764.794319.309320@m79g2000cwm.googlegroups.com>
William James wrote:
> Lars Rune Nøstdal wrote:
>
> > ..and yes; Common Lisp is way better that both Java, Perl, Python or
> > Ruby. Try it out, and you'll see why. :)
>
> Really?  Then this problem should be utterly trivial for you.
>
> A file contains lines like
>
> 06-Jul.14:10 .....
> 06-Jul.09:58 .....
> 13-Jun.09:27 .....
>
> Sort them by date and time.

Plenty of people have suggests ways, its interesting that many of them
are different.

I don't think the problem is really relevant though, because it's quite
simple.  The problems in programming that take the time are writing
medium/large programs to solve larger problems. This is the more
interesting subject, though in that domain it is impossible to give
short examples of the effectiveness of a langauge.
From: Joe Marshall
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152294846.094235.47770@m73g2000cwd.googlegroups.com>
William James wrote:
> Lars Rune Nøstdal wrote:
>
> > ..and yes; Common Lisp is way better that both Java, Perl, Python or
> > Ruby. Try it out, and you'll see why. :)
>
> Really?  Then this problem should be utterly trivial for you.
>
> A file contains lines like
>
> 06-Jul.14:10 .....
> 06-Jul.09:58 .....
> 13-Jun.09:27 .....
>
> Sort them by date and time.

Why not a problem with some meat on it?  Price some airline tickets or
something.
From: Pascal Bourguignon
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <87slldohnr.fsf@thalassa.informatimago.com>
"William James" <·········@yahoo.com> writes:

> Lars Rune N�stdal wrote:
>
>> ..and yes; Common Lisp is way better that both Java, Perl, Python or
>> Ruby. Try it out, and you'll see why. :)
>
> Really?  Then this problem should be utterly trivial for you.
>
> A file contains lines like
>
> 06-Jul.14:10 .....
> 06-Jul.09:58 .....
> 13-Jun.09:27 ..... 
>
> Sort them by date and time.

It is.


LISP> (defun lars-file-date (line)
        (encode-universal-time 
         0
         (parse-integer line :start 10 :junk-allowed t)
         (parse-integer line :start  7 :junk-allowed t)
         (parse-integer line :start  0 :junk-allowed t)
         (position (subseq line 3 6) #(nil "Jan" "Feb" "Mar" "Apr" "May" "Jun"
                                       "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")
                   :test (function string-equal))
         (multiple-value-bind (se mi ho da mo ye) 
             (decode-universal-time (get-universal-time)) ye)))

LISP> (cat "/tmp/file.txt")
06-Jul.14:10 ..... A
06-Jul.09:58 ..... B
13-Jun.09:27 ..... C

LISP> (let* ((path "/tmp/file.txt")
             (sorted 
              (sort
               (COM.INFORMATIMAGO.COMMON-LISP.FILE:TEXT-FILE-TO-STRING-LIST path)
               (function <=)
               :key (function lars-file-date))))
        (with-open-file (out path :direction :output :if-exists :supersede)
          (format out "~{~A~%~}" sorted)))

LISP> (cat "/tmp/file.txt")
13-Jun.09:27 ..... C
06-Jul.09:58 ..... B
06-Jul.14:10 ..... A



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

PLEASE NOTE: Some quantum physics theories suggest that when the
consumer is not directly observing this product, it may cease to
exist or will exist only in a vague and undetermined state.
From: Marco Baringer
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <m23bddzneo.fsf@bese.it>
WARNING: This thread is about to degenerate very quickly, now would be
a good time to use your kill file.

"William James" <·········@yahoo.com> writes:

> Really?  Then this problem should be utterly trivial for you.

troll.

> A file contains lines like
>
> 06-Jul.14:10 .....
> 06-Jul.09:58 .....
> 13-Jun.09:27 ..... 
>
> Sort them by date and time.

------------------------------------------------------------------------
(in-package :common-lisp-user)

(asdf:oos 'asdf:load-op :arnesi)
(asdf:oos 'asdf:load-op :arnesi.cl-ppcre-extras)
(asdf:oos 'asdf:load-op :iterate)

(iterate
  (for line in-file "filename" using #'read-line)
  (rx:=~ "^(..)-(...)\\.(..):(..)" line
         (collect (cons (encode-universal-time
                         0
                         (parse-integer rx:$4)
                         (parse-integer rx:$5)
                         (parse-integer rx:$1)
                         (arnesi:switch (rx:$2 :test #'string=)
                           ("Jan" 1) ("Feb" 2) ("Mar" 3) ("Apr" 4)
                           ("May" 5) ("Jun" 6) ("Jul" 7) ("Aug" 8)
                           ("Sep" 9) ("Oct" 10) ("Nov" 11) ("Dec" 12))
                         2006)
                        line)
                  into lines))
  (finally (mapcar (arnesi:compose #'write-line #'cdr)
                   (sort lines #'< :key #'car))))
------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;

use Date::Calc qw(:all);

open INPUT, "filename" or die "Can't open filename: $!";

my @lines = ();

while (<INPUT>) {
  if (/^(..)-(...)\\.(..):(..)/) {
    # afaik Date::Calc can't directly parse the specified date format.
    # i could be wrong.
    push [ Mktime(2006, 
                  $2 eq 'Jan' ? 1 : $2 eq 'Feb' ? 2 : $2 eq 'Mar' ? 3 :
                  $2 eq 'Apr' ? 4 : $2 eq 'May' ? 5 : $2 eq 'Jun' ? 6 :
                  $2 eq 'Jul' ? 7 : $2 eq 'Agu' ? 8 : $2 eq 'Sep' ? 9 :
                  $2 eq 'Oct' ? 10 : $2 eq 'Nov' ? 11 : $2 eq 'Dec' ? 12,
                  $1,
                  $3,
                  $4,
                  0),
            $_ ], @lines;
  }
}

print join('\n', sort { $a <=> $b } @lines);
------------------------------------------------------------------------

my perl is pretty rusty so that may not be the 'best'
implementation. a function version based on map instead of while wolud
probably be shorter but doesn't feel as perl-y to me.

everything else aside they look very very similar to me...

-- 
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen
From: Rune  Strand
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152274709.004912.231220@s16g2000cws.googlegroups.com>
Here is a quick'n dirty Python version

import time

def compare(a, b):
    astring = "%s %s %s" % (a[0:2], a[3:6], a[7:12])
    bstring = "%s %s %s" % (b[0:2], b[3:6], b[7:12])
    astruct = time.strptime(astring, "%d %b %H:%M")
    bstruct = time.strptime(bstring, "%d %b %H:%M")
    if astruct < bstruct: return -1
    return astruct == bstruct

lines = open('sortfile.txt', 'r').readlines()
lines.sort(compare)
print "".join(lines)
From: Alexander Schmolck
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <yfsy7v5h6z1.fsf@oc.ex.ac.uk>
"Rune  Strand" <···········@gmail.com> writes:

> Here is a quick'n dirty Python version
> 
> import time
> 
> def compare(a, b):
>     astring = "%s %s %s" % (a[0:2], a[3:6], a[7:12])
>     bstring = "%s %s %s" % (b[0:2], b[3:6], b[7:12])
>     astruct = time.strptime(astring, "%d %b %H:%M")
>     bstruct = time.strptime(bstring, "%d %b %H:%M")
>     if astruct < bstruct: return -1
>     return astruct == bstruct
> 
> lines = open('sortfile.txt', 'r').readlines()
> lines.sort(compare)
> print "".join(lines)

Even quicker (untested):

from time import strptime
print "".join(sorted(file(sortfile.txt), key=lambda s: strptime(
                               s[:2], s[3:6], s[7:12], "%d %b %H:%M")))

BTW: On the topic of dirtyness: I think the lisp versions could be shorted by
just sorting by string< after mapping the month field to something that sorts
correctly (e.g. "01" etc) and switching it with the day field.

'as

[p.s. sorry -- I unintentionally emailed it first instead of posting]
From: Rune  Strand
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152281232.234963.222680@s13g2000cwa.googlegroups.com>
Alexander Schmolck wrote:
> Even quicker (untested):
>
> from time import strptime
> print "".join(sorted(file(sortfile.txt), key=lambda s: strptime(
>                                s[:2], s[3:6], s[7:12], "%d %b %H:%M")))
>
> BTW: On the topic of dirtyness: I think the lisp versions could be shorted by
> just sorting by string< after mapping the month field to something that sorts
> correctly (e.g. "01" etc) and switching it with the day field.

Nice!  And perhaps more readable/maintainable with
strptime(s[0:12], "%d-%b.%H:%M") as it parses the original format.

Rune
From: William James
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152284488.103952.267910@m73g2000cwd.googlegroups.com>
Marco Baringer wrote:
> WARNING: This thread is about to degenerate very quickly, now would be
> a good time to use your kill file.

Too late.  Your ineptitude has already been revealed.

>
> "William James" <·········@yahoo.com> writes:
>
> > Really?  Then this problem should be utterly trivial for you.
>
> troll.

Says the fellow who posts perl code in a lisp forum.

>
> > A file contains lines like
> >
> > 06-Jul.14:10 .....
> > 06-Jul.09:58 .....
> > 13-Jun.09:27 .....
> >
> > Sort them by date and time.
>
> ------------------------------------------------------------------------
> (in-package :common-lisp-user)
>
> (asdf:oos 'asdf:load-op :arnesi)
> (asdf:oos 'asdf:load-op :arnesi.cl-ppcre-extras)
> (asdf:oos 'asdf:load-op :iterate)
>
> (iterate
>   (for line in-file "filename" using #'read-line)
>   (rx:=~ "^(..)-(...)\\.(..):(..)" line
>          (collect (cons (encode-universal-time
>                          0
>                          (parse-integer rx:$4)
>                          (parse-integer rx:$5)
>                          (parse-integer rx:$1)
>                          (arnesi:switch (rx:$2 :test #'string=)
>                            ("Jan" 1) ("Feb" 2) ("Mar" 3) ("Apr" 4)
>                            ("May" 5) ("Jun" 6) ("Jul" 7) ("Aug" 8)
>                            ("Sep" 9) ("Oct" 10) ("Nov" 11) ("Dec" 12))
>                          2006)
>                         line)
>                   into lines))
>   (finally (mapcar (arnesi:compose #'write-line #'cdr)
>                    (sort lines #'< :key #'car))))
> ------------------------------------------------------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> use Date::Calc qw(:all);
>
> open INPUT, "filename" or die "Can't open filename: $!";
>
> my @lines = ();
>
> while (<INPUT>) {
>   if (/^(..)-(...)\\.(..):(..)/) {
>     # afaik Date::Calc can't directly parse the specified date format.
>     # i could be wrong.
>     push [ Mktime(2006,
>                   $2 eq 'Jan' ? 1 : $2 eq 'Feb' ? 2 : $2 eq 'Mar' ? 3 :
>                   $2 eq 'Apr' ? 4 : $2 eq 'May' ? 5 : $2 eq 'Jun' ? 6 :
>                   $2 eq 'Jul' ? 7 : $2 eq 'Agu' ? 8 : $2 eq 'Sep' ? 9 :
>                   $2 eq 'Oct' ? 10 : $2 eq 'Nov' ? 11 : $2 eq 'Dec' ? 12,
>                   $1,
>                   $3,
>                   $4,
>                   0),
>             $_ ], @lines;
>   }
> }
>
> print join('\n', sort { $a <=> $b } @lines);
> ------------------------------------------------------------------------

Using the right tool for the job:

ruby -e 'puts ARGF.sort_by { |line| Time.local( "2006",
  *line.split(/\W+/).values_at(1,0,2,3) ) }' file

>
> my perl is pretty rusty so that may not be the 'best'
> implementation. a function version based on map instead of while wolud
> probably be shorter but doesn't feel as perl-y to me.
>
> everything else aside they look very very similar to me...
>
> --
> -Marco
> Ring the bells that still can ring.
> Forget your perfect offering.
> There is a crack in everything.
> That's how the light gets in.
> 	-Leonard Cohen

But cracks in your head haven't helped, have they?

--
Ruby is a language designed in the following steps:

  * take a simple lisp language (like one prior to CL).
  * remove macros, s-expression.
  * add simple object system (much simpler than CLOS).
  * add blocks, inspired by higher order functions.
  * add methods found in Smalltalk.
  * add functionality found in Perl (in OO way).

So, Ruby was a Lisp originally, in theory.
Let's call it MatzLisp from now on. ;-)

                                                        matz.
From: Rob Thorpe
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152290647.522651.254530@m73g2000cwd.googlegroups.com>
William James wrote:
> Marco Baringer wrote:
> > "William James" <·········@yahoo.com> writes:
<misc mudslinging clipped.   Perl & lisp solns also clipped>
>
> Using the right tool for the job:
>
> ruby -e 'puts ARGF.sort_by { |line| Time.local( "2006",
>   *line.split(/\W+/).values_at(1,0,2,3) ) }' file

Interesting, a bit like awk.  How does it know the months?

> > --
> > -Marco
> > Ring the bells that still can ring.
> > Forget your perfect offering.
> > There is a crack in everything.
> > That's how the light gets in.
> > 	-Leonard Cohen
>
> But cracks in your head haven't helped, have they?
>
> --
> Ruby is a language designed in the following steps:
>
>   * take a simple lisp language (like one prior to CL).
>   * remove macros, s-expression.
>   * add simple object system (much simpler than CLOS).
>   * add blocks, inspired by higher order functions.
>   * add methods found in Smalltalk.
>   * add functionality found in Perl (in OO way).
>
> So, Ruby was a Lisp originally, in theory.
> Let's call it MatzLisp from now on. ;-)

>From the perspective of a lisp programmer Ruby doesn't have the things
that make Lisp what it is, namely macro and s-expressions.  These are
the things that make lisp a programmable programming language.

What you have demonstrated is that for a small task you can find a
short solution using Ruby.  But in Ruby you are limited to the language
capabilities that the designer has given you.  This is no problem for a
short program.

Much of the usefulness of lisp comes in being able to solve a problem
in it's own terms, rather than terms dictated by a language designer.
This isn't useful though if the problem is easy to solve with any
programming model.
From: Joe Marshall
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152294271.926607.277800@s53g2000cws.googlegroups.com>
William James wrote:
> --
> Ruby is a language designed in the following steps:
>
>   * take a simple lisp language (like one prior to CL).

That is, ignore any advances prior to, say, 1984.

>   * remove macros, s-expression.

s-expressions are slow, anyway.

>   * add simple object system (much simpler than CLOS).

CLOS is hard.  Let's go shopping.

>   * add blocks, inspired by higher order functions.

Ok, prior to 1984, yet subsequent to 1975.

>   * add methods found in Smalltalk.

Yeah, everyone likes those.

>   * add functionality found in Perl (in OO way).

And some ketchup.  Everyone likes ketchup.

> So, Ruby was a Lisp originally, in theory.
> Let's call it MatzLisp from now on. ;-)
>
>                                                         matz.

I'm sold.  Let's retire this CommonLisp crap.
From: Steven E. Harris
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <q941wstz8t9.fsf@chlorine.gnostech.com>
Joe Marshall <··········@gmail.com> writes:

>>   * add blocks, inspired by higher order functions.

In my limited use of Ruby thus far, the "block" idea has been most
frustrating. I'd be happy to learn that I'm missing something, but the
glaring omission with blocks in Ruby is their distinction from
functions.

Blocks look like lambda expressions. Some functions make use of blocks
provided as arguments, so, coming from Common Lisp, one would expect
that an existing, named function could be provided in lieu of an
ad-hoc block. That is, instead of having to write the following to
remove negative numbers from a sequence:

  (remove-if (lambda (a) (< a 0)) some-seq)

one could provide the predicate function directly:

  (remove-if #'minusp some-seq)

This interchangeability allows simple, existing functions to be used
first, lambda expressions to grow in place as the criteria becomes
more complex, and finally to move those lambda expressions out to named
functions to be reused as named predicates elsewhere.

In Ruby, I keep bumping into functions that want a block, but won't
accept an existing function (of the proper arity) instead. Consider
Enumerable#reject. First, the lambda-like block:

  some_seq = [3, 1, -2]
  some_seq.reject { |a| a < 0 }

Now, what if I happen to have this function around?

  def minusp(a)
    a < 0
  end

How can I use that with Enumerable#reject? Having to write

  some_seq.reject { |a| minusp a }

doesn't count as a solution. There's some conversions available
between Proc objects and blocks. Functions expecting to receive a
block as an argument convert the provided block into a Proc. However,
what I'm asking for here is more like converting a Proc into a block
-- at least to satisfy the function signature.

That I can't find this problem addressed in the Ruby literature
suggests that maybe it's a non-problem, like parentheses in Lisp or
more capable lambda expressions in Python. Maybe it's just a
foreigner's reaction that would subside in significance with prolonged
immersion. I still have some hope for Ruby, but I'm stunned to see
first-class functions and lambda expressions present, yet so
incongruously so.

-- 
Steven E. Harris
From: Juho Snellman
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <slrneb60ad.oc4.jsnell@sbz-30.cs.Helsinki.FI>
Steven E. Harris <···@panix.com> wrote:
[...]
>   some_seq.reject { |a| minusp a }
[...]
> That I can't find this problem addressed in the Ruby literature
> suggests that maybe it's a non-problem, like parentheses in Lisp or
> more capable lambda expressions in Python.

No, actually this seems to be discussed frequently in the Ruby
circles. (And is also badly offtopic for c.l.l, so I'll keep this
brief).

class Symbol
  def to_proc
    proc { |obj, *args| obj.send(self, *args) }
  end
end

def minusp ()
  self < 0
end

p [3, 1, -2, 4, -5].reject(&:minusp)

-- 
Juho Snellman
From: Tayssir John Gabbour
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152301450.028130.73050@m73g2000cwd.googlegroups.com>
William James wrote:
> Using the right tool for the job:
>
> ruby -e 'puts ARGF.sort_by { |line| Time.local( "2006",
>   *line.split(/\W+/).values_at(1,0,2,3) ) }' file

Nice. I decided to steal the idea a bit, and use pattern matching:

;; Instructions and code at:
;; http://www.pentaside.org/code/calendar.lisp
(sort *lines* #'<
      :key (lambda (x) (time->number '(?day ?month ?hour ?minute) x)))


I'm perfectly open to hearing about any problems, here or over email of
any problems. Feel free to use the email listed in the sourcecode.

I wonder if someone packaged up PAIP's sourcecode nicely, so you don't
have to manually fix a couple name clashes...


Tayssir
From: Alexander Schmolck
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <yfsr70xh2g6.fsf@oc.ex.ac.uk>
"William James" <·········@yahoo.com> writes:

> Using the right tool for the job:
> 
> ruby -e 'puts ARGF.sort_by { |line| Time.local( "2006",
>   *line.split(/\W+/).values_at(1,0,2,3) ) }' file

Maybe you're not in such a great position to label others as inept (I think
you've picked the wrong year).

'as
From: Anon
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <79-dnZfY2a05PjPZnZ2dnUVZ_tqdnZ2d@comcast.com>
"William James" <·········@yahoo.com> wrote in 
····························@s53g2000cws.googlegroups.com:

> Lars Rune N�stdal wrote:
> 
>> ..and yes; Common Lisp is way better that both Java, Perl, Python or
>> Ruby. Try it out, and you'll see why. :)
> 
> Really?  Then this problem should be utterly trivial for you.
> 
> A file contains lines like
> 
> 06-Jul.14:10 .....
> 06-Jul.09:58 .....
> 13-Jun.09:27 ..... 
> 
> Sort them by date and time.
> 

here's my newbie attempt:

;; skip the file reading part
;; (i'm a noob, don't know what a file is)
(defparameter *file*
  '("06-Jul.14:10 line 1 ....."
    "06-Jul.09:58 line 2 ....."
    "13-Jun.09:27 line 3 ....."))

;; convert month to number
(defun month-number (month)
  (+ 1 (position
        (intern (string-upcase month) :keyword)
        '(:jan :feb :mar :apr :may :jun :jul :aug :sep :oct :nov :dec))))

;; encode special-date to universal time
(defun time-encode (a)
  (encode-universal-time
   0
   (parse-integer a :start 10 :end 12)
   (parse-integer a :start 7 :end 9)
   (parse-integer a :start 0 :end 2)
   (month-number (subseq a 3 6))
   2006
   0))
   
;; compare time values
(defun line-compare (a b)
  (<
   (time-encode (subseq a 0 12))
   (time-encode (subseq b 0 12))))

;; sort the lines
(sort (copy-list *file*) #'line-compare)


is that correct?
seems to work with my lisp version.
From: drewc
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <87bqs1t78v.fsf@osiris.tech.coop>
"William James" <·········@yahoo.com> writes:

> A file contains lines like
>
> 06-Jul.14:10 .....
> 06-Jul.09:58 .....
> 13-Jun.09:27 ..... 
>
> Sort them by date and time.

Here is my go, with bonus points for not writing my own parser ;)

;; Use a date parsing library
(in-package :net.telent.date)

;; First, a hack at the repl (reformatted for usenet)

(let* ((date-patterns
	'((day 
	   date-divider
	   month 
	   time-divider 
	   hour 
	   time-divider 
	   minute)))
       (input (arnesi:with-input-from-file
		  (s #P"/tmp/date-file")
                (loop 
                   :for line = (read-line s nil)
                   :while (not (null line))
                   :collect (cons 
                             (parse-time 
                              (first
			       (split-sequence:split-sequence
				#\Space
				line))
                              :patterns date-patterns) 
                             line)))))
        
  (mapcar #'cdr (sort input #'< :key #'car)))

;; Then, break it up so's we can name things. 
;; (we like clean, readable, maintainable code around here)

(defparameter *date-pattern*
  '((day date-divider month time-divider 
     hour time-divider minute)))

(defun parse-date-line (line)
  "Return (universal-time . line)"
  (cons 
   (parse-time (first
                (split-sequence:split-sequence
                 #\Space
                 line))
               :patterns *date-pattern*) 
   line))

(defun slurp-date-data (stream)
  "slurp the stream into a list of parsed lines"
  (loop 
     :for line = (read-line stream nil)
     :while (not (null line))
     :collect (parse-date-line line)))

(defun sort-date-file (file) 
  (let* ((input (arnesi:with-input-from-file
                    (s file)
                  (slurp-date-data s))))        
    (mapcar #'cdr (sort input #'< :key #'car))))


;;;; Finally 
DATE> (sort-date-file #P"/tmp/date-file")
("13-Jun.09:27 ..... " "06-Jul.09:58 ....." "06-Jul.14:10 .....")

Not a hard problem at all, took all of five minutes. Was there a point?


drewc





-- 
Posted via a free Usenet account from http://www.teranews.com
From: Wade Humeniuk
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <kGDrg.105147$A8.54511@clgrps12>
William James wrote:
> Lars Rune N�stdal wrote:
> 
>> ..and yes; Common Lisp is way better that both Java, Perl, Python or
>> Ruby. Try it out, and you'll see why. :)
> 
> Really?  Then this problem should be utterly trivial for you.
> 
> A file contains lines like
> 
> 06-Jul.14:10 .....
> 06-Jul.09:58 .....
> 13-Jun.09:27 ..... 
> 
> Sort them by date and time.
> 

And one more way, (with error checking)

(defvar *current-year* nil)

(defun month-number (month-name)
   (1+ (or (position month-name #(jan feb mar apr may jun jul aug sep oct nov dec)
                     :test #'string-equal)
           (error "MONTH-NUMBER: Unable to translate MONTH-NAME ~S" month-name))))

(defun tagged-line (line)
   (or (cl-ppcre:register-groups-bind ((#'parse-integer day) (#'month-number month)
                                       (#'parse-integer hour minute)
                                       content)
           ("^(\\d+)-(\\w+)\\.(\\d+):(\\d+)(.*)$" line)
         (list (encode-universal-time 0 minute hour day month *current-year*) content line))
       (error "Unable to Parse Tagged Line: ~A" line)))

(defun tagged-line< (line1 line2) (< (car line1) (car line2)))
(defun current-year () (elt (multiple-value-list (get-decoded-time)) 5))

(defun sort-date/time-file (filename)
   (with-open-file (stream filename :direction :input)
     (let ((*current-year* (current-year)))
       (sort (loop for line = (read-line stream nil nil)
                   while line collect (tagged-line line))
             #'tagged-line<))))


CL-USER 2 > (pprint (sort-date/time-file "test.txt"))

((3359201220 " ....." "13-Jun.09:27 .....")
  (3361190280 " ....." "06-Jul.09:58 .....")
  (3361205400 " ....." "06-Jul.14:10 ....."))

CL-USER 3 >
From: sross
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152519363.696880.249700@s13g2000cwa.googlegroups.com>
or using cl-l10n's date/time parser

(defun date-string->ut (date-string)
  (cl-l10n:parse-time date-string
   :patterns '((cl-l10n:day (cl-l10n:date-divider ) cl-l10n:month
                   (cl-l10n:time-divider) cl-l10n:hour
                   (cl-l10n:time-divider ) cl-l10n:minute))))

(date-string->ut "13-Jun.09:27") => 3359172420

- sean
From: Rob Thorpe
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152177793.663505.303780@q16g2000cwq.googlegroups.com>
gavino wrote:
> I am aiming far boyond sys admin-ing.  So the thundering YES is good to
> hear.  What do you say are best manuals to read to learn clsip?  or is
> scsh nicer?

You may want to start by learning the Scheme language.  Scheme is a
simpler type of lisp than Common Lisp.

The PLT Scheme system includes an Editor/UI with many facilities for
debugging and some ebooks on learning scheme in their distribution,
see:-
http://www.plt-scheme.org/software/drscheme/
It also has many of the sort of facilities for scripting an admin might
need.

You could then come back to Common Lisp after, it's more complex but
more complete.

Be warned though that Scheme is a very "pure" language with a very
particular perspective on programming.  If this irritates you move to
Common Lisp.
From: funkyj
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152209985.414000.206740@j8g2000cwa.googlegroups.com>
Rob Thorpe wrote:

> You may want to start by learning the Scheme language.  Scheme is a
> simpler type of lisp than Common Lisp.

>
> You could then come back to Common Lisp after, it's more complex but
> more complete.

I've always despised this approach.  If scheme appeals to you more then
use Scheme but don't waste your time learning scheme as a stepping
stone to CL.  If you can't handle learning CL straight away then you
probably are better suited to some other language with training wheels.

I remember at University being forced to waste my time learning Pascal
"because it is a better learning language" when I already proficient in
C.  Pascal wasn't even an LFTM it was a LFSP.

  --fj
From: Rob Thorpe
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152261124.663032.238380@m73g2000cwd.googlegroups.com>
funkyj wrote:
> Rob Thorpe wrote:
>
> > You may want to start by learning the Scheme language.  Scheme is a
> > simpler type of lisp than Common Lisp.
>
> >
> > You could then come back to Common Lisp after, it's more complex but
> > more complete.
>
> I've always despised this approach.  If scheme appeals to you more then
> use Scheme but don't waste your time learning scheme as a stepping
> stone to CL.  If you can't handle learning CL straight away then you
> probably are better suited to some other language with training wheels.

I've always found it useful.  I first learnt C, then I learnt C++.  I'm
sure had I tried to learn C++ first I would have failed because of it's
great complexity.  Similarly I first learnt Emacs Lisp, and only later
learned Common Lisp.

I haven't met anyone I believe to be intelligent enough to understand
Common Lisp as their first programming language.  Maybe small programs
in it that only use a subset of it's capabilities, but not a whole real
program.

I think it depends on how you learn though.  Some people learn by
reading books on a language, others by reading real programs in that
language.  Most do both, and all those who successfully learn a
language use it as they learn.  The problem is not finding a book that
can explain a complex language, thats not too hard since the author can
introduce the complexity slowly.  The problem is finding real programs
in complex languages that are not incomprehendible to a learner.  I
can't think of a CL program that fits that bill.

Learners find the "teach the complex and complete thing first" as
irritating as they find teaching something very simple.  I remember
talking to Engineering students from Cambridge university where they
had attempted to teach C++ to students as their first programming
language.  The students had wisely dug their heals in and submitted
their assignments using mainly the C subset since that was all they had
been able to understand in the duration of the course.
From: funkyj
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <1152297220.945036.105280@75g2000cwc.googlegroups.com>
Rob Thorpe wrote:
>
> I think it depends on how you learn though.  Some people learn by
> reading books on a language, others by reading real programs in that
> language.  Most do both, and all those who successfully learn a
> language use it as they learn.  The problem is not finding a book that
> can explain a complex language, thats not too hard since the author can
> introduce the complexity slowly.  The problem is finding real programs
> in complex languages that are not incomprehendible to a learner.  I
> can't think of a CL program that fits that bill.

I think the methodology of insisting on looking at complex programs to
learn from limits the learning.  Unless you have to maintain someone
else's code that is written in a complex language and uses all of said
languages features why should you bother?

My approach to learning a programming language is to read a book and
write programs that interest me using the new language.  Sometimes
these self assigned programs are recreational and other times they are
utility programs for making some work task easier.

> I remember talking to Engineering students from Cambridge university
> where they had attempted to teach C++ to students as their first
> programming language.  The students had wisely dug their heals in
> and submitted their assignments using mainly the C subset since that
> was all they had been able to understand in the duration of the
> course.

You prove my point for me.  This is exactly the approach I advocate!
Start with CL and use a simple subset of the language.  When you have
mastered this subset learn new stuff.  Many people program C++ for
years without ever learning enough about templates to be able to read
and understand an implementation of STL.  Does this mean that other
aspects of C++ do not make them more productive (e.g. making use STL,
ctors/dtors and function overloading)?  Of course not.

Just because Pascal Bourguignon can do some programming task in 3
lines of CL using all the power of the 'loop' construct doesn't mean
that you need to do this.  You are free to do the same task in 10 or
20 lines of code.  Later when you know more you can improve it.

As far as I can see Common Lisp, the core language, is not THAT
complex, it is the supporting library that is overwhelming.

I guess my point is that, even with a big language like C++ or CL, if
you are writing code from scratch you can be productive in this new
language using just a small subset.

Your example of learning C first and then C++ later is not a good
analogy because C++ is extremely capatible with C (Sure, C99 has gone
and messed that up a bit but that is a fairly recent development).

Comparing C and C++ is more like comparing CL with and without CLOS.

My analogy of learning pascal first and then C is more accurate in
that scheme and CL are about as similar as pascal and C (assume a
professional pascal like Borland Pascal rather than a brain dead
academic pascal).

But as you say, different people learn in different ways.  While I
remain skeptical, I guess it is possible that some people may progress
more quickly by learning Pascal (Scheme) first and then moving onto C
(CL).

  --fj
From: Pascal Costanza
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <4gurqaF1o8psqU1@individual.net>
gavino wrote:
> Why is lisp more "powerful" than those other languages and Why is it
> more rpactical to get lots fo work done?

You might want to give http://p-cos.net/lisp/guide.html a try.


Pascal

-- 
3rd European Lisp Workshop
July 3 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/
From: Alexander Schmolck
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <yfsejx1y5i4.fsf@oc.ex.ac.uk>
"gavino" <········@yahoo.com> writes:

> Why is lisp more "powerful" than those other languages and 
> Why is it more rpactical to get lots fo work done?

Two Wrong premises.
 
> -A linux admin trying to decide what programming tools to learn

In the order of usefulness for *admin* work:

1. about 12 perl one liners for the command line (don't go beyond one liners)
2. python 
3. If you have time and inclination lisp.

'as
From: David Golden
Subject: Re: Why is lisp better than java perl or python or ruby?
Date: 
Message-ID: <YcAqg.11082$j7.315263@news.indigo.ie>
gavino wrote:

> Why is lisp more "powerful" than those other languages and Why is it
> more rpactical to get lots fo work done?
> 
> -A linux admin trying to decide what programming tools to learn

Admin? You should look at cfengine, I'd say - see cfengine.org  
You might love it or hate it, but you should at least investigate
it.

Lisp would probably be a pretty good choice for reimplementing a
cfengine-like software agent in, if you decided you liked the cfengine
idea but not the implementation (which has some pretty grotesque vaguely
C++-like syntax).