[REBOL] Re: Perl is to stupid to understand this 1 liner.
From: rpgwriter::yahoo at: 14-Dec-2001 10:17
--- Joel Neely <[joel--neely--fedex--com]> wrote:
> Hi, Doug,
>
> "Vos, Doug" wrote:
> >
> ...
> > try this at the prompt. - Test for leap year
> > >> 29-Feb-1999
> > ** Syntax Error: Invalid date -- 29-Feb-1999
> > ** Near: (line 1) 29-Feb-1999
> >
> > However there is a leap year in 2000,
> > so rebol knows right away what you mean...
> >
> > >> 29-Feb-2000
> > == 29-Feb-2000
> >
> > >> Can perl do that?
> > == NO
> >
>
> I respectfully suggest that you do NOT want to open
> that door.
>
> The only valid way I know of to use "one-liners" in
> comparing
> languages would be to consider:
>
> 1) The range of one-liners in language A and
> language B.
> 2) The actual utility of EACH such one-liner in
> each language.
> 3) The effort required to learn them.
>
> Items 1 and 2 give the credit side of the ledger,
> while item 3
> is the debit side. Net ROI (return-on-investment)
> is the balance
> between the two. Note that item 2 includes both
> "How often would
> I use this one-liner?" and "Would learning this
> one-liner prepare
> me to create other useful one-liners?"
>
> One-liners often encourage (or at least demonstrate)
> techniques
> which may not have wide application, and may be more
> biased to
> compactness than readability and reusability.
> That's not always
> bad, but it means that one-liners may have little to
> do with the
> way a professional programmer will write significant
> pieces of
> code in the language in question.
>
> Feature count is by no means the only (nor most
> useful) measure of
> a language; if it were, REBOL would come out on the
> short end of
> *many* comparisons. REBOL is a flexible and compact
> scripting
> language designed primarily for "programming in the
> small" (according
> to a quotation from Carl Sassenrath in the document
> "shoebox" on the
> REBOL Forces site). However, that compactness comes
> with a price:
> limits on features. REBOL is also far from the
> highest in brute
> performance of the scripting languages of my
> acquaintance.
>
> Perl, on the other hand, is a mature,
> high-performance language with
> an incredibly rich feature set and even richer
> standard library of
> additional components. However, that richness comes
> with a price:
> the installation of Perl 5.6 on the Solaris box I'm
> using today
> weighs in at about 15 Mb.
>
> It is certainly legitimate to show a piece of code
> that does a
> specific thing that one finds useful and cite that
> as a benefit
> of the language. I do not think it is fair to take
> one such
> example and claim that another language that takes
> more keystrokes
> for the same result is "stupid". By that measure,
> almost every
> language (including REBOL) is "stupid" compared with
> APL.
>
> I might add that I recently attended a meeting which
> included a
> presentation on Python; the presenter concluded with
> a single
> Python expression which, when evaluated, created an
> ASCII-art
> image of the Mandelbrot Set. Although the
> expression was long
> enough to line-wrap (multiple times! ;-) it was
> still far more
> compact than one would reasonably expect, and *way*
> far more
> compact than one could write in REBOL.
>
> I am neither advocating for nor against Perl or
> REBOL here; my
> oft-stated view is that languages are tools, each
> with specific
> capabilities and strengths (and weaknesses). I have
> no time for
> arguments regarding whether a handsaw is "better" or
> "worse" than
> a screwdriver.
>
> That said, I can play parlor games too! (To avoid
> appearing to
> contradict myself, let me point out that I don't
> take this exercise
> at all seriously...)
>
> SUPPOSE that I have a memo containing phone numbers.
> I need to give
> someone a copy of the memo, but need to blot out the
> phone numbers,
> in the best CIA tradition. ;-) Here's the memo:
>
> 8<----------
> Ms. Antoinette,
>
> I spoke with George Washington at 555-1212 about our
> pending
> contract. He referred me to Ben Franklin
> (800-555-1111) of
> their technical support department. Ben said that
> they were
> testing their latest release on WhizBangOS version
> 17.3 as
> we had requested, and that he would have our answer
> tomorrow.
>
> Ben also said that their lead developer, Betsy Ross,
> would
> like to talk to you about the use of complex numbers
> in the
> SystemSleepFor function. You may call her office at
> 123-4576, her cell phone at 987-6543, or page her at
> 111-1111.
> She is very eager to describe this new feature.
>
> Sincerely,
> Thomas Paine
> 8<----------
>
> I can protect everybody's phone numbers from lurking
> telemarketers
> with the following one-liner in Perl:
>
> 8<----------
> # perl -p -e 's/\b(\d{3}-)?\d{3}-\d{4}/####/g'
> memo.txt
> Ms. Antoinette,
>
> I spoke with George Washington at #### about our
> pending
> contract. He referred me to Ben Franklin (####) of
> their technical support department. Ben said that
> they were
> testing their latest release on WhizBangOS version
> 17.3 as
> we had requested, and that he would have our answer
> tomorrow.
>
> Ben also said that their lead developer, Betsy Ross,
> would
> like to talk to you about the use of complex numbers
> in the
> SystemSleepFor function. You may call her office at
> ####, her cell phone at ####, or page her at ####.
> She is very eager to describe this new feature.
>
> Sincerely,
> Thomas Paine
> 8<----------
>
> Anyone is welcome to propose a minimalist solution
> in REBOL!
I haven't used parse much, but it seems like a fairly
trivial application of it.