images | feed | twitter

pullingshots

The Perl and Raku Conference 2024

The Sphere

I attended The Perl and Raku Conference in Las Vegas, NV, which took place June 25-28, 2024. It was HOT outside (over 40C/110F) but we stayed cool inside at the Alexis Park Resort.

Curtis Poe (Ovid) got things started with the keynote encouraging us to Party Like It's 19100 - 1, and reminded us that Vegas is lexically scoped! (what happens in Vegas, stays in Vegas). More importantly he reminded us that Perl is about people, not just the technology, one that has been meeting all over the world since 1999, with this being the 25th anniversary of the The Perl Conference (aka YAPC::NA).

Ovid Keynote

Meeting in person with people who you interact with primarily through digital channels, code commits, and MetaCPAN documentation really highlighted the importance of the community. On the first day, I messed up timezones, showed up an hour before registration opened, and witnessed the conference organizers and core members arrive and greet each other with hugs. And I also enjoyed visiting with one of the very welcoming TPRF board members.

Many of the speakers and attendees put a "Hallway++" sticker on their badge which simply meant "talk to me, I'm here to meet and get to know people". At breakfast one morning, I had the privelege of sitting with Jason Crome, the core maintainer of Dancer, a framework that I have used extensively. It was amazing to be able to pick the brain of one of the people who has intimate knowledge of the software.

Dancing with Cromedome

The Perl community is large and diverse, which was reflected in hearing about the Science Perl Committee and the all Perl Koha Library Software in use at over 4,000 libraries and with its own annual conference. It was cool to hear about the Glue Photo Project, making algorithmic music, and gaming with the TinyNES.

Every community will experience conflict and this one is no different. The impact of Sawyer's resignation at TPRC 2023 could be felt at this conference, and in response the community is focused on making things better with a new standards of conduct.

It wouldn't be a conference in 2024 without AI. We had some Musings on Generative AI and an introduction to PerlGPT, A Code Llama LLM Fine-Tuned For Perl.

And there was of course a lot of talks about actual Perl code!

One of the things I enjoy about attending conferences is discovering things that I wasn't looking for. Chad Granum gave a lightning talk on goto::file and I noticed the use of line directives which can be extremely helpful in debugging eval'd code. For example, let's say you are eval'ing subs into a hashref and then calling them like so:

my $sub1 = "sub {\n  print 'foo';\n  print 'bar';\n print 'baz';\n}";
my $sub2 = "sub {\n  print 'foo';\n  print 'bar';\n warn 'baz';\n}";
my $Sub = {
  sub1 => eval $sub1,
  sub2 => eval $sub2,
};
$Sub->{sub1}->();
$Sub->{sub2}->();

Any warn or die output will give you a line number, but no context as to which sub it originated from:

baz at (eval 2) line 4.

Making use of a line directive when eval'ing the subs like this:

