Slashdot Mirror


Apocalypse 3

rob_99 writes: "The third installment of the Apocalypse is out!" You may have missed the first or second Apocalypses. This one is roughly "all about operators".

32 of 151 comments (clear)

  1. Breaking out of your own culture by Water+Paradox · · Score: 4, Interesting

    "Breaking out of your culture is also important, because that is how we understand other cultures. As an explicitly multicultural language, Perl has generally done OK in this area, though we can always do better. Examples of cross-cultural exchange among computer cultures include XML and Unicode. (Not surprisingly, these features also enable better cross-cultural exchange among human cultures -- we sincerely hope.)"

    It is for statements like this, that I am drawn into studying and using Perl. Many designers try to design a langauge which develops its own internal culture; it becomes static and internally consistent, but not very adventurous. Larry Wall seeks to develop a language which has built-in the fact that we like to explore, making his task more difficult, but a language which moves and flows with the evolution of our culture readily.

    Keep up the great work!

    --
    information is immaterial
  2. keeping track of ops..? by _Mustang · · Score: 2

    Perl gets around some of these problems by keeping track of whether it is expecting an operator or a term. As it happens, a unary operator is simply one that occurs when Perl is expecting a term. So Perl could keep track of a unary = operator, even if the human programmer might be confused.

    This seems to be a seriously smart way to do sytax checking. Is this drawn from an existing implementation in a different language or is it a new development that he thought up?

    Speaking from my own experience as a non-developer coder, I'd love to see more of this kind of "artificial" intelligence in programming languages. I really love the power of languages such as c/c++ but keeping track of every possible way I can fsk stuff up is just impossible. I definately think having more checks in place (within reasonable limits) would certainly make for better code all around.

    1. Re:keeping track of ops..? by Ian+Bicking · · Score: 3, Interesting
      Well, there's not really anything novel in what he's talking about. Almost all languages do the same thing. Consider these two expressions:

      5 - 3
      5 + - 3

      The first "-" relates to subtraction. The second one relates to negating a number. Those are two different kinds of operations, and those are considered two different operators. You can tell the two apart, because in the first one when you encounter "-" you are looking to extend the expression; while in the second when you encounter "-" you are looking for a second term to go after "+".

      You could do the same thing with "=", but that sort of thing can get confusing. Imagine an expression $x = =$y (quite different from $x == $y !)

  3. Concatenating strings by seanadams.com · · Score: 4, Insightful

    He stresses the importance of good huffman coding, then goes on to change the string concatenation operator "." to a three character sequence " _ "

    ...instead of:

    $a . $b . $c

    you'll say:

    $a _ $b _ $c


    String concatenation is such a commonly used perl feature that it deserves a single character operator. Discriminating between operators by the existence of white space before/after the character is an incredibly ugly kludge. Larry seems to admit it, too: This is to be construed as a feature

    At least we don't have to use "+", like in JavaScript!

    1. Re:Concatenating strings by John+Miles · · Score: 2

      I'm really not interested in using any language in which 'a'+'b'='c' is true. Maybe that's just me, though.

      --
      Dahlmann tightly grips the knife, which he may have no idea how to use, and steps out into the plain.
    2. Re:Concatenating strings by motb · · Score: 2, Informative
      'He stresses the importance of good huffman coding, then goes on to change the string concatenation operator "." to a three character sequence " _ "'

      Actually, I'd be surprised to see that stick around once Unicode support is rock-solid on the popular platforms. Larry mentions using non-ASCII operators, and I'm almost sure string concatenation will use one of these.

      For my part, though, I actually like spaces around most binary operators, and wouldn't be upset to see it enforced in the language. That way, people would write unreadable code in my style of unreadable coding. ;)

      I'm looking forward to non-ASCII operators. I understand they were much loved on the Lisp machines, and much hated in APL. Different ways of handling things in the two languages, though, so it might be a contextual thing. It will be interesting to see how they are received after twenty years or so of disuse.

      --
      -- http://www.membersofthebored.com Keep an open mind -- you'll need it!
  4. As I sheepishly back away... by hillct · · Score: 4, Interesting

    I never really thought about how valuable perl really is. I use it constantly. I use it based on the syntactic rules set fourth in the cammel book. I never considered evaluating changes to the language (well, not to any great degree anyway. While I find Larry Wall's series of articles interesting, I just can't get excited about changing the language in it's next incarnation. It works. It's an effective tool. That's good enough to me. I'm not saying don't change it, so much as in it's role as a tool I find it valuable, but when given the opportunity to provide feedback on how to change it I'm at a loss.

    Now, I consider my job to be 'Intranet Systems Arhitect' as distinct from 'Programmer'. Perhaps that's why I can't get excited about changing a tool I've come to depend on in it's current form. Perhaps true programmers might find the prospect fascinating. perhaps you could liken it to the difference between an army officer and a gunsmith. While both make use of guns at various times, only the gunsmith is inclined to take the gun apart, examine it and make a better one.

    Or perhaps I'm just not showing the proper community spirit, and I should dive in and offer my two cents on how to make the language better. Maybe I'm just lazy (then again, isn't that why perl is such a great language...)

    --CTH

    --

    --Got Lists? | Top 95 Star Wars Line
  5. Larry is always interesting by Ars-Fartsica · · Score: 3, Interesting
    Regardless of your opinion of perl, I find Larry's writings to be consistently insightful and although the humor os a bit corny, somewhat amusing.

    How perl 6 will fare is another issue. The language is going to change radically - will developers follow Larry into perl 6, just use perl 5 compatibility mode, or move on altogether?

    1. Re:Larry is always interesting by jallen02 · · Score: 2

      Im just not sure how practical it is.. well see..

      Jeremy

    2. Re:Larry is always interesting by Black+Parrot · · Score: 3, Funny


      Is this the same -Wall whose name scrolls past so many times when you recompile your kernel?

      --
      Sheesh, evil *and* a jerk. -- Jade
  6. Perl trying to outgrow its niche by Starship+Trooper · · Score: 3, Interesting

    Let's face it, perl is absolutely great for its original intention - fast, easy, write-and-forget scripting. But as I see the plans for Perl 6 unfold, one thought comes to my mind - Yuck. The language they propose is bloated and convoluted beyond words; it's clearly evident that Wall and his fellow "designers" are struggling vainly to make Perl "grow up" -- something that it has absolutely no need to do. There are other languages out there to fill the other niches; languages which try to do everything doom themselves to failure. Ambition kills.

    --
    Loneliness is a power that we possess to give or take away forever
  7. Re:Heh... by sbeitzel · · Score: 2
    What's funny is first, he overuses the $ sign like mad, and perl is so well known to be unreadable.
    I bet you're just bitter because you don't understand it.
    Wow, touchy much, kilgore? In point of fact, when I read Larry's comment about functional languages overusing parentheses and OO languages overusing . I immediately thought, "Nu? So in Perl 6 we won't have to use $ in front of EVERY SINGLE VARIABLE?"

    And as to perl's infamous illegibility, it's true that the code's readability has a lot to do with the author and only a bit to do with the language. But I'll tell you right now that most of the perl fanatics I've met and all of the perl coders with whom I've worked came to the language from little or no programming experience. This means that nearly all the code I (and they) encountered was written by someone who had, at the time of authorship, only the vaguest of notions about legibility.

    Remember, dude, just because you like a particular thing doesn't mean it doesn't have flaws.
    --
    Oh, go on, check out my job.
  8. Re:Heh... by el_nino · · Score: 2

    Most of the Perl coders you have experienced might have been bad, but that says nothing about whether Perl is good or bad. If whatever language you prefer suddenly gets an influx of really poor programmers, will you switch?

  9. Limerick by 575 · · Score: 2, Funny

    There once was a hacker named Wall
    To maintain his own scripts, his downfall
    He released to the world
    A wonder named Perl
    You can write code, but never recall!

  10. also too bad underscore requires pressing shift by Preposterous+Coward · · Score: 2
    one of the nice things about the dot is that it's a single keystroke. the underscore may be a single character, but (at least on English) keyboards it requires two keystrokes.

    of course perl has such extensive string interpolation and other capabilities that this doesn't strike me as a humongous problem.

    I, too, hate the whitespace kludge, but then i've always put whitespace around my dots too because print $this . $that just seems more readable to me than print $this.$that, which looks disturbingly like some kind of slightly funky method call.

    --

    "Biped! Good cranial development. Evidently considerable human ancestry."
  11. Sweet! Hyperoperators! by Fixer · · Score: 2, Interesting
    I like the way Perl6 is going, I have to say. Though I kind of agree with others, changing
    $a.$b.$c
    to
    $a _ $b _ $c
    kind of bites. Then again, this could also be looked at as readability enforcement. Common cases:

    $a = $b.$c;
    print "Hello: ".$you."\n";

    becomes

    $a = $b _ $c;
    print "Hello: " _ $you _ "\n";

    It is definitely more readable, but I dislike significant whitespace. shrug
    But as to the rest of the proposed changes, I can't wait.

    --
    "Avast! Prepare for the rodgering!" THWACK! "Arrr.. me nards.."
    1. Re:Sweet! Hyperoperators! by OddHackGEA · · Score: 2, Informative

      > $a = $b.$c;
      > print "Hello: ".$you."\n";
      >
      > becomes
      >
      > $a = $b _ $c;
      > print "Hello: " _ $you _ "\n";

      Or just

      $a = "$b$c";
      print "Hello: $you\n";


      like you can do right now.

      I can't tell yet whether "$a:b" will change, but presumably the Perl5 clarification "${a}:b" would still work.

    2. Re:Sweet! Hyperoperators! by ichimunki · · Score: 2

      I think it sounds annoying as heck, because I tend to use a lot of _ in my variable names. Things like $foo_bar are a lot more readable than $fooBar, imho-- and allows me to save caps for other purposes like constants and the occasional global.

      --
      I do not have a signature
  12. No, result should depend on types of operands by SMN · · Score: 3, Informative
    'a'+'b' = 'c'?
    'a'+'b' = "ab"?
    No, the results of this should rely on the type of the operands, as it does with numerical values in C and C++ and most C++ classes. Keep in mind that single quotes denote a character (really an 8-bit ASCII value), and double quotes indicate a string (usually zero-terminated):

    'a' + 'b' = 'Ã'
    (char and char results in another char by adding their ASCII values)

    "a" + 'b' = "ab"
    (string and char results in a string by concatenation)

    'a' + "b" = "ab"
    (char and string -- order does not matter, so see string and char above)

    "a" + "b" = "ab"
    (string and string results in a string by concatenation)

    To summarize, if a string is involved, then the char(s) is (are) promoted up to string(s) and the result depends on concatenation. If all operands are chars, then no promotion occurs and they are added by ASCII value.

    This is similar to the numerical addition rules of C, C++, and a number of similar languages. One simple example: If an int and a float are added, the int is promoted to be a float and the result is a float. If an int and an int are added, the result is an int and must by cast (either explicitly or implicitly) in order to be a float value.

    I'm not too familiar with Perl, but this seems to be the most sensible behavior. If I'm missing something and there's a valid reason not to use an addition sign for concatenation, please reply and let me know.

    --
    -- Imagine how much more advanced our technology would be if we had eight fingers per hand.
    1. Re:No, result should depend on types of operands by James+Lanfear · · Score: 3, Informative
      No, the results of this should rely on the type of the operands, as it does with numerical values in C and C++ and most C++ classes.

      They do, but the rather essential point that your missing is that in Perl both 1 and "1" are scalar -- they have the same type (in an obviously broader sense of the word). "1" + "1" produces "2" (or 2), as does 1 + "1", "1" + 1, and 1 + 1; and, as you might expect, "1" . "1" and 1 . 1 (note the whitespace) produces "11". Thus the need for distinct syntax, which is already present in the equality operators, where you have == vs eq, > vs gt, etc.

      Keep in mind that single quotes denote a character (really an 8-bit ASCII value), and double quotes indicate a string (usually zero-terminated)

      As has already been stated, single and double quoting controls variable interpolation in Perl; there are no character constants as such. And since we're playing lanaguage lawyer, (non-wide-)character constants in C are actually int's, and are not required to be ASCII (which only uses 7 bits, anyway), and strings are by definition null-terminated.

      I'm not too familiar with Perl

      Which begs the question of why you posted in the first place.

  13. Re:Not a good title by Matchstick · · Score: 3, Informative
    See the definition:
    Apocalypse \A*poc"a*lypse\, n. [L. apocalypsis, Gr. ?, fr. ? to uncover, to disclose; ? from + ? to cover, conceal: cf. F. apocalypse.] 1. The revelation delivered to St. John, in the isle of Patmos, near the close of the first century, forming the last book of the New Testament. 2. Anything viewed as a revelation; a disclosure.
    Or read the first paragraph of the first apocalypse:
    People get scared when they hear the word Apocalypse, but here I mean it in the good sense: a Revealing. An Apocalypse is supposed to reveal good news to good people. (And if it also happens to reveal bad news to bad people, so be it. Just don't be bad.)
  14. More eclectic, less practical... by forehead · · Score: 3, Interesting

    Before I begin, I know that Perl is Larry's baby and he can do with it what he likes. But I wouldn't be so vocal about this if I didn't care. ;-) That said...

    Maybe it is just me, but the more and more I see what is going on in the perl world, the less and less I want to have anything do with it. The whole
    hyper-operator conecpt is a good example. My thoughs? Just use a fscking for loop. That is what they were designed to do. Larry seems to be going through *great* pains to include as many bizzare syntactic short cuts as you can reasonably string characters on the keyboard to represent. This is not terribly innovative.

    It's starting to diverge from "Practical extraction and report(ing) language"
    and towards "pathetically Eclectic rubbish lister". Personally, I aim a little more towards practical. That was what made it so popular to begin with. Make difficult things easy and hard thing possible was a nice concept. Perl 5 did that well. IMNSHO, Perl 6 seems to be making 100 ways to do the same simple thing all so the developer can opt to use the method with the verbosity level he/she desire, and not making the hard things any easier.

    </rant>

    --
    --
    1. Re:More eclectic, less practical... by Fixer · · Score: 3, Informative

      Okay. All languages that are Turing complete are equivalent, as you well know. So why do we need more than one language?

      --
      "Avast! Prepare for the rodgering!" THWACK! "Arrr.. me nards.."
    2. Re:More eclectic, less practical... by Mr_Huber · · Score: 3, Insightful
      Why, then, does Perl include a 'foreach' operator when a 'for' loop will do just fine? Efficiency. By giving the language a hint as to what you are going to do, it can iterate through the list faster and with fewer resources. I expect that when the implementation arrives, we will find the hyper operators offer a not-insignificant efficiency gain over a simple for loop.


      The point of Perl is not necessarily to provide more than one way to do things, but to make certain types of programming much easier than with other languages. There are things I do in Perl in an hour that would be a week undertaking in C or C++. If enough users are calling for these seemingly esoteric features, add them. The more expressive the language, the more useful.

    3. Re:More eclectic, less practical... by tstock · · Score: 2, Informative

      Your FOREACH and FOR example is without merit.

      ripped from perlsyn (man perlsyn):

      The `foreach' keyword is actually a synonym for the `for' keyword, so you can use `foreach' for readability or `for' for brevity.

      I do agree on your point though, you just choose a bad example and topic, since 'Efficiency' for perl *normally* means coding better and faster, not running faster.

    4. Re:More eclectic, less practical... by Junks+Jerzey · · Score: 2

      The foreach construction allows Perl to better understand your intention. It takes advantage of that knowledge to increase its efficiency.

      Although if your're _that_ pressed for run-time efficiency, then you shouldn't be programming in an interpreted language in the first place. Sure, "for" is slower than "foreach" but replace all occurrences of the latter with the former is any application and what do you get? Certainly not a perceptible difference.

      What matters in this case is that foreach style loops are easier for humans to parse.

  15. Functional languages and parentheses by V.P. · · Score: 2, Informative
    Actually, not all functional languages use parentheses; that's just Lisp & friends. In modern functional languages like Haskell, you end up using fewer parentheses (and other punctuation) than in C, Python, or Perl.

    For example, Haskell parses f 0 + f 1 as: f(0) + f(1) (In a less obvious way, it also parses f g x as f(g, x), but that's another story...)

  16. don't jump to conclusions: by Anonymous Coward · · Score: 4, Insightful

    For all of those people who want to jump ship from perl6, all I can say is I'd give it some time. I've been playing around with the syntax in perl6, and I think people are giving it way too much short shrift, without thinking no less. Here, for example, are a couple of equivalent programs in perl6 and perl5:

    Concatenating two arrays together:

    perl5

    my $biggest_index = (@array1 > @array2)? @array1:
    @array2;

    for ($index = 0; $index $biggest_index; $index++)
    {
    $array1[$index] += $array2[$index];
    }

    perl6:

    @array1 ^+= @array2;

    Comparing all of the elements in an array to one another for equality:

    perl5:

    for ($xx = 0; $xx @array1; $xx++)
    {
    ($notequal = 1, last) if ($array1[$xx] ne $array2[$xx]);
    }
    if (@array1 != @array2)
    {
    $notequal = 1;
    }
    else
    {
    $notequal = 0;
    }

    Perl6:

    $notequal = (@array1 ^!= @array2);

    Perl5: setting an element to the first defined item:

    my $element = (defined($a))? $a : (defined($b))? $b: 'default';

    perl6:

    my $element = $a // $b // 'default';

    etc, etc. I could go on, but I'll leave it to damien && his exegesis...

    Now, you could argue that things like the above don't belong in the language proper, and that it would be better to write functions to do them, but believe me, there are a hell of a lot of different low level functions that you can write, all with a little wrinkle here or there that makes them *slightly* different from the functions that you've written before - like doing cmp instead of ==, and so on.

    So don't bolt before you see the final result.. I think its going to be really cool, especially being built on top of parrot....

    Ed

    (ps - as for the OO, I'd *also* hold my tongue if I were you. I've used the OO features of perl5 extensively, and its exceedingly flexible. There are aspects that I don't like (like no type checking of attributes as they are in a hash) but even this can be used to your advantage in programming.

    so its definitely *not* worthless, and definitely something worth checking into. 50,000 line APIs don't just spring up overnight...

  17. Unicode operators? by iabervon · · Score: 3, Funny

    It'll be so great to be able to use expressions like "x y". Of course, you'll have to define for yourself what an eight teardrop-spoked propeller asterisk does...

    Hmm... slashdot doesn't seem to like my character. Gonna make it hard to ask about my programs...

  18. Re:Change is good by hillct · · Score: 3, Insightful

    In responding to the previous poster my first inclination was to defend my perl programming prowess but instead of descending into such a ridiculous debate of an issue that would only be of interest to my clients and myself, I'll just clarify my point which was more that I have never found anything that I wasn't able to do in perl more easily than I could have done in C and that I wasn't able to find any specific single item in Larry's article that would make my use of perl significantly more convenient or effective. That's not to say that I'm against making changes to perl. If it can be improved, so much the better.

    --CTH

    --

    --Got Lists? | Top 95 Star Wars Line
  19. Re:Unicode operators? (slightly OT...) by iabervon · · Score: 2

    Ah, right. Yes, if I do the right thing, *then* slashdot doesn't like my character. Of course (❊) seems to work (maybe), but it's a pain to type decimal character values for unicode characters.

  20. Re:operators by cloudmaster · · Score: 2

    Hey, I was just thinking yesterday that there really oughtta be something like ?= - though I was working with php at the time (which is slowly getting replaced with eperl).