Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > to RG - Lisp lunacy and Perl psychosis

Reply
Thread Tools

to RG - Lisp lunacy and Perl psychosis

 
 
ccc31807
Guest
Posts: n/a
 
      03-10-2010
On February 27, in a thread on c.l.l, RG had this to say about Perl:
<quote>
>> But Perl is just an
>> abomination through-and-through. I do not deny that many people find it
>> a productive tool, and about ten years ago having developed a certain
>> level of respect for some of those people I determined to learn Perl
>> just to see what those people got out of it. So I picked up a Perl
>> book, but I could not get past the first few chapters without recoiling
>> in revulsion. It was just horrible.

</quote>
I wanted to reply but also wanted to take some time to think about my
reply.

Yesterday, I wrote a typical data munging script using Perl. I was
using two hashes, %sec and %fac, and needed to populate the 'location'
value in %fac with the value in %sec depending on the state of the
'xlist' key in %sec. The code looks horrible, but I think any
journeyman programmer can follow the logic even if he doesn't
understand Perl or the data structures. This is the code, and I might
add that it's working code:

<code>
if ($sec{$k}{'xlist'} !~ /\d/)
{ $fac{$sec{$k}{'id1'}}{'location'} = $sec{$k}{'site'}; }
elsif ($sec{$k}{'xlist'} eq $sec{$k}{'crs_id'})
{ $fac{$sec{$k}{'id1'}}{'location'} = $sec{$k}{'site'}; }
else
{ $fac{$sec{$k}{'id1'}}{'location'} = $sec{$sec{$k}{'xlist'}}
{'site'}; }
</code>

In David Lamkins' book 'Successful Common Lisp' in chapter 4, we find
the following. This also looks horrible, and I don't think a
journeyman programmer can follow this logic unless he knew something
about Lisp.

<quote>
The following piece of code illustrates how you can use the same name
for different purposes. Take a minute to read this, and see how many
separate uses you can count for the name FUNNY.

(defun funny (funny)
"funny..."
(if (zerop funny)
:funny
(list
(cons funny
(let ((funny funny))
(setq funny (1- funny))
(funny funny)))
funny)))

Here are the five roles played by this one name:

1. function name
2. function argument
3. a word in the documentation string
4. a constant in the keyword package
5. a new lexical variable
</quote>

Perl uses sigils ($, !, %, &) to signify a token's usage. Lisp uses
positional notation for the same thing. It's not that one's bad and
one's not -- it's just cosmetic. It's as if one language is wearing a
pinstripe suit with wing tips and the other is wearing a blue blazer
with penny loafers. Underneath, the logic is the same in both
languages, and once you get past the peculiarities of the language you
use the same logic. (I'm not arguing that the power of the languages
is the same, in several respects Lisp is more powerful than Perl, but
that the process of thinking through a problem is the same.)

Here's the point: to call one language horrible and an abomination
because you don't understand it, and ignoring the horribleness and the
abominable in another language because you do understand it, doesn't
make any sense. The cover doesn't make the book the clothes don't make
the man, and the appearance doesn't make the language. Instead, a
language should be judged on the work that it permits, and in this
respect (based on surveys like TIOBE and advertised positions) Perl
seems to be a lot more useful (and perhaps a lot less horrible) than
CL.

One language isn't better or worse that the other, they are just
different, and the expression of RG's opinion is simply a value
judgment, which others may or may not share.

CC.
 
Reply With Quote
 
 
 
 
Tamas K Papp
Guest
Posts: n/a
 
      03-10-2010
On Wed, 10 Mar 2010 07:01:14 -0800, ccc31807 wrote:

> (defun funny (funny)
> "funny..."
> (if (zerop funny)
> :funny
> (list
> (cons funny
> (let ((funny funny))
> (setq funny (1- funny))
> (funny funny)))
> funny)))
>
> Here are the five roles played by this one name:
>
> 1. function name
> 2. function argument
> 3. a word in the documentation string 4. a constant in the keyword
> package
> 5. a new lexical variable


You mean that you can use something as a variable name, and then use
the same letters as part of a string? Gosh, Common Lisp must be Pure
Madness!

But more seriously, you completely misunderstand Common Lisp when you
write "roles played by this ONE NAME" (my emphasis). It is _not_ one
name.

Your post actually highlights some similarities between Perl and CL:
both have various namespaces, once you see through the thin layer of
syntax for accessing these. So your feeble attempt at starting a
flamewar is pretty... funny.

Tamas
 
Reply With Quote
 
 
 
 
ccc31807
Guest
Posts: n/a
 
      03-10-2010
On Mar 10, 10:46*am, Tamas K Papp <(E-Mail Removed)> wrote:
> So your feeble attempt at starting a flamewar is pretty... funny.


Not my intent to start a flame war. Please reread my post.

