Hacker News new | comments | ask | show | jobs | submit login

As someone who actually glares at Perl quite frequently can I gently request you take that slight back. Or at least qualify it to be "perl regex". Unless youve used Perl 6 (a different language) and not found it readable youd do well to say Perl 5 too. Or perhaps you've never used either language but use it as a defacto meme to make a point?

The bigger argument is not readability but where the abstraction lies. From the examples I cant see much sugar beyond what an ORM often provides.

I write Perl5 every work day and find Perl6 less readable due to double symbols and increased symbol madness. Like the new ternary operator, which is probably much more visible but looks just crazy. Or private/public variables. In some respects it's worse than Perl5, in others it's exponentially more powerful. It's like giving you the equivalent of a swiss army knife for each and every tool inside your toolbox.


That said, I am more tempted to try Ruby, Crystal and Dlang for a new project, rather than Perl6. The latter looks like it was designed by a mad scientist on LSD.

> less readable due to double symbols

Double symbols? What do you mean by that?

> increased symbol madness

Could you elaborate what you mean by that?

> It's like giving you the equivalent of a swiss army knife for each and every tool inside your toolbox.

Please note that the link you've given, is about being able to restrict calling a subroutine by making sure that the first 2 parameters are of the same type (regardless of which type). Generally one knows which types to expect. And even so, typechecking is an optional thing in Perl 6 (hence the term "gradual typechecking".

> The latter looks like it was designed by a mad scientist on LSD.

I think that's uncalled for. But that's your opinion. The same mad scientist who gave you Perl 5, by that reasoning, by the way.

I mean $.x and $!x or such craziness:

     submethod BUILD(:&!callback, :@!dependencies) { }

or the quite useful Z=> operator.

    my %hash = @keys Z=> @values;
or the Bat range operators:

    (1^..^5).list; # (2 3 4)
I know. It was meant as a Perl6 example chosen at random. It looks as something taken out of the Discworld novels:


You don't understand what the following means

  1 ^..^ 5
It means a Range of values from 1 to 5 excluding 1 and 5.

  1         ~~  1^..^5; # False
  5         ~~  1^..^5; # False
  1.000001  ~~  1^..^5; # True
  4.999999  ~~  1^..^5; # True
It is short for

  Range.new( 1, 5, excludes-min => True, excludes-max => True )
One of the benefits if you want to get the first 10 items from an array is that you can use the numbers 0 and 10

  @a[ 0..^10 ]
It also means you don't have to do so many +1 or -1 when generating a sequence

  $n+1  ..  $m-1
  $n   ^..^ $m
We don't have to declare ranges with a number past the end like Python


… but we can if it increases clarity


Since we don't use prefix ^ for anything else, we have it as shorthand for the above


Perl 6 doesn't have a Z=> operator. It has a Z meta-operator and a => operator.

  my %hash = @keys Z[=>] @values;
short for

  my %hash = zip( @keys, @values ).map: -> ( $key, $value ) { Pair.new( $key, $value }
I would like to know which of those you can scan over and be sure it is correct without much thought.

We also don't have a += operator, instead = is also a meta-operator

  $i  +=  2;
  $i [+]= 2; # more explicit, but identical
Which means that if you modify an existing infix operator or add a new one, you get something like += for free.

  sub infix:< +++ > ( $l, $r ) { $l + 1 + $r }

  $i +++= 1;
Note that since operators are so simple, we don't have to re-use operators for completely different operations. Just add a new one.


Sigils and Twigils allow us to know the scope of a variable and that it is a variable, at a glance.

  sub value () { 10 }

  submethod BUILD ( $value ) {
    $!value = $value || value
  #   ^          ^        ^
  #   |          |         \_ not a variable
  #   |           \__________ subroutine scoped
  #    \_____________________ class scoped
There are also compile time "variables"

  say $?LINE;
and dynamic variables (thread local)

  say %*ENV;
This makes it so that when you modify a dynamic variable, it is immediately obvious that is what you are doing.

  sub foo () {
    $*foo = 42;

  my $*foo = 0;
  say $*foo; # 42

  sub bar () {
    $bar = 42;  # compile-time error

  my $bar = 0;
  say $bar;

>can I gently request you take that slight back. Or at least qualify it to be "perl regex".

Regex has the same complexity in any language, that can't be a valid reason to denigrate Perl. My biggest issue with Perl is that functions don't even have proper parameters and you need somewhat cryptic syntax to work with arrays, scalars and dictionaries.

Define "proper parameters". Perl subroutines are delightfully flexible in that regard compared to most other languages, and they also happen to be closer to your machine's reality (x86 doesn't care about what's in your stack when you JMP). With the Perl approach, you have the tools to implement multiple dispatch, variable numbers of arguments, etc. rather easily and elegantly. Yeah, it looks weird from the outside, but once you're used to it you start to want it in other languages.

That's one example of what makes Perl a great teaching tool for general programming: it doesn't hide the mechanics of function/method calls behind the language, but instead shows it off to you and encourages you to explore and experiment.

I don't want a great teaching tool, I can use ASM for that. I want something that's easy to read and maintain.

I think Perl 6 got it right, but a little too late.

People keep saying that Perl 6 is too late, but they don't say that about other new languages.

I mean nobody says the same about Julia, which has been in development for the better part of a decade.

The only way it could be too late is if it doesn't do anything better than a single other language. By that I mean if there is a language that does everything that Perl 6 does, and does it just as well.

Even if all it does is bring a collection of useful features that haven't already been collected together into a single language, then it isn't too late.

It could also create a new design of an existing feature that goes on to influence the design in future languages. That would also make it so that it isn't too late. (I think that in the future we may be able say that about Perl 6 grammars.)

I think the real reason people keep saying that about Perl 6 is that they want it to be true. We can only really make that determination years from now when we have perspective.

It does have subroutine signatures since 5.20. And there's autobox.

Ok, I didn't know that, haven't used Perl in a long time. But I don't think any of my Perl programming colleagues have heard of it or like using it. I still think their code is harder to read because of this ingrained bad practice.

Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact