What parser do birds use?

In my new blog post , I compare parsing, as practiced by birds and by computer programmers.

Running mixed Perl 5 and Perl 6 tests.

Those two tricks are especially useful when refactoring big codebase from Perl 5 to Perl 6. Such process may take weeks or even a months, and you will encounter two cases:



1. Some features are still in Perl 5, some are fully refactored to Perl 6. So you want to
run separate Perl 5 and Perl 6 test files on single prove command. Prove is not very smart. It does not peek into test files to use correct interpreter (Perl 5 is assumed) and it does not recognize ".t6" extension some people use. But there is a solution. First create your test files.

t/perl5.t

Rewriting Gumbo Binding - A GPTrixie 'demo'

 originally wanted to make a small history about GPTrixie, but it will probably be boring and you can probably look at the commit history to have an idea of how it evolved. Instead, we will see how to rewrite my Gumbo binding using GPTrixie.


trixie_cm20x20.pngWhat is Gumbo?

Gumbo is a standalone C99 library that parse HTML5. It's heavily tested and it's project endorsed by google. Gumbo on github


trixie_cm20x20.pngWhat is GPTrixie?

GPTrixie is a tool that extracts definitions from a C header to transform them into their perl6 NativeCall counterpart. This definition is partially false since it actually extract the C definition from a XML file produced by GCCXML. C parsing is something a compiler like clang or GCC are more likely to do a better job than me with my poor compiler knowledge. Anyways you can find it at GPTrixie on github or just install it with panda install App::GPTrixie

cpanparty updates

Hi!

This is cpanparty current list:

  • Kelp 0.9071
  • Dancer2 0.166001
  • Mojolicious::Plugin::Vparam 1.4
  • Dancer2::Plugin::Ajax 0.200001
  • Dancer2::Plugin::Res 0.03
  • Plack::Middleware::StackTrace::LinkedSource 0.12
  • Raisin 0.63
  • Dancer2::Plugin::Feed 1.160550
  • DateTime 1.25
  • Test2::Suite 0.000022
  • Mojolicious 6.55
  • Dancer2 0.166001
  • Dancer2::Plugin::Auth::Extensible 0.502

Other improvements:

  • colorful html reports

-- Regards

Alexey

YAML patches done

I've finished most of the needed YAML work, esp. for YAML::XS.

libyaml upstream has now a patch with the new options NonStrict and IndentlessMap https://github.com/yaml/libyaml/pull/8

YAML::XS in https://github.com/ingydotnet/yaml-libyaml-pm/pull/43

YAML::XS writes now proper YAML which can be read with YAML.pm, and passes the CPAN::Meta validation tests. See https://github.com/Perl-Toolchain-Gang/CPAN-Meta/pull/107

For CPAN::Meta I've added validation tests for all existing YAML loaders, so you can see what's going on, and which version is conforming or fails. YAML::XS, YAML::Tiny, CPAN::Meta::YAML, YAML::Syck do pass now, YAML fails.

I have also patches for Parse::CPAN::META and CPAN-Meta-YAML to use the new versions, but only in cperl, no PR yet.

I've also started merging libsyck from upstream into YAML::Syck, which came up with some horrible private extensions, and made them mergable to upstream. But this work is still ongoing at https://github.com/rurban/syck/commits/0.71 and https://github.com/rurban/YAML-Syck/commits/merge-upstream.

TODO (optional)

  • YAML.pm would need a patch to read old YAML::XS with $IndentlessMap=1.
  • YAML::Syck
  • syck

Tabletop.Events at MadMongers

I'm going to go over a bunch of the technical challenges that I faced building the Tabletop.Events, as well as some that are still yet to come. If you want to see what it takes to build a massive new app from scratch, talk about how to build a business around an app, or just learn about some novel solutions to hard problems, then join us at MadMongers on Tuesday, March 8th at 7pm.

Perl 5 Porters Mailing List Summary: March 1st-6th

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week. Enjoy!

A Date with CPAN, Part 7: In the Zone