> Here's the point: to call one language horrible and an abomination
> because you don't understand it, and ignoring the horribleness and the
> abominable in another language because you do understand it, doesn't
> make any sense.


CC
 
Reply With Quote
 
Tamas K Papp
Guest
Posts: n/a
 
      03-10-2010
On Wed, 10 Mar 2010 07:53:28 -0800, ccc31807 wrote:

> On Mar 10, 10:46Â*am, Tamas K Papp <(E-Mail Removed)> wrote:
>> So your feeble attempt at starting a flamewar is pretty... funny.

>
> Not my intent to start a flame war. Please reread my post.


Yeah, sure. Cross-posting something like this usually promotes peace
and happiness.

>> Here's the point: to call one language horrible and an abomination
>> because you don't understand it, and ignoring the horribleness and the
>> abominable in another language because you do understand it, doesn't
>> make any sense.


You failed to show anything horrible or abominable in CL. All you
demonstrated was your confusion (but that was done pretty well,
congrats).

Cheers,

Tamas
 
Reply With Quote
 
Peter Keller
Guest
Posts: n/a
 
      03-10-2010
In comp.lang.lisp ccc31807 <(E-Mail Removed)> wrote:
> Perl uses sigils ($, !, %, &) to signify a token's usage.


That's not entirely true.

Example:

# BEGIN CODE
#! /usr/bin/perl

$foo = 12;
$foo{'key'} = 34;
$foo[9] = 55;

print "$foo $foo{'key'} $foo[9]\n";
exit 0;
# END CODE

C has similar problems between type names and functions:

/* Begin Code */
#include <stdio.h>
#include <stdlib.h>

struct XXX
{
int foo;
};

void XXX(void)
{
printf("Hello world\n");
}

int main(void)
{
struct XXX fg;

XXX();

return 0;
}
/* End Code */

Nearly all languages have different namespaces for their semantic ideas:
functions, types, variables, etc, etc, etc. Symbols often intersect
in representation: the symbol 'foo' in one namespace is identical to
the symbol 'foo' in another namespace. They rarely, but sometimes do
depending on the language, intersect in meaning.

An example is calling a higher order function in scheme versus lisp.
In scheme you simply call it, in lisp, you use funcall.

Later,
-pete


 
Reply With Quote
 
Ron Garret
Guest
Posts: n/a
 
      03-10-2010
Most of what I have to say about this has already been said by other
people, but since this post is addressed specifically to me I'll respond
nonetheless.

In article
<(E-Mail Removed)>,
ccc31807 <(E-Mail Removed)> wrote:

> On February 27, in a thread on c.l.l, RG had this to say about Perl:
> <quote>
> >> But Perl is just an
> >> abomination through-and-through. I do not deny that many people find it
> >> a productive tool, and about ten years ago having developed a certain
> >> level of respect for some of those people I determined to learn Perl
> >> just to see what those people got out of it. So I picked up a Perl
> >> book, but I could not get past the first few chapters without recoiling
> >> in revulsion. It was just horrible.

> </quote>
> I wanted to reply but also wanted to take some time to think about my
> reply.
>
> Yesterday, I wrote a typical data munging script using Perl. I was
> using two hashes, %sec and %fac, and needed to populate the 'location'
> value in %fac with the value in %sec depending on the state of the
> 'xlist' key in %sec. The code looks horrible, but I think any
> journeyman programmer can follow the logic even if he doesn't
> understand Perl or the data structures. This is the code, and I might
> add that it's working code:
>
> <code>
> if ($sec{$k}{'xlist'} !~ /\d/)
> { $fac{$sec{$k}{'id1'}}{'location'} = $sec{$k}{'site'}; }
> elsif ($sec{$k}{'xlist'} eq $sec{$k}{'crs_id'})
> { $fac{$sec{$k}{'id1'}}{'location'} = $sec{$k}{'site'}; }
> else
> { $fac{$sec{$k}{'id1'}}{'location'} = $sec{$sec{$k}{'xlist'}}
> {'site'}; }
> </code>
>
> In David Lamkins' book 'Successful Common Lisp' in chapter 4, we find
> the following. This also looks horrible, and I don't think a
> journeyman programmer can follow this logic unless he knew something
> about Lisp.
>
> <quote>
> The following piece of code illustrates how you can use the same name
> for different purposes. Take a minute to read this, and see how many
> separate uses you can count for the name FUNNY.
>
> (defun funny (funny)
> "funny..."
> (if (zerop funny)
> :funny
> (list
> (cons funny
> (let ((funny funny))
> (setq funny (1- funny))
> (funny funny)))
> funny)))
>
> Here are the five roles played by this one name:
>
> 1. function name
> 2. function argument
> 3. a word in the documentation string
> 4. a constant in the keyword package
> 5. a new lexical variable
> </quote>
>
> Perl uses sigils ($, !, %, &) to signify a token's usage. Lisp uses
> positional notation for the same thing. It's not that one's bad and
> one's not -- it's just cosmetic. It's as if one language is wearing a
> pinstripe suit with wing tips and the other is wearing a blue blazer
> with penny loafers. Underneath, the logic is the same in both
> languages, and once you get past the peculiarities of the language you
> use the same logic. (I'm not arguing that the power of the languages
> is the same, in several respects Lisp is more powerful than Perl, but
> that the process of thinking through a problem is the same.)
>
> Here's the point: to call one language horrible and an abomination
> because you don't understand it, and ignoring the horribleness and the
> abominable in another language because you do understand it, doesn't
> make any sense. The cover doesn't make the book the clothes don't make
> the man, and the appearance doesn't make the language. Instead, a
> language should be judged on the work that it permits, and in this
> respect (based on surveys like TIOBE and advertised positions) Perl
> seems to be a lot more useful (and perhaps a lot less horrible) than
> CL.
>
> One language isn't better or worse that the other, they are just
> different, and the expression of RG's opinion is simply a value
> judgment, which others may or may not share.