my $sub1 = "sub {\n  print 'foo';\n  print 'bar';\n print 'baz';\n}";
my $sub2 = "sub {\n  print 'foo';\n  print 'bar';\n warn 'baz';\n}";
my $Sub = {
  sub1 => eval qq(#line 1 "sub1"\n$sub1),
  sub2 => eval qq(#line 1 "sub2"\n$sub2),
};
$Sub->{sub1}->();
$Sub->{sub2}->();

Will now result in a much more friendly:

baz at sub2 line 4.

And in true open source fashion, this has been turned into a pull request for Interchange!

I always enjoy hearing from others in the community about CPAN modules that are in their toolbox. I learned about DBIx::QuickDB, which you can use to spin up a database server on the fly, especially useful for disconnecting your tests from needing a running database server, and also enables running concurrent tests which require a database server that would otherwise conflict. Combine this with a DBIx::Class schema and DBIx::Class::Fixtures and you have a very nice way to run some tests against fixed data:

use DBIx::QuickDB PSQL_DB  => {driver => 'PostgreSQL'};
my $dbh = PSQL_DB->connect;
$schema = Some::Schema->connect( sub { $dbh }, { on_connect_do => ["..."] } );
$schema->deploy();
my $fixtures = DBIx::Class::Fixtures->new({ config_dir => '...' });
$fixtures->populate({ no_deploy => 1, schema => $schema, directory => '...' });

ok($schema->resultset('Foo')->count >= 1, 'database populated');

Damian Conway gave a keynote on The Once and Future Perl, showing how far Perl has come as a language and how it's rich history can be leveraged into the future - "if you can envisage what you could have done better in the past, then you can probably think of ways to make the future brighter!".

He showed off his new Multi::Dispatch module which you can use now to write incredibly extensible (and beautiful) code. Here it is in action with a simple Data::Dumper clone in 5 lines of code:

use v5.26;
use Multi::Dispatch;

multi dd :before :where(VOID) (@data)   { say &next::variant }
multi dd ($k, $v)                       { dd($k) . ' => ' . dd($v) }
multi dd ($data :where(ARRAY))          { '[' . join(', ', map {dd($_)}                 @$data) . ']' }
multi dd ($data :where(HASH))           { '{' . join(', ', map {dd($_, $data->{$_})} keys %$data) . '}' }
multi dd ($data)                        { '"' . quotemeta($data) . '"' }

say dd ['foo', { bar => "baz" }];

With Smartmatch (give/when) scheduled for deprecation in 5.42 he has written a new drop-in replacement that uses Multi::Dispatch, Switch::Right, which addresses the issues with the original implementation that was in core.

Also on display was the new class syntax introduced into core in 5.38 with use feature 'class'. Here's an example of how it looks:

use v5.40;
use feature 'class';

class Point {
  field $x :param = 0;
  field $y :param = 0;

  method describe () {
      say "A point at ($x, $y)\n";
   }
}

Point->new(x => 5, y => 10)->describe;

If you are waiting for Perl 7, Damian is here to tell you that the future is now, you don't have to wait for Perl 7 (or 17), it's Perl 5 with Multi::Dispatch and use feature 'class'!

The last day of the conference provided an opportunity to go deeper into learning the new class syntax with a workshop on building a rogue-like adventure game from scratch.

So what's next? The London Perl & Raku Workshop is taking place on October 26, 2024 and Perl 5.42 is just around the corner!

Next Generation

-JAPH (Just Another Perl Hacker)

posted at 2024-07-10T21:29:40 by baerg

My Freedom Story

An open letter to my Canadian elected officials,

When the covid-19 vaccines became available in early 2021 I was one of the first ones to line up in downtown Calgary to get a shot. I generally do not have reactions to medicine so I felt I was in a very low risk category personally of an adverse event and could help reduce the risk of overwhelming our health care system by participating in the experiment. I did this of my own free will. My wife has had many strange reactions to medicine and did not feel comfortable getting inoculated due to the risk of an adverse event. I respected and supported her in that, having witnessed many of the reactions. Both of our decisions regarding the vaccines were valid and had to be evaluated based on our individual health and experience, which is not how they are being presented to us by our government health authorities. Instead they are being presented as a one size fits all, safe and effective for everyone. When the restrictions on our freedoms came into effect, she felt compelled to take the risk so that she could be included in society and have freedom of movement. Immediately after getting the shot, her face went numb. It should be understandable that she is not willing to get a second shot, but both the pharmacist and a call to AHS downplayed the adverse event. She is now excluded from much of society, is not able to travel by plane, and cannot visit her Dad in his care home.

I am asking you to help protect our freedom to say no to medicine that has harmed our loved ones.

I have 3 healthy boys aged 14-20. They are in an age group that has no significant risk from covid-19. They are also precisely in the higher risk group of myocarditis and pericarditis as outlined on the Canadian government website regarding the safety and adverse events of the current covid-19 vaccines.

myocarditis

source: COVID-19: Vaccine safety and side effects - Canada.ca - 29 Jan 2022

Because of this we have chosen not to give them the current vaccines and are continuing to focus on other preventative measures like fresh air, an active lifestyle, healthy eating, and vitamin D supplements. Yet our children are subject to government advertising encouraging them to ask their parents to get them vaccinated. Canada has strict rules around advertising drugs which this violates, and this advertising undermines our role as a parent.

I am asking you to help protect our freedom to say no to medicine that carries a risk for our children.

In Sept 2021, I was censored and banned from participating in discussions on cbc.ca. I was commenting on an article about Ivermectin, which did not bring forward all of the research and information that was currently available. I was simply discussing information with others that was on topic.

censored

When we censor some ideas, we are causing others to be amplified that you did not intend. Without all comments being allowed, the thread on the article ended up being filled with insults and dehumanizing statements implying that a segment of the Canadian population are idiots.

dehumanizing

source: Ivermectin: Questions and answers about the anti-parasitic drug - CBC.ca - 02 Sep 2021

When we allow ideas and information to be cancelled because of how it may affect a policy or narrative, we are taking a big risk. We need both liberal and conservative ideas in order to progress without chaos. We need the free flow of all ideas and information to collectively determine the best way forward.

I am asking you to help protect our freedom to discuss ideas without being censored, cancelled, or banned from conversation.

My wife has a yoga fitness class business that was shut down by the restrictions implemented in 2020. When the restrictions were eased in 2021, she began to start back up. This meant planning sessions months in advance, booking a studio and taking registrations. When various forms of restrictions began again, and mandates were introduced, it became impossible for her to plan anything more than a week in advance, effectively shutting down her business again. In one case, we were told only days before our children were supposed to go back to school that their schools were being shut down.

I am asking you to help protect our freedom from living in constant fear that our plans will be disrupted by government restrictions and mandates.

As a family we recently attended an event at a children's camp. Upon arrival we were asked to show our vaccine cards, and having none, we were provided with red wristbands. Those that had vaccine cards were given green wrist bands. This labelling and the resulting segregation that it caused is a direct result of government policies.

I am asking you to help protect our freedom from being labelled and segregated.

I am asking for an end to all restrictions and mandates, that these measures will not be used in this way again, and a stop to all censorship. Please understand that I will only vote for an elected official in the future that is committed to this, and I will be encouraging others to do the same.

Respectfully,

Andrew Baerg - Resident of Calgary (Ward 3), Alberta (Calgary North East), Canada (Calgary Skyview)

posted at 2022-02-12T19:21:37 by baerg

Xmonad is my DE

Remember Enlightenment? Beautiful backgrounds and transparent terminals so you could admire the backgrounds while coding.

Now I consistently cover the background with a tiling window manager and I don't even have a transparent terminal because it doesn't support compositing...

I probably get more done.

I just upgraded my System76 laptop and decided to try out Pop!_OS. I couldn't bind <Super> 1 through 9 to switching workspaces, so I bailed on it pretty quick. I tried i3 on Manjaro but it binds workspaces to additional monitors.

Turns out I'm addicted to Xmonad.

But Xmonad is just a window manager and none of the distros bundle it with a full desktop environment - which makes sense, it's for the minimalist. But you still want your Fn keys to work (brightness, volume, media), a way to control network connections, and of course a way to open your browser of choice!

So, I'm sharing my Xmonad desktop environment. A collection of configs and scripts (and sounds) - there's even a script to change the background, which I rarely see.

posted at 2020-08-13T04:55:43 by baerg

ic5+plack+nginx

I have been successfully running Interchange 5 using a stack of Plack + Nginx in production since February, 2016 on a busy site, yoursole.com

Here are the relevant config snippets:

app.psgi:

use Plack::Builder;
use Plack::App::WrapCGI;

builder {

  # restart interchange
  my $ic = `/path/to/interchange/bin/interchange -r`;
  if (!$ic) {
    print "ERROR: failed to restart interchange\n";
  }
  else {
    print $ic . "\n";
  }

  # Mount paths
  mount "/catalog" => Plack::App::WrapCGI->new( script => "/path/to/interchange/bin/catalog", execute => 1 )->to_app;
};

plackup command:

plackup -s Starman --workers=5 -p 5001 -a /path/to/app.psgi -D

nginx:

proxy_pass http://localhost:5001/catalog;

posted at 2016-06-23T05:58:50 by baerg