[This is a post in my latest long-ass series.  You may want to begin at the beginning.  I do not promise that the next post in the series will be next week.  Just that I will eventually finish it, someday.  Unless I get hit by a bus.

IMPORTANT NOTE!  When I provide you links to code on GitHub, I’m giving you links to particular commits.  This allows me to show you the code as it was at the time the blog post was written and insures that the code references will make sense in the context of this post.  Just be aware that the latest version of the code may be very different.]


Last time I said that I had three things left to do for Date::Easy before it was ready for CPAN:

  • Add a Time::ParseDate fallback to the ::Datetime class.
  • Figure out how to handle the UTC version of datetimes.
  • (Hopefully) fill out the POD.

This time, I’m reminded of the wise words of the great sage Meatloaf: two outta three ain’t bad.

Perl curio: For loops and statement modifiers

Perl has a "statement modifier" form of most control structures:

EXPR if EXPR;
EXPR unless EXPR;
EXPR while EXPR;
EXPR until EXPR;
EXPR for EXPR;

Perl also has a C-style for loop:

for (INIT; COND; STEP) {
    ...
}

The curious part: COND is a normal expression, but STEP allows statement modifiers. That is, you can write:

for (my $i = 0; $i < 10; $i++ if rand() < 0.5) {
    print "$i\n";
}

MacPorts openssl versus Perl

This is only of interest to Mac users who link their Perl against MacPorts code, but if you are such a person, you may find this useful.

This morning I found that Perl code that used LWP::Protocol::https was failing, but only when run by the test harness.

After some flailing around I managed to track this to the fact that I had just updated MacPorts, and taken openssl from 1.0.2f_0 to 1.0.2g_0. I still do not know the precise cause of the failure, but it was exposed by the fact that the test harness (whether ExtUtils::MakeMaker or Module::Build) set PERL_DL_NONLAZY=1.

Downgrading to the old openssl did not fix the problem of course, but made the symptoms go away. The short version of the procedure is

$ sudo port activate openssl @1.0.2f_0

For details on downgrading a port, see https://trac.macports.org/wiki/howto/InstallingOlderPort

More on YAML, syck looks much better

In my last YAML post I said libsyck is not maintained anymore. I had a look, and this is wrong. Even if _why does not work on it anymore, (he came back btw recently), it is maintained and made some progress in libsyck, which is not reflected in the YAML::Syck perl part.

It is a mess, I admit, but easier fixable than the YAML::XS mess. So I took libsyck upstream, which is at 0.70, and merged it with our changes which are at 0.61. Our perl-specific changes are a complete mess, so I cleaned that up to be acceptable upstream into a new 0.71.

merge back various changes from upstream (my own WIP version 0.71)

Not so new shiny things: LWP::Protocol::PSGI

Too long/didn't read: Don't use Test::WWW::Mechanize::PSGI or similar, use LWP::Protocol::PSGI. I wish I'd found out about this module when it was first released in 2011 rather than in 2015. Which is why this article is here. LWP::Protocol::PSGI is great work and needs to be more widely known.

Since we moved away from monolithic web applications deeply embedded into the web server via the web framework movement and PSGI, now around a decade ago, a common way of testing things has been with modules like Catalyst::Test, Test::WWW::Mechanize::PSGI, Dancer2::Test and similar. These work by mocking the http request and response layers, with the mocked layers talking to an object or a subroutine reference rather than a web server. Which is fine, except, say you want to test both against your application code and your web server using the same test suite. You end up having to do fairly nasty things to decide if you are dealing with a mocked http request/response layer talking to a coderef, or a real one talking to a web server.

Fortunately LWP::Protocol::PSGI eliminates this entire problem.

Perl curio: Dereferencing blocks

We're all familiar with references and Use Rule 1:

You can always use an array reference, in curly braces, in place of the name of an array.

This leads to code like ${$foo} (dereference a scalar reference) or @{$bar{baz}} (dereference an array reference stored in a hash).

The curious part: The curly braces actually form a block, i.e. you can put multiple statements in there (just like do BLOCK), as long as the last one returns a reference:

