[Nolug] Language philosophy

From: Ron Johnson <ron.l.johnson_at_cox.net>
Date: 12 Jul 2003 19:49:50 -0500
Message-Id: <1058057389.18890.76.camel@haggis>

On Sat, 2003-07-12 at 18:38, Mark A. Hershberger wrote:
> Ron Johnson <ron.l.johnson@cox.net> writes:
>
> > On Sat, 2003-07-12 at 03:57, Mark A. Hershberger wrote:
> >
> >> Some things are virtually impossible w/o regular expressions.
> >
> > Possible in Python, but takes an aggravating amount of 3GL coding.
>
> Yes, and Python seems to want to objectify everything. Which, while
> sometimes really helpful, is sometimes really annoying.

Yes. I've come to like it, though.

> >> Perl:
> >>
> >> for(<*>) {if(/ +/) {$o=$_;s/ +/_/g;rename $o,$_}}
>
> One think I like about Perl is the Syntactic Sugar. This leads to
> the accusation that TMTOWTDI is the real problem with Perl, but,
> frankly, that's a tired argument by languages with less power. Learn

You're right. Even in so-called "rigid" language like Python,
TMTOWTDI.

> the language. Learn the idioms. Don't be afraid to learn more.
>
> rename @{map {($n = $_) =~ tr/ /_/; [$_, $n]}}
> if / /
> for(<*>);
>
> We don't expect a Lisp newbie to understand closures and lambdas after
> getting past the syntax of parenthesis, so why do we expect a Perl
> newbie to be able to grok everything we show him?
>
> Sure, we can write it in such a way that anyone can understand it, but
> why?

Gak!!!! I *hate* "clever" programming.

The next person (who may not be an expert in the language) that
reads the code and modifies it, can do so with a higher likelihood
of not adding new bugs.

> One measure of how quickly a programmer can use a language bring
> his ideas to fruition is lines of code. Perl obviously wins there.

Lines of code is important, but "crypticness" does not need to go
hand-in-hand with "minimal number of lines". That Python script
was a good example.

I guess it's just that I don't write many one-liners. I save
the commands so that, "next time", I have a blueprint to work
from. That minimizes bugs.

> It further wins by the easy access to power that is CPAN.
>
> > Let's make that a non-1-liner:
> >
> > for(<*>)
> > {
> > if(/ +/)
> > {
> > $o=$_;
> > s/ +/_/g;
> > rename $o,$_
> > }
> > }
> > The implicit assumptions in every line except the braces lines makes
> > this hard to read unless you grok REs and know Perl's implicit
> > assumptions.
>
> s,assumptions,variables,g
>
> So, try it with no implicit variables:
>
> for $file (<*>) {
> if($file =~ m{ }) {
> $new = $file;
> $new =~ tr/ /_/;
> rename $file, $new;
> }
> }
>
> Do you find pronouns in English a hard concept to grasp? They are
> part of the implicit assumptions of the language. Instead of using
> George's name every time we want to talk about him, we just use "him"
> or "his". This is similar to the concept of $_ and _ in Perl.

In computer languages I like explicitness. That's one less source
of bugs

> The thing to remember about Perl is that it isn't an ivory tower
> language. It is a mucky, dirty language because, like natural
> languages, it evolves, it gathers stuff and looses other things.

So I've read.

> Perl assumes you are reasonably intelligent.

That is incredibly condescending.

They may assume that humans are fallible, but really, what language
*really* assumes that you are stupid?

[snip]
> But, let me be clear. Languages like Lisp, Perl, and Smalltalk are
> much maligned languages because they are "different". People who grew
> up reading C or C++ or Java or C# look at Lisp or Perl and shake their
> heads because they are so dramatically different. Perl must be
> approached using the Beginners Mind.
>
> > Is there any documentation for the functions in CPAN similar to
> > those of the standard Python library?
>
> What is in the standard Python library? I imagine that the standard

http://www.python.org/doc/current/lib/modindex.html
http://www.python.org/doc/current/lib/genindex.html

> distribution for Perl covers about the same ground as Python, though
> I'm sure there are differences.

If anyone can add a new module, then I'm sure CPAN's scope
is much wider.

> That said, everything in core Perl is also on CPAN. Tons of
> documentation hyperlinked and mirrored accross the globe:
> <http://search.cpan.org/dist/perl/>.

Good to know. Thanks.

-- 
+-----------------------------------------------------------+
| Ron Johnson, Jr.     Home: ron.l.johnson@cox.net          |
| Jefferson, LA  USA   http://members.cox.net/ron.l.johnson |
|                                                           |
| 4 degrees from Vladimir Putin
+-----------------------------------------------------------+
___________________
Nolug mailing list
nolug@nolug.org
Received on 07/12/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST