XS, I Spoke too soon

Well in my last post like almost all other XS post I started out by lamenting the sad truth that there was little in the way or resources for XS in 2010 and things haven't improved much since then.

Well I was wrong. While doing a little research for this post I stumbled onto XS-Fun up on github and was so surprised at what I found I decided to do a quick review on it for today's post.

Well it is new tutorial, less than an year old and a work in progress with three short chapters in POD format.

Well it is worth the read as they introduce the novel approach to drop 'h2xs' from the picture and dive right into actually using XS code with practical examples. So to use the authors own words

Eliminating the use of h2xs and bundling any C libraries we use (that we haven't wrote by ourselves) remove a lot of needless complexity.

Box::Calc 1.0

I’m pleased to announce the release of Box::Calc 1.0, which is an algorithm we’ve been developing for a few years over at The Game Crafter for packing items into boxes. If you run a shipping / receiving operation, or a web store this module can help you determine which box or boxes to use to fit all the items ordered, how much each box will weigh, etc. 

Originally we offered Box::Calc as a web service, but now we’re releasing the full module as open source on CPAN. Enjoy!

[From my blog.]

"Functional core & Imperative shell" : OO design, and isolated tests without mocks

Following Ovid's Sick of being mocked by unit tests and the link to the discussion is TDD dead between Kent Beck and others, I found this talk and it seems like a promising solution. I'm writing this post to share it with you all, but also to clarify ideas for myself.

The original goal is to do isolated unit testing without using Test Doubles (mocks, stubs, etc), and the method is called "Functional core & Imperative shell". According to its creator it also leads to cleaner design, which is more important than testing in the end. So we're fetching two stones with one bird.

Here is how to do it in theory:

mop problem 4 - mop is misleading name

I want to write all mop problems I am thinking before mop is added to Perl core.

mop is abbreviation of Meta Object Protocol. I think this name is misleading name. This name associate "Meta information of Object ".

But truth is that any information is Class Information, not Object information.

For example,

1. Attribute name
2. Parent class
3. Role

This is belong to Class, not Object.

    ref $object
        -> Class
            -> Attribute name
            -> Parent class
            -> Role information

The following concept is not good.

XS, Enough Said

Well I think I will tackle a difficult subject for my next series and that is XS programming or how to add C to you Perl and learn to regret it.

XS programming is not for the faint of heart I will warn you know it is tedious, stressful, unrewarding, undocumented and hard to learn. However if you can get past the first few high hurdles it is well worth the effort.

Now XS programming is not rare you can find it all over CPAN and I can almost grantee if you have ever used Perl to log into a DB then you have used XS.

So it is there and in use every day, it just works and we are happy about that.

Watch the secret YAPC::NA live

TL;DR

You can watch YAPC::NA live here .

The rant

Honestly, I don't get it. It seems the organizers of YAPC::NA 2014 have decided to keep total radio silence, so no enemy will know about the event. No blog posts. Hardly any tweets. Even the mailing list was almost deserted.

Then a month before the conference there was a blog post asking YAPC::NA or not which I posted on twitter and to the YAPC::NA mailing list. Not surprisingly some people took offense of me echoing it or calling the whole thing silly. Instead of focusing on the actual issue. The lack of communication.

There was a response to that article in the form of a comment, but still no post on the YAPC::NA web site.

I understand how other things can interrupt the well meaning of people, but if it was an unfixed bug in a piece of open source code, someone could step up and fix it. At a conference, at the Perl conference in NA, I'd hope the organizers would mention they have a time or resource issue. I'd probably even expect the officials of The Perl Foundation to check if the organization of YAPC::NA goes well.

Another (silly) idea: autocorrect in shell (bash) tab completion

Here's another idea that just popped up in my head and can be considered silly, somewhat: autocorrect for tab completion.

bash already has cdspell shell option (enabled via shopt -s cdspell) which can correct directory names for you, so for example if you have a directory named "pictures" and you type "cd picture" or "cd pcitures" it will assume you meant "pictures" and cd to the corrected directory. To be honest I've never used this feature.

bash also has another option called dirspell which can correct spelling in directory name during completion. Try it out with shopt -s dirspell direxpand. So now if you type "ls /ect/pa" and press [TAB] bash will correct it into "ls /etc/pa". Pretty nifty. I'm only recently aware of this option and will turn the setting on for the next few weeks to find out if this is useful.

But the dirspell setting only works for directory/filename and it does not show suggested alternatives. I was thinking more like Google search autocomplete and typeahead suggestion.

A month of my work on MetaCPAN report.

I just updated my blog about my work on MetaCPAN as I have been working on The Outreach Program for Women for fully a month. Here : My blog

Enter MooseX, Appendix II Last One I Promiss!

Well This should really be the last one in this series baring any big problems that come down the line if people ever end up using this MooseX.

So in my last post I applied the first patch to my MooseX by simply clicking a button on github and I must say I am pleased with the result

So not I get a full green board on CPAN testers for V0.00.05 with 33 passes and 33 attempts however I do see that my compatibility Matrix isn't that broad covering only two OSs.

Looking back a bit comparing to my first result I got 276 attempts, 95 FAILs, 17 NAs 164 PASSes, so I tested on a larger number of boxes but failed a large number of tests.

System Sleuthing - Using ptrace to Print Backtraces

I recently developed a Perl module that allows you to print backtraces when your program makes certain system calls; see my blog for the full story!

Moose MonkeyPatching With a Mock UserAgent

In this post: https://blogs.perl.org/users/samuel_kaufman/2014/06/when-a-fat-comma-is-confusing.html I mentioned I was using Test::LWP::UserAgent for my test. One thing I struggled with was testing ( with a mockup ) a service which was being instantiated completely beyond the scope of the test- so even though it took ua as a parameter to the constructor to override the default LWP::UserAgent->new, I couldn't reach down inside the Catalyst controller where it instantiated a module with the default parameters from the test.

So in case anyone else has had similar issues, here's how I got it working:

Giving up on weekly neoCPANisms

For a brief period of time (well, one week), I had a chain of 4 weekly neoCPANisms in NEILB's NeoCPANisms contest (which is subtly different from the Monthly New Distribution Challenge 2014 quest on questhub).

Then at the end of week 23, instead of pushing out an entirely new module (I have a two or three "almost ready" distributions in my CPAN folder), I decided to give up.

Enter MooseX, Appendix I Not Again!!

Honestly I though my last post would be the final one of this rather lenghty series but I was wrong.

Seems soon after my release I got what I think is my first ever 'Pull Request' from github from the resident mooz giiyosewinini na Toby Inkster so I had to post on that today.

Well Seems there is a better fix for the bugs/errors that where thrown in the first version of MooseX::AuthorizedMethodRoles as the root of the problem was the inability of perls less that 5.8.8 to figure out that the $requires part of

 
 foreach my $key (keys($requires))
is a hash.

Well I must of really been up late when I wrote that up as I normally, as force of habit,
wrap my hash refs with {} like this

A marvellous source of color info

Here, I've entered ff9600:

http://www.color-hex.com/color/ff9600

When a fat comma is confusing

I frequently swap out commas for fat commas ( => ) when I think it reads better. One place this bites me in the ass is when I reread code where I'm using a function that takes two parameters but look like they could take more. This recently happened to me with Test::LWP::UserAgent.

I started with the docs' example:

$test_ua->map_response(
  "myapp",
  sub { HTTP::Response->from_psgi($app->($_[0]->to_psgi)) },
);

Then thought this would look prettier:

$test_ua->map_response(
  myapp =>
  sub { HTTP::Response->from_psgi($app->($_[0]->to_psgi)) },
);

Then of course I came back two days later and added:

When a failure is not a failure

[What I really should have done here is something like Tom Wyant or Joel Berger.  Being a literary type, that appeals to me.  Of course, with Dupin and Holmes taken, who would I pay homage to? Nero Wolfe, perhaps? Batman? Michael Westen? Harry Dresden?

Anyways, maybe next time, if I have more time to prepare.  For now, you’ll have to settle for plain ol’ me.]

At $work, I’m the guy who maintains the tool we use for branching, merging, pushing ... release management, I suppose you’d say.  I don’t actually do the pushes most of the time, but I’m usually the guy who takes the tickets when there’s something wrong with the process.

Enter MooseX, V Well Thats a Wrap

Well a wrap for Kwalitee at least as my little changes from my last post left me with only one Extra metric

is prereq

Well there is not much I can do about that unless one of the many legions of my readers, (well maybe a contubernium at least) will have to do that for me.

So I did improve from 86%/111.2 in version 00.001 to 100%/134.4 for version 0.00.04 so not bad but what does this mean?

Well in the end not much as it is only a game and I am sure there are plenty of Mods out there that have a less than stellar scores but are made to very high standard.

Silliness of the day: digit-by-digit tab completion for ints/floats

I was hacking on Perinci::Sub::Complete these past two days and I thought I'd add a (silly) feature that most other completion libraries don't (bother to) have.

Conflict Resolution: local::lib and git's Perl

I ran into a frustrating problem the other day:

$ git add -i
/usr/bin/perl: symbol lookup error: ~/perl5/lib/perl5/x86_64-linux-thread-multi/auto/List/Util/Util.so:
undefined symbol: Perl_xs_apiversion_bootcheck
fatal: 'add--interactive' appears to be a git command, but we were not
able to execute it. Maybe git-add--interactive is broken?

I've seen this error message from Perl a lot. It basically means that I'm trying to load an XS module compiled for a different version of Perl. Since git is directly trying to run /usr/bin/perl (5.10.1) as opposed to the perlbrew Perl I have installed (5.16.3), the error comes as no surprise: PERL5LIB is checked before Perl's built-in libraries. So if you have a local::lib (which adds its directories to PERL5LIB) and try to use those modules in a different Perl, things may not work as you expected.

General hardware hackathon at YAPC::NA 2014

How many Perl programmers does it take to change a lightbulb?

Wait, I thought that was a hardware problem. Well, it used to be; now it's a new module to contribute to CPAN, a new web service, or maybe something not dreamed up yet. Thanks to a proliferation of inexpensive SBCs (Single Board Computers), such as Arduino and Raspberry Pi, and an amazing array of easy-to-use sensors and actuators, the lines between programming and hardware are blurring fast.

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.