From: Charlton Wilbur on
>>>>> "PY" == Peng Yu <pengyu.ut(a)gmail.com> writes:

PY> According to Programming Perl, more than one way may not always
PY> be better. But I just don't see more than one way is better at
PY> all.

comp.lang.python is over there; comp.lang.java is down the hall;
comp.lang.ruby is between the two of them; and comp.lang.c++ is on the
other side.

PY> In this sense, there were a subroutine that can read multiple
PY> lines from a file. There is no need that the users should
PY> understand the different ways of reading muliple lines as
PY> discussed in other thread mentioned the original post.

Ah, but the reason there are multiple ways to do things is because the
choice of which way to do things depends on the context.

The best way to read *three* lines from a file is not the best way to
read *ten thousand* lines from a file. Instead of mandating one way,
the Perl philosophy is to assume that you're a competent programmer who
can judge the quality of various solutions for yourself.

If you're a competent programmer, this is a benefit, because *you* get
to decide what the best solution is. If you're an incompetent
programmer, this is a burden, because it requires you to think
critically about what you're doing, and (as the hypothetical "you" is
incompetent) you'll probably get it wrong anyway.

And if you find that that last bit is too much of a burden, well, if you
found Perl, you can find Python, C++, Ruby, or Java.

Charlton




--
Charlton Wilbur
cwilbur(a)chromatico.net
From: Ted Zlatanov on
On Fri, 11 Jun 2010 03:11:36 -0700 (PDT) Peng Yu <pengyu.ut(a)gmail.com> wrote:

PY> On Jun 10, 8:32�am, Ted Zlatanov <t...(a)lifelogs.com> wrote:

>> I think Peng Yu is asking for something like List::Utils but more
>> general. �It's not a terrible idea; Simple::Perl (analogous to
>> Modern::Perl) could be useful to beginners and could even be a way to
>> teach efficient Perl (through an option to show the generated code). �It
>> would certainly be better than a DSL. �Another parallel is the Template
>> Toolkit, which has lots of primitives that make writing raw Perl less
>> necessary.

PY> Yes. Essentially this is what I'm asking.

Well, can you list the functions you think Simple::Perl should provide?
What would you expect from it, and what wouldn't belong in it?

PY> I think this is a more important problem than figuring out how many
PY> ways of programming there are and choosing the best one out of them,
PY> in the sense that once such choice has been figured out in a given
PY> context, then just package it into an API then people don't have to
PY> worry about it in the future.

I disagree about this, but as I said it could be useful to beginners.
I'd suggest you investigate Lisp (especially the syntax tree and the
macros), Google's Guava project, and the Template Toolkit to understand
the concepts of metaprogramming and why a simple API may not be the best
approach. Guava is probably closest to your ideal.

On Thu, 10 Jun 2010 13:23:39 -0500 John Bokma <john(a)castleamber.com> wrote:

JB> But what's better? Logic in two places or in one? I have often the
JB> feeling that dumbing down a template language results in reinventing
JB> HTML and making it smarter and smarter results in the reinventing of
JB> PHP (but better :-D ).

There's quite a few opinions on this balance (which I'd say is one of
the fundamental elements of programming) in the terrific "Coders at
Work" interviews by Peter Seibel; L Peter Deutsch in particular comments
on how frustrating it is that today's software has essentially made no
progress since the late 60's to abstract logic and constraints out of
the code. I think Lisp macros are the best answer to your question so far.

JB> IMO: Perl has a strong focus on not breaking things, while Python has a
JB> strong focus on cleaning up the language / extending the language in a
JB> clean way (if it makes it more Pythonic). I still don't know what's
JB> better. I wish that Perl by now had real OO support and real
JB> exceptions. OTHO, I manage and I do like how flexible Perl can be. And
JB> its (relative) speed.

I simply don't enjoy the dry Python syntax. Java is similarly boring
(though it has become livelier with generics and now the upcoming Java 7
features). Perl and Lisp (and Ruby, their mutant child, which I kind of
like) are much more fun to write and so I do. IMHO every programmer has
these likes and dislikes and we simply layer excuses on top :)

Ted
From: Charlton Wilbur on
>>>>> "PY" == Peng Yu <pengyu.ut(a)gmail.com> writes:

PY> Rather than being hypothetically saying there are different ways
PY> of coding for different parameter values. I'd like to see what
PY> the best code is for reading three lines and what is the best
PY> code is for reading 10000 lines?

PY> And I would like to know how much time and effort it would
PY> require to know the different between the different code and how
PY> much actually difference (say in performance or whatever
PY> metrics) can be gained by careful choosing different ways.

You're a programmer, and programming is as much empirical art as
theoretical science. Try it and see, and learn something.

Charlton



--
Charlton Wilbur
cwilbur(a)chromatico.net