Certainly my opinion is only my opinion. But in my opinion it is not
true that "one language isn't better or worse than the other."
Brainf*ck, Whitespace, and Unlambda, for example, were specifically
designed to be bad languages, and they are. Perl was not specifically
designed to be a bad language, but it is (IMHO of course) for many of
the same reasons that the aforementioned languages are bad.

You write:

> I think any
> journeyman programmer can follow the logic even if he doesn't
> understand Perl or the data structures


Maybe I don't qualify as a journeyman I can't follow that Perl code, and
for exactly the same reason that I can't follow Brainf*ck code: too much
punctuation. What does !~ mean? What do the curly braces denote? What
is /\d/? And if I don't know the answers, how do I look them up? (Yes,
I tried Perldoc. It didn't help.)

The Lisp code, by contrast, has only three items of punctuation that I
have to understand: parentheses, double quotes, and the colon. All the
rest is English words. Some of those words might be mysterious (like
CONS) but at least I can plug those into a search engine to obtain
additional clues. And the double quotes mean exactly what they mean in
common usage, so that leaves only two punctuation marks to deal with.

Also, others have mentioned this but it's worth reiterating: you've
taken actual working Perl code and compared it to a Lisp example
specifically designed to be pathological. That doesn't exactly make it
a fair fight. You can write obfuscated code in any language.

> Perl uses sigils ($, !, %, &) to signify a token's usage.


No, Perl uses sigils to indicate a variable's data type, not a token's
usage. Except that it doesn't. It distinguishes between scalars,
lists, and hash tables, but not between integers, floats, and strings.
It distinguishes between strings and regular expressions, but not
between strings and code. It has all kinds of weird punctuationy things
that you can't look up, like $@ and !~ and <>. It fails silently where
it should produce errors. It violates universally accepted conventions
about what, for example, double quotes mean. For example, this:

print "The widget costs $12.75.";

The actual behavior of that code snippet is not justifiable under any
sane language semantics.

I could go on and on. But life is short. If you really want to
continue this discussion (and if you do you really ought to consider
getting yourself a life instead) I'd suggest starting with a pair of
examples that do more or less the same thing so we can compare apples
and apples.

rg
 
Reply With Quote
 
ccc31807
Guest
Posts: n/a
 
      03-10-2010
On Mar 10, 11:03*am, Tamas K Papp <(E-Mail Removed)> wrote:
> > Not my intent to start a flame war. Please reread my post.

>
> Yeah, sure. *Cross-posting something like this usually promotes peace
> and happiness.


You still haven't read my post, or if you did you haven't comprehended
it. There's nothing in it that works against peace and happiness. I
actually wanted to increase peace and happiness insofar as in my power
to do so.

> >> Here's the point: to call one language horrible and an abomination
> >> because you don't understand it, and ignoring the horribleness and the
> >> abominable in another language because you do understand it, doesn't
> >> make any sense.

>
> You failed to show anything horrible or abominable in CL.


That's right. There isn't anything horrible or abominable in either of
the two languages. It certainly wasn't my intention to create that
impression, just to opposite in fact.

Somehow, you think that I've said exactly the opposite of what I
meant. Either I wasn't clear in my writing, or you weren't clear in
your reading. I'll try one more time.

<emphasis>Calling a language horrible because you don't understand it
is a mindless prejudice.</emphasis>
A
Do you understand that? I contrasted a bit of working Perl code (which
appears to be abominable) to a deliberately obfuscated bit of Lisp
code to make that point. I really don't understand why you think I
have insulted CL, when I undertook to say that insult based on
ignorance is pointless.

CC.
 
Reply With Quote
 
sln@netherlands.com
Guest
Posts: n/a
 
      03-10-2010
On Wed, 10 Mar 2010 09:45:20 -0800, Ron Garret <(E-Mail Removed)> wrote:

>It has all kinds of weird punctuationy things
>that you can't look up, like $@ and !~ and <>. It fails silently where
>it should produce errors. It violates universally accepted conventions
>about what, for example, double quotes mean. For example, this:
>
>print "The widget costs $12.75.";
>
>The actual behavior of that code snippet is not justifiable under any
>sane language semantics.
>


q{$12} =~ /((((((((((((...))))))))))))/;
print "The widget costs $12.75.";
--
The widget costs $12.75.

Works for me.

-sln

 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      03-10-2010
Ron Garret <(E-Mail Removed)> wrote:
>Maybe I don't qualify as a journeyman I can't follow that Perl code, and
>for exactly the same reason that I can't follow Brainf*ck code: too much
>punctuation. What does !~ mean?


perldoc perlop:
Binary "!=" returns true if the left argument is numerically not equal
to the right argument.

> What do the curly braces denote?


Depends on where they are used. Some common uses include enclosure of
code block (perldoc perlsyn) and indexing of hashes (perldoc perldata).

> What is /\d/?


perldoc perlre:
In addition, Perl defines the following:
\d Match a digit character

>And if I don't know the answers, how do I look them up? (Yes,
>I tried Perldoc. It didn't help.)


It's all there. Granted, in particular perlop is hopelessly overloaded
and therefore information is hard to find, but you are very welcome to
improve it.

>The Lisp code, by contrast, has only three items of punctuation that I
>have to understand: parentheses, double quotes, and the colon. All the
>rest is English words. Some of those words might be mysterious (like
>CONS) but at least I can plug those into a search engine to obtain
>additional clues. And the double quotes mean exactly what they mean in
>common usage, so that leaves only two punctuation marks to deal with.


In other words: you have a very limited vocabulary. Sure, that makes it
much easier to learn the vocabulary, there are just much fewer words to
learn. But at the same time you are paying for this advantage with
lenghty sentences (=code) to express the same content (=algorithm).
Wasn't it the Inuit language, that has over 50 different words for snow?
To express the same differentiation in other languages you need half a
sentence for what Inuit can do in a single word.

>Also, others have mentioned this but it's worth reiterating: you've
>taken actual working Perl code and compared it to a Lisp example
>specifically designed to be pathological. That doesn't exactly make it
>a fair fight. You can write obfuscated code in any language.


That Perl code clearly qualifies as obfuscuted, no sane programmer would
write code like that. Ben already demonstrated how equivalent, actual,
readable Perl code would look like.

>> Perl uses sigils ($, !, %, &) to signify a token's usage.

>
>No, Perl uses sigils to indicate a variable's data type, not a token's
>usage.


Correct.

>Except that it doesn't. It distinguishes between scalars,
>lists, and hash tables, but not between integers, floats, and strings.


Why would you want to distinguish between them on such a low level? A
scalar is all those simultaneously and you can use whichever version you
need at any given moment. No awkward conversion from int to string only
because you want to print that value, no need for special conversion
from text (just read from a file or user input) to floating point to do
some calculations. Seems very convenient to me.

>It distinguishes between strings and regular expressions,


Well, those are very different animals. Strings are data while REs are
code.

>but not between strings and code.


Perl most certainly does clearly differentiate between strings (=data)
and code, although you can breach the border using eval() or in REs.

>It has all kinds of weird punctuationy things
>that you can't look up, like $@ and !~ and <>.


Yes, you can. See perldoc perlvar, perldoc perlop, perldoc perlop.

>It fails silently where
>it should produce errors. It violates universally accepted conventions
>about what, for example, double quotes mean. For example, this:
>
>print "The widget costs $12.75.";
>The actual behavior of that code snippet is not justifiable under any
>sane language semantics.


If you don't want variables ($12) to be interpolated, then don't use
quotes that interpolate variables:

print 'The widget costs $12.75.'

jue
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      03-10-2010
ccc31807 <(E-Mail Removed)> wrote:
>I contrasted a bit of working Perl code (which
>appears to be abominable)


That code is abominable and obfuscated, but of course you can write
abominable and obfuscated code in any programming language.

jue
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crazy Gordon Brown's psychosis trickling down? RichA Digital Photography 7 03-01-2010 08:33 AM
Re: Icon psychosis §ñühw¤£f Computer Support 3 07-25-2009 12:50 PM
Re: Icon psychosis chuckcar Computer Support 24 07-24-2009 10:50 AM
pat-match.lisp or extend-match.lisp in Python? ekzept Python 0 08-10-2007 06:08 PM
DVD Verdict reviews: PARANOIA AGENT: SERIAL PSYCHOSIS and more! DVD Verdict DVD Video 0 04-28-2005 08:10 AM



Advertisments