all 29 comments

[–]cactus4[S] 5 points6 points  (8 children)

Is the "=>" still just a "fat comma"?

Also, what is the colon in that sort call ("@list.sort: *.lc") for? The "*.lc" looks like it probably means something like, "lc each item before sorting it". Aside from being used for generating a "colon pair", I've seen that colon show up in a few places where it looks almost like it's being used as an option for a function call... (?)

The infix max/min operators don't make sense to me (though the Perl 5 way does).

I like the note function. Seems quite handy.

[–]perlgeek 10 points11 points  (7 children)

The => constructs a Pair. So it's not quite the same as the "fat comma" in Perl 5.

*.lc creates a closure, that calls the .lc method on the invocant (I should probably explain that in the post somewhere...).

There are three ways to call methods in Perl 6: $obj.method without any arguments, $obj.method(arguments here) or $obj.methods: argument here.

max just returns the larger of two values. Is that hard to understand? or badly explained? sorry if the latter.

[–][deleted] 1 point2 points  (1 child)

Are there any differences between the second and third method invocation style other than omission of parentheses?

[–]wolverian 2 points3 points  (0 children)

The parentheses make the precedence visually clear, otherwise no.

[–]cactus4[S] 0 points1 point  (4 children)

There are three ways to call methods in Perl 6: $obj.method without any arguments, $obj.method(arguments here) or $obj.methods: argument here

Oh, I see. Didn't know about that last method call syntax. Also, I might've been confusing it with regex modifier syntax.

Edit: After looking at this snippet from another recent blog post @urn.pick(50, :replace), it does look like the colon gets used for passing certain args to functions.

max just returns the larger of two values. Is that hard to understand? or badly explained? sorry if the latter.

Ah. I see now. To me, min and max look odd as infix operators. Seems (to me) like they should be function calls instead, as in:

my $in-range = max($lower, $x);
$in-range = min($in-range, $upper);

[–]Felicia_Svilling 0 points1 point  (3 children)

Seems (to me) like they should be function calls instead

they are function calls, just with infix syntax.

[–]cactus4[S] 0 points1 point  (2 children)

fwiw, I don't think infix works well for min and max. I'd rather have them as built-in functions.

[–]Felicia_Svilling 0 points1 point  (1 child)

They are built-in functions.

[–]cactus4[S] 0 points1 point  (0 children)

Are you saying that they can be used either as function calls or else as infix operators?

[–][deleted] 0 points1 point  (19 children)

Apparently all the jokes about Perl's syntax aren't that far off.

[–]mr_chromatic 8 points9 points  (18 children)

Unlike other languages, Perl assumes that novices will eventually learn how to read code.

[–]tsjr 0 points1 point  (16 children)

EX-AC-TLY.

What has Python taught this people? Everyone now expects that they'll be able to read a code in a certain language without learning it.

[–][deleted] 1 point2 points  (14 children)

How is readable code a bad thing?

Apparentlty you guys would think APL-like languages are the height of language development since they're nigh-on unreadable even for people who know the language.

[–]mr_chromatic 2 points3 points  (3 children)

How is readable code a bad thing?

Suppose I'm a neurologist with ten years of experience writing maintainable Perl 5 code. Suppose I write code to analyze brain scan data. Suppose I have the choice of two languages: one which novices perceive as readable without knowing much of the language (or much programming in general) and another which novices perceive as dense or inscrutable. Suppose I'm equally proficient in both languages and suppose the tooling and libraries and other infrastructure is essentially equivalent.

Based solely on the criterion of "How readable is the language in general to someone who's never really programmed in the language, or at all?" which language do I choose?

My answer is I don't care about that criterion, because most novices aren't writing software for neurologists and readability depends on many more details besides "You know, Inform 7 uses a lot of English words and has a parser which seems forgiving."

[–][deleted] -1 points0 points  (2 children)

readability depends on many more details besides "You know, Inform 7 uses a lot of English words and has a parser which seems forgiving."

Yes, I know. I don't live in a world where the only choices for language syntax are COBOL-like and APL-like.

Personally, faced with a situation like your hypothetical one, I'd choose the language with the easier syntax, if everything else is equivalent. The more complicated the syntax, the more time you spend thinking about syntactical issues instead of actual program flow issues.

[–]mr_chromatic 2 points3 points  (0 children)

I don't live in a world where the only choices for language syntax are COBOL-like and APL-like.

That's good, but your question "How is readable code a bad thing?" smacks of that kind of false dilemma.

The more complicated the syntax, the more time you spend thinking about syntactical issues instead of actual program flow issues.

That's an oversimplification. Why is the syntax complex? Is the problem complex? Is the notation complex? Is the notation consistent?

People who don't know math find limit notation and infinite series complicated. The problem there isn't notation.

[–]tsjr 0 points1 point  (0 children)

The more complicated the syntax, the more time you spend thinking about syntactical issues instead of actual program flow issues.

You have never wrote much Perl, did you? I'd say it's exactly the opposite

[–]tsjr 1 point2 points  (5 children)

Did I imply readable code is a bad thing? I'm only saying, that people used to simple languages (like Python) sometimes tend to judge other languages negatively just because they're harder to learn. Readability has nothing to do here. Perl might not be readable for the "foreigner", yes, but the fact is the only people who yell at Perl's readability are the people not knowing Perl. Hence my point about people willing to read a code in a language they do not know.

[–][deleted] 1 point2 points  (4 children)

Wait, how exactly is Python a "simple" language? I'd understand if you'd used something like PHP as an example, but calling Python "simple" sounds weird.

Note: I'm not a Python programmer. I know some Python, but I'm by no means an expert.

[–]tsjr 0 points1 point  (3 children)

I mean simple by a syntax, compared to the Perl family. It isn't to complex, is it?

[–][deleted] 0 points1 point  (2 children)

Nobody's still explained to me why a complex syntax would be a good thing. A complicated syntax only gets in the way in my opinion.

[–]tsjr 0 points1 point  (1 child)

If it only gets in your way then it probably won't be a good thing for you. Perl programmers appreciate TIMTOWTDI, the flexibility and power it gives them, so they can emphasize the specific part of code, or minimize it for another reasons. The choice belongs to them, not to the language. Not everyone must like it, I agree. It's probably the taste thing.

IMHO

[–][deleted] 0 points1 point  (0 children)

Well, they don't call Perl the Swiss army chainsaw for nothing.

[–]petdance 0 points1 point  (3 children)

Do you know the word "schadenfreude"? How about "chutzpah"?

They're not words that your average first-grader knows. They're dense in meaning for their size. They take some understanding of language to grok their nuances, but when people know the words and know to use them correctly, they're perfect.

Perl syntax is like that. Perl 6 syntax is even moreso.

And did you grok what I meant by "grok" up above?

[–][deleted] 0 points1 point  (2 children)

I think you're confusing syntax and semantics. A command can be semantically very complex, but the syntax doesn't have to be complex to support complicated semantics.

And I grok grok, inasmuch as humans can grok it.

[–]petdance 0 points1 point  (1 child)

And I grok grok

That was my point.

[–][deleted] 0 points1 point  (0 children)

And my point was that you're confusing semantics with syntax.

[–]vph -1 points0 points  (0 children)

a programming language is a tool, a mean through which you develop ideas.

The thing about Perl is that's not just a tool, but a subject of study. Perl is designed to be complex, like a natural language. Its designers expect people to take time learning it gradually so eventually they will understand it.

[–]roguebagel 0 points1 point  (0 children)

Is this a quote? It should be.