News for hackers. Stuff that matters.
Re:Perl 6 hands-on tutorial – A small introduction to a big ... by logicallee on Thursday September 03, 2015 @11:39PM (#10168715)
Let me get this straight - the first example in the tutorial is code that you shouldn't write. Got it.

By the way guys, string concatenation isn't . or + or a comma or something. It's a tilde: ~

'a' ~ 'b' to get 'ab'.

Because it looks like a "piece of string" ... that ties ... strings together, apparently.

Re:Perl 6 hands-on tutorial – A small introduction to a big ... by kbenson on Friday September 04, 2015 @12:04AM (#10168764)
> Let me get this straight - the first example in the tutorial is code that you shouldn't write. Got it.

If you read a little farther you might have seen this: Note: .VAR and .WHAT are code smells. They’re useful to understand the language and debug, but testing against what they return is nearly always the wrong approach.

> Because it looks like a "piece of string" ... that ties ... strings together, apparently.

You're mistaking a mnemonic for the reasoning. The reasoning is most likely because using a period for string concatenation is likely to cause problems when it's also used for method calls and strings can have methods, and when methods can be quotes. E.g. "foo"."chars"(), which might be useful with string interpolation.

As for why it's not +, that's covered as well. Perl takes the stance that operators should be different for different operation types. What does foo + bar mean in python? You need to know the types of foo and bar to know that. In Perl 5 and Perl 6, you know whether you are adding numeric types or concatenating (not adding) strings.

It's easy to assume no thought went into the development[1], but it's been very well thought out and been baking for a very long time. They spent that time actually testing their ideas, and making changes when reality didn't match expectations.

1: for that matter, a lot of people think that about Perl 5, which is untrue, it just has different design goals than many languages

Re:Perl 6 hands-on tutorial – A small introduction to a big ... by singingfish on Friday September 04, 2015 @08:49AM (#10170046)
I have two trite one-liners about perl(5) in comparison and to other languages these days.

1. Python helps you think more like the computer does. Perl helps the computer think more like you.

2. Modern Perl is C# for hippies.

Re:Perl 6 hands-on tutorial – A small introduction to a big ... by raiph on Friday September 04, 2015 @01:24PM (#10171759)
Re:Perl 6 hands-on tutorial – A small introduction to a big ... by Ulti on Friday September 04, 2015 @07:07AM (#10169704)
Yeah because we can't possibly have languages which diverge in syntax... I mean I don't use any languages every day where the concat operator is || for example which is short circuit OR for most people. cough PgSQL cough

JavaScript overloading + to mean addition and string concatenation was the worst decision ever given the use case of JS. 1 + '1' * 1 is not the same as '1' + 1 * 1 good job. That definitely wont be evil once the values are in a more complex equation with variables coming from some server side JSON string... at all. Definitely wont lead to any unusual bugs when something like the following happens 1 + '000001'. You might not notice 2 being 12 for a while but your customer will likely notice 2 suddenly becoming 1000001.

At least '~' joins two different string together when writing. Makes a lot more sense than '+' to me ~ Ulti 2015

Re:Perl 6 hands-on tutorial – A small introduction to a big ... by sparky_z on Thursday September 03, 2015 @11:56PM (#10168749)
That's because . is a method call, + is addition, and comma is a list separator. Which of those would you give up? So yes, the ~ is a little unique to Perl6, but at least they were thoughtful enough to pick something with more than one easy mnemonic.

I guarantee you, most people new to the language would be much more put-off by keeping perl5's -> for method calls. Perl lost that battle, it's over. They're making the best of it.

Also, any language with a self-reflective object system is going to show that off to beginners to help them explore, even if it wouldn't be used in production code much. That's like complaining about a language tutorial showing off the REPL to start out, even though you don't use it in production code.

Re:Perl 6 hands-on tutorial – A small introduction to a big ... by SamReidHughes on Thursday September 03, 2015 @11:52PM (#10168740)
Getting the type of a value is useful to beginners and belongs in a tutorial. The one time I tried Perl 6 was a few weeks ago, and it took a while to find out how to do this exact thing.
Re:Perl 6 hands-on tutorial – A small introduction to a big ... by tomjakubowski on Saturday September 05, 2015 @11:50PM (#10176778)
But Perl is unityped so I don't think it'd be useful there. :V
Re:Perl 6 hands-on tutorial – A small introduction to a big ... by raiph on Monday September 07, 2015 @03:33AM (#10180450)
That's gotta be a joke but I'm missing it -- can you spare a hint?
Re:Perl 6 hands-on tutorial – A small introduction to a big ... by tomjakubowski on Tuesday September 08, 2015 @01:51PM (#10187206)
Re:Perl 6 hands-on tutorial – A small introduction to a big ... by raiph on Tuesday September 08, 2015 @09:36PM (#10189191)
The article you've linked is about unityped languages. Perl 6 is not unityped.

To quote the conclusion of the article you linked:

> Why should you care? Because, I argue, that a fully expressive language is one that supports the delicate interplay between static and dynamic techniques. Languages that force only one perspective on you ... hobble you; languages that admit both modes of reasoning enable you and liberate you from the tyranny of a single type.

It would seem he ought to love Perl 6.

"Getting beyond static vs dynamic" may be of interest:

* HN discussion https://news.ycombinator.com/item?id=9089259

* Youtube: https://www.youtube.com/watch?v=id4pDstMu1s

Re:Perl 6 hands-on tutorial – A small introduction to a big ... by enqk on Friday September 04, 2015 @01:55AM (#10168998)
the use of + for string concatenation is not exactly compelling either, since string concatenation, unlike addition, is not commutative