Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Perl is a post-modern aesthetic language

by cosimo (Hermit)
on Jan 16, 2005 at 21:21 UTC ( #422640=perlmeditation: print w/replies, xml ) Need Help??

These days I was thinking that Perl, which is by no doubt my preferred programming language, is also an highly aesthetical language. If you look at perl6 language (off-site), several discussions about core language grammar and features can be cut down to "language aesthetical beauty". While someone talks about a syntax and tells that it is nice and clean, some other says that one expression looks ugly, ...

What I think is that I like to express my perly style through code reformatting and "tuning" to make it look nice, clean and expressive.

Probably an example can clarify my confused ideas. The following code, for my own personal perl aesthetic taste, is awfully ugly:

my $i=0; for( $i=0; $i<=$n; $i++ ) { $list[$i] = &foo(1, 2, 3, 4, 5); if( $#list > &max_length ) { last; } my $result = &bar("$n", @list); if( $result > 999.999 ) { print STDERR "System halt"; exit; } }
I surely prefer something like:
for( 0 .. $n ) { push @list, foo(1 .. 5); last if @list >= max_length(); warn('System halt') and exit if bar($n => @list) > 999.999; }

In fact, I really hate those &function_calls(), the use of double quotes around "$scalars" (if they don't have a special meaning), and so on...

What is special and wonderful about Perl is that you can express your own style, very much like spoken language.

Trying to apply your personal stylish influence to Java, or (worse) to Python (which BTW is a wonderful language) IMHO just won't make sense...


(no language flames should start from here :-)

Another sub-meditation: isn't Perl6 design highly influenced by aesthetical appearance ?

Janitored by davido: Changed pre tags to code tags, and turned link into a PerlMonks style link.

Replies are listed 'Best First'.
Re: Perl is a post-modern aesthetic language
by davido (Cardinal) on Jan 17, 2005 at 03:08 UTC

    There are many levels and facets to defining asthetics. Someone who appreciates the taking of life at face value might say about a Picasso painting, "Why are all the people so ugly? Why are they distorted?" And the person who enjoys the Picasso might be bored with the simple grandeur of an Ansel Adams photograph.

    When I look at well written Perl code, I appreciate the elegance. The bigger picture is quite elegant. I see that beauty in constructs such as the Schwartzian Transform, file operations, and so on. And yet when you look at the individual trees in the Perl forest you see things like s/([\w\s]+)(?!\d)/lc $1/eg; and quickly realize that while the solution (the forest) is elegant, the leaves and branches (the syntax) are a little shabby. This isn't to condemn Perl in any way. I happen to like the terse nature of the language. But I'm pointing out that to one who doesn't look at the bigger picture so much as the details of implementation, Perl may be asthetically displeasing.

    We all look at art and science in different ways. Naturally when someone asks the Monastery how they feel about Perl, you're going to get a lot of enthusiastic hurrahs. Bach inspires such favorable reaction among those who enjoy classical baroque music. And yet his complex style may not be fully appreciated by the likes of Charlie "Bird" Parker. On the other hand, Bach would probably not find much pleasure in Parker's harsh style of jazz either. Me, I like them both, but that's just me. ;)

    We happen to mostly be Perl proponents here. And from my perspective, it's easy to see why Perl enjoys this kind of a following. After all, I find it asthetically pleasing. ;) I wouldn't be surprised to hear that there are people out there who find Lisp (or insert some other language here) pleasing too. ;)


    Dave

      Hey, sometimes I write LISP that happens to be parsed by perl :)

      my @DB_FIELDS = qw/ foo bar baz /; my $sql = 'INSERT INTO table ('; $sql .= join( ', ', @DB_FIELDS ); $sql .= ') VALUES ('; $sql .= join( ', ', map( '?', @DB_FIELDS ) ); $sql .= ')';

      OK, so I could have used the x operator instead of map, and it doesn't quite have the extreme paren-nesting that LISP does (in fact, it's possible to get rid of many parens while maintaining correctness). I have some more extreme examples that make you swear you fell into another interpreter, but I can't think of them ATM.

      In any case, LISP is remarkable (in its orginal form) for being an incrediably small language without falling down a Turing-tarpit. It's arguably more minimalistic than BF, and you can still write real programs in it without tearing your hair out.

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Re: Perl is a post-modern aesthetic language
by Anonymous Monk on Jan 16, 2005 at 21:47 UTC
    In fact, I really hate those &function_calls(), the use of double quotes around "$scalars"

    Using & for function calls and unnecessarily quoting scalars has different semantic effects. Sometimes those semantic differences are intended, but often the person who uses those constructs doesn't realize them. This is probably the reason they have become bad style.

Re: Perl is a post-modern aesthetic language
by g0n (Priest) on Jan 17, 2005 at 14:00 UTC
    In keeping with the 'Natural language Principles in Perl' article & some of the comments on thread 'People watching' its tempting to regard individual style as being a sort of coding 'accent', traceable to other languages and the coders you've worked with.

    I picked up habitual java style capitalizationOfVariableNames from working with java programmers perl scripts for example.

      I picked up habitual java style capitalizationOfVariableNames from working with java programmers perl scripts for example.
      The proper way to do it is $lpszwMyVariableHelloWorld = "Hello World!";
        Where does the wide in lpszw come from? Are you utf8ing??


        qq/madams55075.spamtrap.@comcast.net/ =~ s/\.spamtrap\.//;

Re: Perl is a post-modern aesthetic language
by Anonymous Monk on Jan 17, 2005 at 15:10 UTC
    Trying to apply your personal stylish influence to Java, or (worse) to Python (which BTW is a wonderful language) IMHO just won't make sense...
    This is pretty much flamebait. Python list-comprehensions, generators, and first-class functions make it very expressive. Now try to implement FP in Java and you are stuck with Anonymous Inner Classes to simulate Functors, which is infinitely worse than Perl/Python. You clearly haven't delved very deep into either of these too. While Python supports limited ways of rewriting the language, it is VERY expressive, and only a small notch down from Ruby.

      I was *not* saying that Python is not expressive. In fact, I think Python is really great, it has an overall code elegance that Perl does not have ({$#@}). Perl however, is far more sensitive to one's own personal style. In this sense it is more expressive.

      Sorry I didn't intend to flame Python or Java in any way. There's already too much language flames these days...

Re: Perl is a post-modern aesthetic language
by dimar (Curate) on Jan 19, 2005 at 07:31 UTC

    Sometimes, musical analogy says it well:

    The playing of some virtuosos is like the gait of a drunkard. Make not such your models.
    .. and ..
    There are no wrong notes, only wrong resolutions.
    .. and ..
    A good musician can make mistakes as long as they seem like they were planned, and evoke amazement and beauty by intentionally making what seems like mistakes, only to resolve them later, when no one is expecting it.
    see also: rules for young musicians

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://422640]
Approved by friedo
Front-paged by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2020-11-25 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?