On Wed, Mar 10, 2004 at 10:43:21AM +1300, Michael JasonSmith wrote:

>  * Perl suffers the same problem as TCL, sh and (non-visual) Basic
>    in that it is hard write a program over 25 lines that does not
>    descend into a pile of spaghetti.  Other languages ? such as
>    Moduala-2, C, Smalltalk and Python ? force you to write
>    structured code that is easy to read and maintain.  The good
>    ones, like Samlltalk and Python, do it in such a way you do not
>    even know you are being encouraged to write good code.

You can write awful code in Python (and Smalltalk) too.  With Python,
it'll just be nicely indented.  I agree that Perl requires somewhat more
discipline to program in.  It is easier to end up with an ugly looking
piece of code in Perl than Python, because Perl is not sensitive to
whitespace and can be significantly terser than Python.

>  * Too complex for the simple things.  If I want to write some code
>    to munge data from one file into another, then I use AWK or sed
>    (simple, does one thing well). If either is too simple, then I
>    will use Python or C (see the first point for why).

I tend to use AWK and sed when the problem is simple, too.  But Perl
(and Python, to a lesser extent) has a far more powerful regular
expression engine (among other things) that allows you to perform data
munging tasks that are all but impossible with AWK or sed--this is part
of the reason Perl was created; to provide a better tool for the task
than AWK and sed.

>  * Too many ways to do things.  Usually I do not want to have to
>    worry about the benefits of writing a loop one way compared with
>    another.  If I really cared about how the system interpreted my
>    code I would use C or assembler.  Then I have *real* control.

If you don't want to worry, then don't worry.  If you care a little bit,
then learn the idiomatic way to write the structure in the language
you're using.  If you care a lot, then try writing it every way you can
and work out which method is appropriate for your program.  It seems
that this particular statement is too general to apply to just Perl.
Yes, Perl's motto is "there's more than one way to do it", but I think
you're taking the motto out of context.

>  *  Perl's data structures bite.  Evidence for the prosecution:
>     declare an array (also known as a hash-table or dictionary) that
>     contains other arrays and try to access an element from an inner
>     array. 

This is confusing.  Are you saying that an array is the same as a
dictionary in general Computer Science, or are you saying that Perl
implements arrays as dictionaries?  In either case, that's not correct.

Perl has plain arrays, indexed by integer, and the type specifier for
these is "@".  Perl also has hashes (also known as associative arrays or
dictionaries), the type specifier for these is "%", and they are indexed
by key.

I suspect you know this fact--so it is probably some miscommunication.

Cheers,
-mjg
-- 
Matthew Gregan                     |/
                                  /|                [EMAIL PROTECTED]

Reply via email to