% perl -E 'use strict; use warnings; ${say "hi"; \$_} = 42; say $_'
hi
42

This block also gets its own scope:

% perl -E 'use strict; use warnings; ${my $x = "hi"; say $x; \$x} = 42; say $x'
Global symbol "$x" requires explicit package name at -e line 1.
Execution of -e aborted due to compilation errors.

$x isn't visible outside the ${ ... } block it was declared in.

% perl -E 'use strict; use warnings; ${my $x = "hi"; say $x; \$x} = 42;'
hi

Alien::Base and Module::Build

TL;DR - if you have an Alien::Base based Alien module, please update configure_requires so that it depends on Alien::Base::ModuleBuild instead of Alien::Base, and (this part is key) make a release.

This is technically more correct, and it will also future proof your module in the event that Alien::Base::ModuleBuild gets spun off from the rest of Alien::Base. There are a number of motivations making such a move. Please join us on GitHub or the #native IRC channel if are interested in working on the next generation of of Alien::Base.

On YAML and YAML::XS inconsistencies

Personally I'd prefer YAML over JSON for local config data anytime. Even if JSON is secure by default, and YAML is insecure. YAML is readable and writable. It's better than .ini, .json and .xml.

But Houston we have a problem. For a long time. I'll fix it.

We have the unique advantage that the spec author and maintainer is from the perl world, Ingy, and maintains the two standard libraries YAML, the PP (pure perl) variant, and YAML::XS, the fast XS variant, based on LibYAML.

This would be an advantage if those two libraries would agree on their interpretation and implementation of the specs. They do not.

Historically the YAML library is used as the default reader for CPAN .yml preferences and a fork of YAML::Tiny, CPAN::Meta::YAML which is in core is used to read and write the package META.yml files.

continuous integration using sparrow tool chain

continuous integration using sparrow tool chain

Sparrow is a tool to automate testing infrastructure. Automated testing is essential part of continuous integration processes as it provides fast feedback on cases when something goes wrong.

Consider simple example of how sparrow could be used to build up some basic parts of your infrastructure.

web application development

We have a simple Dancer2 application we are going to deploy on development environment:

app.psgi

#!/usr/bin/env perl
use Dancer2;

get '/' => sub {
    "Hello World!"
};

dance;

Let's keep source code at git repository:

Perl 5 Porters Mailing List Summary: February 15th-29th

Hey everyone,

I apologize for skipping last week. Following is the p5p (Perl 5 Porters) mailing list summary for the past two weeks. Enjoy!

NYC Perl 6 Beginners Study Group Session 2

"The future is now thanks to science" - Clemont - Pokemon Trainer and Science Aficionado.

If you are in or around NYC next week then be part of the future. NY.pm has organized a Perl 6 Beginners Study Group and next week Saturday March 05 2016 is our second group session. Meeting details from official announcement in NY.pm mailing list:

``````
The second meeting of our New York City Perl 6 study group will be held:

Saturday, March 5, 1:00 - 3:00 pm
d.b.a.
41 First Ave
Manhattan
between East 2 and East 3 Streets
http://tinyurl.com/gphhdja

Subway: F-train to Second Ave; exit at First Ave (east) end of station

R.S.V.P: http://www.meetup.com/The-New-York-Perl-Meetup-Group/events/228790319/

Preparation for Meeting:

1. Prepare to speak for 60 seconds on one Perl 6 statement or concept you've explored since Session One. A web link to your example will be helpful.

From Regular Expressions to Grammars (in Perl 6) Part IV

The fourth and final installment of the Perl 6 regular expression -> grammars tutorial has hit the blog: From Regular Expressions to Grammars, Part 4

cpanparty first members

Below is the list of cpanparty first members

  • Kelp 0.9071
  • Dancer2 0.166001
  • Mojolicious::Plugin::Vparam 1.4
  • Dancer2::Plugin::Ajax 0.200001
  • Dancer2::Plugin::Res 0.03
  • Plack::Middleware::StackTrace::LinkedSource 0.12
  • Raisin 0.63

Regards

-- Alexey

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.