On Thursday 03 September 2009 06:44:40 Uri Guttman wrote:
> >>>>> "SHC" == Shawn H Corey <shawnhco...@gmail.com> writes:
> 
>   SHC> Dave Tang wrote:
>   >> I wanted to ask why is Perl, in comparison to other programming
>   >> languages, so powerful in text processing?
> 
>   SHC> Undoubtedly, when it was written, Perl was the most powerful text
>   SHC> processing language available.  This is no longer the case (thanks
>   SHC> largely to Perl :).  Today's scripting languages have the same text
>   SHC> processing abilities as Perl.  You will find this true of Perl's
>   SHC> documentation; some of it has not been updated in quite some time.
> 
> why would documentation that is accurate need to be updated? 

Right - it shouldn't. And it has been corrected, updated slightly, or made 
more accessible.

> and each
> new version of perl has added many more perldocs including tutorials,
> quick references and more? as for text processing, see my other
> post. most other langs still don't have perl's text munging power no
> matter how loudly they claim to. power is not only speed but
> expressiveness. 

See also:

* http://www.paulgraham.com/power.html - "Succinctness is Power"

I should note that what Graham says about the length of the program measured 
in "tokens" is not entirely accurate. In a way, it is also measured in 
characters - for example most people will prefer "len" or "length" over 
"string_length" or even "strlen", and +/./~/"," are preferable to 
"concatenate".

* http://www.paulgraham.com/popular.html - see Brevity and other factors that 
have made languages like Perl popular.

* http://greenokapi.net/talks/ReadablePerl.pdf - a little about Perl's 
dedicated regular expression syntax (e.g: "m{...}), etc.

In addition to regular expressions (as first-order syntactical objects), there 
are also things like pos(), /g, \G, (which is not present in Ruby 1.8.x 
unfortunately) etc. as well as an lvalue-substr, index, rindex, substr with 
negative parameters, and other goodies.

> my favorite simple example of how perl's text and other
> ops work well together is a trivial parser for a simple key=value file
> with one entry per line.
> 
> use File::Slurp ;
> my %config = read_file( $file ) =~ /^(\w+)=(.*)$/mg ;
> 
> that is concise, clear and not terse. 

I should note that often brevity results in conciseness and succinctness - not 
in terseness. Perl 5 code can be made very terse (in Golf, etc.), and code of 
APL/J/etc. can be much worse than that. But it's not necessary that it will. I 
find Perl's expressive power useful in expressing my thoughts, and don't like 
languages that try to restrict in the name of "readability", "regularity", or 
any other higher cause.

Regards,

        Shlomi Fish

> show me a better simple parser in
> any other lang. that is text processing power. you can parse out the
> keys/values line by line and also assign them to a hash to be used later
> in the program. that is what config parsing should be and too often
> isn't. complexity isn't the same as power.
> 
> uri
> 

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Why I Love Perl - http://shlom.in/joy-of-perl

God gave us two eyes and ten fingers so we will type five times as much as we
read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to