Periodic Table of the Operators 323
mAsterdam writes "At his code blog Mark Lentcner writes:
"A while back, I saw Larry Wall give a short talk about the current design of Perl 6. At some point he put up a list of all the operators - well over a hundred of them! I had a sudden inspiration, but it took a few months to get around to drawing it..."
You might want to take a look at this and think about which operators are yet to be discovered."
Re:Oh my sweet Jesus... (Score:4, Insightful)
Re:Oh my sweet Jesus... (Score:2, Insightful)
Contrast this to something like Python which I find barely acceptable as a high-level language. The syntax is just as tedious and verbose as something like C++ or Java. Which raises the question, why use the slower Python at all? Try using regular expressions in Python. It is kinda like using them in C++ or Java, eh? Now try it in Perl where it's built-in (special operators). Seamless, fast, and easy.
The only things I like better about Python are that it has a simple built-in interactive mode, a better object system, and it's easier to integrate into non-Python projects. The language itself sucks though.
Awful! XD (Score:4, Insightful)
Re:Oh my sweet Jesus... (Score:5, Insightful)
This duality is already a feature of Perl and it actually is a necessity. The reason is that string compare and numeric compare are different desired operations.
Let us say that perl used == for both string and numeric compare. Now let us say that someone wrote the following statement in a perl program: "3.0" == "3". Does this return true or not? If we perform a numeric compare, then yes. If we perform a string compare, then no. Now, you can point at my example and say that since 3 and 3.0 were both quoted here, clearly the programmer intended for 3 and 3.0 to be treated as strings. However, if rather than literals those had been variables-- maybe taken from user input-- that would have been no such indicators. The language has no way to tell what to do.
This really so much isn't about types as it is about the fact perl will autobox numbers in and out of strings for you. I'll give you Perl has many features that just make one's head hurt, but this isn't one of them.
Really, it's not too bad. (Score:2, Insightful)
Alot of them, for example, are numeric operators that should be familar to most programmers: !=,==,=,&,&&,, and so forth. About a third of them are regex operators. And among those that are left, many are either common Perl operators, or are not that difficult to figure out if you don't know what they are--e.g., "eq".
I could make up a similar list for almost any other language, and it would appear pretty large.
Perl has more operators than other languages, but if you include some of the things this individual is including, I'm not sure it's that much more.
My reaction, too, was something like "whoa! what are all those!" But then when I saw what they were, it didn't seem so overwhelming.
THAT'S A LOT OF NUTS!!!! (Score:2, Insightful)
To people who don't deal with the Periodic Table of Elements on a regular basis (i.e. it isn't part of the job or hobbies), this is overwhelming. I find this interesting because I can see how the brain of a fellow human works.
Why go this trouble if they will be presented in the index of a book or an order of operations table? He's forced the information into his way of understanding. He's taken the operators and organized them in a manner that he feels they are easy to deal with.
A chemist can make everything look like chemistry. Or for the programmers, a C programmer can program C in any language.
-fragbaitPerl6 Kitchen Sink: **= as an operator?! (Score:1, Insightful)
You can write nasty code in any language (Score:1, Insightful)
Oops. I said "comprehension". That's a complicated word. It requires understanding a large vocabulary. Perhaps I should have circumlocuted instead by saying "easy to understand"? We wouldn't want to have parsimony and nuance in our expressions...
At some point you have to pay for complexity. If you don't do it at the language level, you'll do it at the phrase, block, unit, or organizational level. How long to learn Brainfuck [thefreedictionary.com] and how long to build a useful program in it?
So apart from some windy griping, only one coherent argument has been presented here to counteract Perl's dada/inclusiveness bent. That was the astute observation that the families of operators are bigger because the types are not explicit and therefore the operation must be explicit instead of relying on context to understand what "a op b" actually really means. However all is not necessarily ideal because now the type of operation disappears from the local context, hence the reason for such reviled ideas as Hungarianization ("aByteP op bByteP").
I find the most unsettling part of Perl is that I always thought scripting languages should be easy to learn: a limitation that makes them poorly suited to large or complex projects. And on the other end of the spectrum, an industrial-strength language should take years to learn properly but once mastered you can build the universe.
Operators considered optional. (Score:5, Insightful)
There is no doubt that a cleaner and more consistent language would arise from putting all the language functionality into clear and well-organized paths that everyone would use and recognize in exactly the same way. However the thing is, that is not what many people want. And I would posit that the popularity of perl proves that that is not what people want. While this chart may horrify many programmers, the simple fact is that one of the main reasons for the popularity of perl is the freedom offered by all of its shortcuts and bizarre little unnecessary operatorss. Someone programming in, say, Java, will find themselves often having to stop, scratch their heads, and try to remember or look up the method or class in the standard library used to do some trivial thing, or write a trivial function to do it themselves. While the perl programmer just scribbles out &$g =~
Perl 6's one big problem, from my perspective, is that the language is *so* big that it's unlikely or impossible any one person will be familiar with all of its features. However one of these features-- which is either horrible or very attractive depending on how you look at it-- is that it offers you the opportunity to redefine the syntax. My personal theory is that many organizations which decide to adopt perl 6 internally will use this to just cut out large swaths of the language, cutting perl 6 down to something more streamlined and manageable. That is, in order to ensure everyone can read each other's code, they will be able to just set certain coding standards-- for example, "don't use hyper operators" or "don't alter the perl grammar"-- and then enforce this by requiring everyone to include a lib that simply removes these features from the language. Do something like this, and you're left with a language which is readable yet still perfectly functional and still more attractive in many ways than many other languages.
This doesn't help though with the reason this is a big problem, though: code reuse. Perl 6 offers so many options that code written by another person or another organization, when it falls in your hands may sometimes appear to have been written in a different language than the one you are used to. And if people have been taking advantage of the syntax-redefinition features, it will literally be in a different language. However, I suspect this will not be an intractable problem for one reason. Perl 6 offers a very robust object system; it is likely that most of the code reuse in perl 6 will be done through modularity and incorporation of objects, rather than simple cut and paste code reuse. This is in fact generally the way that things work in perl 5; people just modularize everything, and learn not to poke too closely at the internals of any class they're given to work with, looking only at the perldocs. Weirdly, despite the illegible code (or perhaps because of it), the perl culture, or at least the perl module community, seems to have developed a tendency to write very exhaustive documentation. Anyhow, we shall see what happens.
One last thing. This chart is not as bad as it seems. Most of the size of this chart stems from the explosion of "operators" caused by the addition into perl 6 of APL-style "adverbial operators". (I believe the user may define their own adverbs, but I am not sure.) This means that many of the operators on this list are actually compound operators-- for example, the "add the contents of two lists" oper
Re:Some of these have a halflife of a few nanoseco (Score:4, Insightful)
But most stuff are quite logical and easy to pick up for a Perl 5 programmer like ... (yada yada yada), etc.
boolean operators,
Lots are straight Perl 5, like .. list ..), { }-use, []-use, \, etc.
eq, ne, (
quite a few are pure C (and Perl 5), like
--, ++, +=, ==, !=, &&, ||, |=, [array access], etc.
In short, it's not that different from Perl 5. An indication on the periodic table for what is different from Perl 5 would have been very useful.
Author, please?
Re:Perl 6 (Score:3, Insightful)
it stands for itself...
* ; ; ; h e l m e r . . .
| I have been slowly learning lisp over the past year and have had someone
| mention to me that I should learn perl, for jobs etc.
the unemployed programmer had a problem. "I know", said the programmer,
"I'll just learn perl." the unemployed programmer now had two problems.
having a job is not unimportant, but if knowing perl is a requirement for
a particular job, consider another one before taking that one. this is
true even if you know perl very well. life is too long to be an expert
at harmful things, including such evilness as C++ and perl.
I once studied perl enough to read perl code and spot bugs in other
people's programs (but later gained the wisdom that this was not an
accomplishment -- spotting a bug in a perl program is like spotting the
dog that brought the fleas), but I don't write in it and I don't ever
plan to use it for anything (part of my new position is quality assurance
for the systems I'm inheriting responsibility for, and part of any
serious QA is removing perl code the same way you go over a dilapidated
building you inherit to remove chewing gum and duct tape and fix whatever
was kept together for real). also, very much unlike any other language I
have ever studied, perl has failed to stick to memory, a phenomenon that
has actually puzzled me, but I guess there are some things that are so
gross you just have to forget, or it'll destroy something with you. perl
is the first such thing I have known.
this is your brain. this is perl. this is your brain on perl. any
questions?
| If I learn lisp well will I be able to do what people do with perl[?]
no, you won't. however, there is a very important clue to be had from
this: what people do with perl is wrong. perl makes a whole lot of tasks
easy to do, but if you look closely, you will see that those tasks are
fundamentally braindamaged, and should never have been initiated. perl
is perhaps the best example I can think of for a theory I have on the
ills of optimization and the design choices people make. most people,
when faced with a problem, will not investigate the cause of the problem,
but will instead want to solve it because the problem is actually in the
way of something more important than figuring out why something suddenly
got in their way out of nowhere. if you are a programmer, you may reach
for perl at this point, and perl can remove your problem. happy, you go
on, but find another problem blocking your way, requiring more perl --
the perl programmer who veers off the road into the forest will get out
of his car and cut down each and every tree that blocks his progress,
then drive a few meters and repeat the whole process. whether he gets
where he wanted to go or not is immaterial -- a perl programmer will
happily keep moving forward and look busy. getting a perl programmer
back on the road is a managerial responsibility, and it can be very hard:
the perl programmer is very good at solving his own problems and assure
you that he's on the right track -- he looks like any other programmer
who is stuck, and this happens to all of us, but the perl programmer is
very different in one crucial capacity: the tool is causing the problems,
and unlike other programmers who discover the cause of the problem sooner
or later and try something else, perl is rewarding the programmer with a
very strong sense of control and accomplishment that a perl programmer
does _not_ try something else.
it's not that perl programmers are idiots, it's that the language rewards
idiotic behavior in a way that no other language or tool has ever done,
and on top of it, it punishes conscientiousness and quality
Re:Oh my sweet Jesus... (Score:4, Insightful)
If you never get beyond hobby programming, of course, then this is almost never an issue.
Re:Oh my sweet Jesus... (Score:3, Insightful)
This turned out to be a bad thing(tm) so no-one has repeated that particular mistake since.
Re:Oh my sweet Jesus... (Score:2, Insightful)
Perl has always had this. All Perl 6 values have a type like Int or Str, but this isn't necessarily useful--I/O in Perl is done exclusively with strings, so without casting (which already exists--the ~, + and ? unary ops, along with the 'as' binary op) all the comparisons would be with strings too.
Basically, you have to have the typing somewhere. Some languages have them in the values; Perl has them in the operators. It's a design trade-off.
If you really want a magical equality that Does The Right Thing, the smartmatch operator (~~) does a lot more than the old Perl 5 regex-binding (=~) ever did. You can pretty much hand it two arbitrary objects and it'll do something appropriate with them.
Perl 6 looks like a big language--and really, it is pretty big. The trick to learning it is to recognize the parallels. For example, throughout the language the question mark is used for boolean operations, plus for numeric ops, and tilde for string ops. (The tilde is supposed to remind you of a little piece of string.) This extends to ANDs, ORs, XORs, and NOTs as well--there are the parallel sets of operators ?&, ?|, ?^, ?!, +&, +|, +^, +!, and ~&, ~|, ~^, ~!, along with logical short-circuting &&, ||, ^^, and !, and junctive operators &, |, and &. (Yeah, there's a break in the parallelism there, for hysterical raisins. Junctive operators, btw, allow you to say things like "$foo == 1|2|3", but they're a fair bit more flexible than just that.)
Re:Oh my sweet Jesus... (Score:5, Insightful)
Here is where your argument falls down. Proof by construction: There are a large number of languages of every variety that still manage to have types for that input.
Your argument is more accurately described as:
"Perl actively tries to avoid giving types to strings and numbers, and as a result of this desire to not distinguish between the two, the onus is on the programmer to do so. That's how the language solves this problem that other languages solve through stronger typing."
At this point, one can then go on and debate whether or not this is a good thing, but don't pretend that Perl has no choice. It had all kinds of choice and deliberately chose this system, most likely for backwards programmer compatibility with awk and its other predecessors.
Perl isn't "autoboxing"; that's a technical term that means that you take simple C++ or Java style scalars and automatically wrap them in an object. Perl is dynamically "looking at" the object as either a number or a string, depending on context; thus, to the programmer, every string is also a number (albiet usually 0) and every number is also a string.
Re:Oh my sweet Jesus... (Score:5, Insightful)
Stronger typing does not automatically solve this particular issue. Look at, for example, C. It uses == for numeric compare and strcmp() for string compare. Strong typing does not help here; ==, as in perl, means only one thing, and that one thing is "compare two numbers".
Now, you *can* in C++ overload the == operator on a string class you create-- or in Java the equals() method-- to do custom comparisons on specific types. However this then brings up the question of what happens if for some reason you want to do a numeric compare between two string objects. You have to somehow do a conversion to a different object type. Perhaps this is a bit clumsy. So yes, certain applications of strong typing lead to a potential way to trick the language into allowing you to perform the two different operations of string and numeric comparison with only a single operator. However you have unfortunately in doing so introduced ambiguity into your definition of equality. This does not necessarily seem like a win to me.
It is worth noting that Perl 6 offers the opportunity to strongly type your variables, and this includes numeric types. However it still uses the separate == and eq operators for numeric and string compare even when this strong typing is effect, simply as a design choice. I think this is a good one: there are already far too many situations where an operator or function in Perl behaves in different ways depending on minor details of the context, we do not need another. Again, I assure you, you are better off going to find some other grounds on which to attack Perl. You will not have to look long.
Incidentally, I used the term "autoboxing" in the sense that Perl is automatically converting data entities from string to numeric types (yes, the variables may not be "typed", but the data certainly can be said to be). I was not aware the term "autobox" referred only to conversions between object and non-object types. Oops.
Re:Brace yourself... (Score:3, Insightful)
huh? (Score:4, Insightful)
The amazing properties of the periodic table was that you could predict properties of elements that had not yet been discovered, and this amazing property is of use today. For example, we can predict that, chemically, strontium makes a good calcium analog because they are in the same column, and we are right! Strontium is often found in bones where calcium normally is. (this was important when there was a lot of radioactive strontium in fallout and when it decayed it didn't hold the bone together as well.)
Anyway way, for other properties, next-to relationships are importantand also allows for predictions to be made.
Re:Operators considered optional. (Score:2, Insightful)
You can write programs in whatever subset you want;
but if you want to read someone else's programs you had better know it all. Which is why Perl is a write-only language.
Re:huh? (Score:2, Insightful)
By the way, there is at least one operator that this table predicts should exist: list concatenation. Well, except that you can just push the elements on to the end of the array, or use an idiom like @c=(@a, @b).
(Hmm...could comma be considered the list concatenation operator?)
unfortunately, you still have to READ others' Perl (Score:5, Insightful)
Unfortunately, you still have know these operators in order to READ Perl code written by other programmers.
Perl 5 is already conceptually too large to use [mathdogs.com]. Perl 6 just takes things completely over the top.
Mike
Re:Hmm.. (Score:3, Insightful)
The author probably built the chart in Illustrator, which outputs its PDF documents as v1.4 by default.
Re:Oh my sweet Jesus... (Score:2, Insightful)
No, OP was expounding on the virtues of Perl 5 vs. other existing languages: "Part of the reason why Perl is so good is that it makes development fast and easy.". Note that it did not say: "will make it fast and easy if and when it is ever released".
Re:Oh my sweet Jesus... (Score:3, Insightful)
I'm afraid coding and painting are not even CLOSE to being analogous. Having unnecessary operators and sloppy constructs does NOT make you more expressive in a coding sense. If that were the case, why can I do everything Perl can, and most likely more, in Java than in Perl when Perl has over 140 operators and Java has only 48? Expressiveness is in the algorithms and the approach to a problem, not how many or what type of operators I can have.
The problem a LOT of us have with Perl is that it is a very sloppy, unmaintainable language. You've got tons of people whipping up utter crap in Perl and then when they leave, programmers who use better languages are stuck wading through that garbage to re-write or maintain it. It's happened to me numerous times. I'm quite sick of Perl and the 5,000 ways people write the same scripts.
A couple million of us DO and will continue to.
Great. More work for me when your code falls apart and you can't add simple functionality because of fragile spaghetti code.
English IS as write-only as Perl can be. (Score:3, Insightful)
Using a relatively obscure subset of Perl is akin to using jargon in a paper. Noone but those "in the know" would fully understand what on earth you're on about. When you want to make yourself understandable to a wider audience it is at times (unfortunately) necessary to lower your vocabulary to the lowest common denominator. But with most programmers being less than adept at social interaction, this concept doesn't get applied to writing code very often.
Which brings us back to this periodic table. It's use is to create a common vocabulary. Chemists use the periodic table as a common framework, so people can understand eachother when they're talking about materials. Sodium (English) = Natrium(dutch) = Na. Most chemistry specialists would identify Na. Not many dutch chemists would easily identify "Sodium". If you had to make sure someone understood you, what would you use? I hope that this table gets wider recognition.
Re:Oh my sweet Jesus... (Score:3, Insightful)
While that sounds all nice and freedom-loving, that's exactly why any group larger than about 5 people usually gives up on Perl.
So there's 10 ways to do something. Okay, great, you only need to use one of them to write the code. But it's not the same way I used, and neither of those are the same way as the guy over here used, and the sourceforge[t].net code we just downloaded uses a fourth way, and the new hire wants to use a fifth because "it's the Perl Way."
So now all of use have to know all 10 ways of doing the same damn thing, and all the minor ways in which they differ. Just to read and maintain it, not to write anything new.
"More than one way" is fine. Anarchy is not.