Hacker News new | ask | show | jobs
by Ulti 3510 days ago
A) It's released with a frozen spec and a large test suite for compliance (https://github.com/perl6/roast), with a compiler available that supports a module ecosystem with over 700 modules (http://modules.perl6.org). What's a complete state in your mind? If not this.

B) All of the below is core language, not a use or import anywhere required. Error reporting is also handled for you without autodie and friends.

  Reading from a file:

  #Efficiently line by line for STDIN
  for lines() -> $line {
      $line.say;
  }

  #Get everything in RAM right now
  my $string = "filename".IO.slurp;

  #Lazy list will do IO as you request into the list
  my @lines = "filename".IO.lines;

  #Listing of directories if the path is a directory
  my @directories = "coolstuff".IO.dir if "coolstuff".IO.d;

  Playing with dates:

  #Get a DateTime for right now
  my $date = DateTime.now;

  #Does what it says on the tin
  say "Yippee" if $date.later(:5years).is-leap-year;
3 comments

A) Complete is when the compiler(s) actually implement all of the spec, for starters.

B) Nice examples. Well done. But it's not about whether you can do the simple things. It's more about the impression of the community and where its interest and focus lies.

I'd rather use a language where the mundane day-to-day stuff is the most important consideration. My impression of Perl6, however unfair that may be, is that the day-to-day functionality is the boring necessary evil that must be in there somewhere, but the true focus is the amazing stuff you can do with a language that's simultaneously trying to be a better Perl, and a better Lisp, and a better Erlang, and a better Haskell.

In my mind, Perl6 is a huge lumbering beast that tries to do absolutely everything. I'm sure if I ever feel the need to write a lazy asynchronous parser script, it'll be the first language that leaps to mind. In the meantime, I don't have the time nor the interest to bother.

* A) Complete is when the compiler(s) actually implement all of the spec, for starters.*

The spec was frozen last Christmas, with a corresponding compiler release.

As a beginner who never used Perl5, I found my first bug (missing method https://rt.perl.org/Public/Bug/Display.html?id=128903) within 24 hours. It does seem like there are some relatively raw things left around.

That said, it seems like a really interesting language.

> #Does what it says on the tin > say "Yippee" if $date.later(:5years).is-leap-year;

Is that a Georgian or Benghali or Indian or Buddist Era Thai leap year?

Actually are we talking the Georgian calendar - or the Julian, Revised Julian, Coptic, Ethiopian, Chinese, Hebrew, Islamic, Hindu, Bahai, or Solar Hejri calendar ?

I have to admit the documentation for perl6 is absolutely excellent as the very first English prose line on the very first google result answers your very reasonable first question about a date class.

https://docs.perl6.org/type/Date

"A Date is an immutable object identifying a day in the Gregorian calendar."

I like a language that's not surprising, with easy to find answers. My experience with Perl over the decades is everything about it meets expectations to a spooky extent, which is also nice. The surprise factor for Perl is very low.

It seems to define excellence in programming language documentation. Is there anything better out there?

From https://docs.perl6.org/type/Date:

"A Date is an immutable object identifying a day in the Gregorian calendar."

(It's proleptic.)

The days used in DateTime, which is compatible with the Date class, also identify days in the Gregorian calendar.

(DateTime adopts RFC 3339[1].)

The `is-leap-year` methods for both classes refer to the Gregorian calendar year.

For a civil calendar independent date, use the `daycount` method to return a Modified Julian Day[2].

The `Dateish` role[3] abstracts from any particular civil calendar.

I'm not aware of any routines, built in or in existing Perl 6 modules, for conversion to other calendars.

[1] https://www.ietf.org/rfc/rfc3339.txt

[2] http://tycho.usno.navy.mil/mjd.html

[3] https://docs.perl6.org/type/Dateish