in reply to Re: Re: Re: Perl6 syntax being too much complex? How we will teach and read that?!
in thread Perl6 syntax being too much complex? How we will teach and read that?!

I'm pretty certain the fact that Perl has a lot of syntax isn't key to its usefulness. It is key to its readability (when the programmer actually puts effort into expressing himself naturally), but not to usefulness.

Look at the usefulness of the aforementioned LISP, which doesn't have very bare syntax, but rather really has no syntax (the programmer is basically writing raw parse trees in textual representation). Yet LISP didn't have to syphon all that complexity into class libraries to be useful; it is right there in the core of the language.

Remember that Perl6 is doing a lot to orthogonize Perl syntax — sometimes adding by adding to it, but not rarely by dropping cases that so far have been special or by integrating multiple special cases in a unifying frame.

The elegance of C is its minimalism in assumptions — it doesn't do any of your work for you, but it also doesn't prevent you from doing anything. C++'s failure is that it implements the restrictions necessary to implement a higher level world view without offering any higher level constructs to get work done easier. You still have to do as much legwork to get places as in C, but suddenly you're no longer allowed (nay, even able) to walk across the field. You get no car, not even a bike, but you have to stick to the roads now.

Makeshifts last the longest.

  • Comment on Re^4: Perl6 syntax being too much complex? How we will teach and read that?!

Replies are listed 'Best First'.
Re: Re^4: Perl6 syntax being too much complex? How we will teach and read that?!
by BrowserUk (Patriarch) on Mar 24, 2004 at 18:47 UTC

    I think we are saying much the same thing, but quibbling over terms :) I'd only note that there is a difference between "useful" and "usability".

    I like the "raw parse trees" description of LISP. I'd never really thought of it that way, but it is a very accurate description from my less than comprehensive knowledge of the language. I assume that there is some mechanism for code re-use in LISP? Even if it is only something like include files? I also have no idea how you would read/write a file in LISP. I keep meaning to get around to installing a build of Scheme and playing.

    P6 is definitely doing some things to orthoganise the language--consistant use of $, @, % comes to mind--but there are other areas where calls for orthoganality have been rejected. The most obvious example I can think of is length. I don't think that we are likely to see

    my $sizeOfArray = @array.length;
    or
    my $sizeOfArray = length @array;
    nor
    my $lenOfString = scalar @$scalar;
    (though I personally still hanker for my $substring = $scalar[ 3 .. 7 ];).

    So, whilst P6 is regularising the language in many places, it's being done not for sake of orthoganality itself, but to simply the use of the language. If it also makes it more elegant, thats great, but I don't think that is the primary drive for change.

    Let me add, I think that Perl 5 can be elegant. Some of Abigail's recursive solutions are extremely elegant. Likewise some of your code. But as you've noted about some of my P5 in the past, it's also possible to produce stuff which is "Yuck!":)

    As for C++. I've fairly recently discovered a language that I think achieves most of what C++ set out to achieve (except backwards compatibility), but that does it with much less complexity. It's still evolving, and I haven't had opportunity to make a great deal of use of it in larger programs yet, but the simplicity of its objects, the automatic memory management, built-in associative arrays endear me to it strongly.

    The fact that I can still get down and dirty with the machine as with C, but have a few more HLL features to simplify things, plus the compiled-to-native performance make it really interesting to me.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
      In fact, you're not even going to see
      my $sizeofstring = length($string);
      That's because "length" has been deemed to be an insufficiently specified concept, because it doesn't specify the units. Instead, if you want the length of something in characters you use
      my $sizeinchars = chars($string);
      and if you want the size in elements, you use
      my $sizeinelems = elems(@array);
      This is more orthogonal in some ways, insofar as you can now ask for the size in chars of an array, and it will add up all the lengths of the strings in it for you:
      my $sizeinchars = chars(@array);
      And if you ask for the number of elems of a scalar, it knows to dereference it:
      my $ref = [1,2,3]; my $sizeinelems = elems($ref);
      These are, in fact, just generic object methods:
      @array.elems $string.chars @array.chars $ref.elems
      And the functional forms are just method calls in disguise.

      So maybe length() is a bad example now. Sorry. :-)

      By the way, you can also use %hash.elems, which returns the number of pairs in the hash. I don't think %hash.chars is terribly useful, but it will tell you how many characters total there are in both keys and values.

      Actually, the meaning of .chars varies depending on your current level of Unicode support. To be more specific, there's also:

      $string.bytes $string.codepoints $string.graphemes $string.letters
      ...none of which should be confused with:
      $string.columns
      or its evil twin:
      $string.pixels

        Better & better.

        Presumably my elems = $nonrefscalar.elems; is just an error?

        Do you need the parens for the functional form or can you do my $noffchars = chars $scalar:;


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail

      (Note: I knew about the method call syntax and was going to mention it — but Larry did, so I don't have to. As is the case with many things. Thanks, Larry!)

      Perl6 is going for more orthogonality than you may have been thinking. We're not going to get @array.length exactly, but a rose by any other name (@array.elems), well…

      Makeshifts last the longest.