Twin Peaks (YAML Walk with Me)

I've just returned from a 2 week (and 2 Summit!) trip to Europe, specifically Berlin and Lyon. A couple months ago I was invited to attend the Perl Toolchain Summit 2017 in Lyon. Whenever I go to the EU I like to drop by Berlin to visit some friends.

One of my friends is Tina Müller, who works with me throughout the year on various open source things. We met 2 years ago at the Perl toolchain event in Berlin, that Tina helped organize. For the past 4 moths we've been concentrating on all of YAML as a lanuguage.

Specifically we've been making:

  • The canonical YAML Test Suite for all YAML projects
  • A multi-language YAML Editor for seeing how a given YAML text works in several language implementations at once
  • The YAML Testing Matrix website for seeing how all the YAMLs work at a glance

I decided that we should have the first ever YAML Summit in Berlin along with our fabulous collaborator (and NimYAML author) from Stuttgart, Felix Krause.

Tina has written all about the YAML Summit. Check it out. Spoiler: we've started to create YAML 1.3 (the first new YAML spec in 8 years).

Next Stop, Lyon

Tina got invited to the Perl Toolchain summit as a last minute replacement for Chad Granum who couldn't make it for some personal reasons. Needless to say, I was psyched. Tina and I got to work together in person on YAML for almost 2 weeks; first on the overall YAML language itself, and then on the specific Perl/YAML ecosystem.

Perl was the very first language to have YAML, but is also one of the languages where YAML needs the most attention.

YAML.pm is Old (and I mean ::Old)

The first YAML module in Perl (and the world) is YAML.pm. It's the first (and worst) module that Perl programmers try when they want to use YAML. Since it is 16+ years old, a lot of code depends on it.

I really wanted YAML.pm to be the module that had the latest/greatest best-of-breed YAML that Perl had to offer, while breaking as little existing code as possible.

That might not seem possible (unless your name is Ingy). We came up with this plan. In a nutshell, we moved all the old YAML.pm code to YAML::Old and made use YAML; invoke that code. So nothing changes...

...unless you use YAML -new! That's not really the new syntax (but it sounded cool). The new usage looks like this:

use YAML 'yaml';

my $data = yaml->load($yaml);
$yaml = yaml->dump($data);

That's the basic usage. What does it do different? Not yet much, but it gives us the ability to make the YAML I've always wanted:

  • Single entry point to all Perl YAML backend implementations
    • Simple sugar usage like above
    • Can also use 100% plain old OO usage
  • New capabilities
    • Keep/set key orders
    • Choose exact dumper styles for every node
    • Preserve or add comments to write
  • Highly configurable
    • Lexical options and configs
    • No more global variables for config
  • Access to a YAML::DOM
  • Streaming YAML usage
  • Much more

So far we have gotten (or at least very close) the new YAML.pm working with, libyaml, Tina's new pure Perl YAML::PP parser, and Ingy's new Pegex based YAML::Pegex.

Tina and I have released YAML::Old to CPAN, and put out a developer release of the new YAML.pm. We've also made a dev release of YAML::Perl where much of the new common API code will go.

...and a 6 pack of YAML

At some point during the summit, Tina and I went out in search of some food and ran into Tony O'Dell, a Perl 6 hacker. We told him what we were up to, and a few hours (and whiskey drinks) later Tony had made a binding of libyaml to Perl 6.

In some other universe, at about the same time, Curt Tilmes did the exact same thing, but with a Dumper too. Long story short, Curt gave us his code to carry forth. Tina and I will be making this code stay perfectly in sync with our Perl 5 efforts.

A Shout Out and I'm Out

This was a really great month for me and for YAML. None of it would have happened at all without the generous support of the 2017 Perl Toolchain Summit Sponsors. Please support them like they supported us:

Booking.com, ActiveState, cPanel, FastMail, MaxMind, Perl Careers, MongoDB, SureVoIP, Campus Explorer, Bytemark, CAPSiDE, Charlie Gonzalez, Elastic, OpusVL, Perl Services, Procura, XS4ALL, Oetiker+Partner.

Finally, big hugs to all the great people who came to Lyon, and especially the organizers: Philippe, Laurent, Neil and Wendy!

Thank You and see you in TheFuture™, Ingy döt Net

2 Comments

Super prospects for YAML.
I'm especially interested in the streaming part.

I've been a bit concerned lately that YAML in Perl hasn't been compatible with RAML, an API design language.

Thank you, Ingy.

Super prospects for YAML.
I'm especially interested in the streaming part.

I've been a bit concerned lately that YAML in Perl hasn't been compatible with RAML, an API design language.

Thank you, Ingy.

Leave a comment

About Ingy döt Net

user-pic I am an Acmeist Hacker. I program in many languages to meet many people. Perl people are my favorite people. Currently I am working as a Distinguished Technologist for Hewlett Packard Enterprise; developing the future of cloud solutions.