The Moose Collective

Well in my last post I added a few new attributes to my Database::Accessor::Element class and when playing about bout today I think I will have to revisit one of them 'aggregate'.

If I just leave it as it is

 has 'aggregate' => (
        is  => 'rw',
        isa => 'Str',
     );
 
It will begin to break-down my API as a programmer could come along and enter a very specific Mongo item such as 'mergeObjects' or something odd from an SQL DB like 'DENSERANK' and that makes for a very inconstant API.

So I am just going to bite the bullet and add in a 'Type' for this attribute so lets have a look at that.

By the Numbers - YAPC::NA::2016 - Wednesday Night Pull Request Challenge

As YAPC ... TPC::NA draws to a close, there was one final hurrah. About 25 (+/- a few) brave souls partook in the Wednesday Night Pull Request Challenge.

There were:
  • 28 pull requests issued
  • 4 modules release
  • many more "person hours" spent coding, rewriting, and debugging
  • 50 peoples worth of food eaten
  • 1 budding cross-continental collaboration (App::DBCritic)
  • a metric ton of community enjoyments had all around

Thank you to craigslist for sponsoring the event. And thank you to both the hard working YAPC organizers and PRC participants for coming together for something that I hope will become continued in the future.

I would be remiss if I did not greatly encourage anyone (no matter your skill level) to get involved in the monthly CPAN PRC Challenge run by Neil Bowers. It is his effort that gave me my first real opportunity to contribute to the Perl community through pull requests; but moreover it inspired me to take a role in introducing the fun to attendees of YAPC::NA::2016.

Why do I like simple object system? Object::Simple story.

Do you like simple object system or lerge object system? I like simple object system.

In old days, I believed Perl would need complete object system, which has meta object protocol and class syntax.
Many perl programmers sought a good way to write object oriented programing.

A famouse lerge object system is Moose.
This module has many features, for example,
has, extends, with, is, isa, corce, dose, required, traits, builder, BUILD, DEMOLISH, etc.

A famouse simple object system is Mojo::Base.
This module is a part of Mojolicious.
Mojo::Base only has "has" method and a option to set default attribute value.

Do you know Mojo::Base was a little more complex at first?
Gradually, Mojo::Base removed the features except only really needed ones.

Mojolicious source codes is very clean. Mojolicious only use single inheritance and delegation.
Simple object system and single inheritance produce very clean codes.

I was surprised because I had believed Perl would need complete object system to produce good codes.

Perl 5 Porters Mailing List Summary: June 16th-21st

Hey everyone,

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

A Few Moose Never Hurt

So continuing on with the attribute fun today in the Moose-pen I am going to have a look at my 'Element' Database::Accessor class. So far like View there is not much to it only 'alias' and 'name'

Now putting my fore-ward looking Moose glasses you can see that I am going to need some more attributes. Well in SQL this class is being used as a field so I will need at least a 'table name' but then again I do not have a table in Classes so I guess I need a 'View' object now I could do this.

has 'view' => (
        is  => 'rw',
        isa => 'View',
    );

Comprehensive guide and tools to split monolithic database into shards using Perl

You can find the most recent version of this tutorial here.

Intro

When you suddenly get this brilliant idea, the revolutionary game-changer, all you want to do is to immediately hack some proof of concept to start small project flame from a spark of creativity. So I'll leave you alone for now, with your third mug of coffee and birds chirping first morning songs outside of the window...

...Few years later we meet again. Your proof of concept has grown into a mature, recognizable product. Congratulations! But why the sad face? Your clients are complaining that your product is slow and unresponsive? They want more features? They generate more data? And you cannot do anything about it, despite the fact that you bought the most shiny, expensive database server that is available?

Cool Perl 6 features available in Perl 5

Today I saw Damian Conway giving a talk at YAPC::NA 2016 (also known as The Perl Conference now :-). He was talking about some cool Perl 6 features, and I realized that some of them are available right now in Perl 5.

Please test MITHALDU/OpenGL-0.6704_05.tar.gz

Reaching out to the Perl community at large due to this release being hardware-sensitive and feedback being most useful to me when it comes from many various hardware combinations, particularly if the graphics cards involved are older or stranger.

Please test this CPAN developers release on your platforms to confirm that
there are no regressions from the last stable release. ... Actually,
please do report any and all errors you can see, i am VERY keen to see
what other issues this throws up on different platforms.

This update has seen a LOT of changes since _03/_04, but the main ones are
these:

  • updated and greatly automated compilation of hardware-dependent functions and constants
  • enabled hardware feature detection for compilation on windows
  • it even runs and tests successfully on a Win10 VM with OpenGL 1.1
  • updated included freeglut.dll to latest release in major version 2

Update

Thanks to all the feedback i got, i was able to nail things down better and make a new dev release that should at least fix the glut regression:

https://metacpan.org/release/MITHALDU/OpenGL-0.6704_06

Cool Moose

In yesterday's Moose-pen I hinted that I would be getting all my test in order. Well I did that and checked them in but there really was not that much to report on. Just a lot of repetitive code. I suppose I could write one test case to check all of my Database::Accessor classes using some simpler iteration over a list but I really like having a separate test case for all my classes as there really is only a small part that is common between them, so onto something different today.

I am going to start filling in the attributes of my various embedded Database::Accessor classes and I guess the best place to start in with Database::Accessor::View.

Sparrowdo - a simple configuration management tool written on Perl6 and consuming sparrow plugins

Hi!

This is the very first ( to take it for a spin ) release of sparrowdo - a simple configuration management tool written on Perl6 and consuming sparrow plugins.

This is where Perl5, Perl6 could make a synergy. Consider a simple example of sparrowdo scenario:

Perl 5 Porters Mailing List Summary: June 9th-15th

Hey everyone,

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

Refactor of Perl Critic policy ProhibitUnusedVarsStricter

Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter (whew!) is a Perl Critic policy that attempts to be more stringent about finding unused variables than the core policy of similar name. One of the things that has to be done to make this happen is to figure out which variables are interpolated into double-quotish strings.

The original version of this module had its own string-analysis logic, as do other Perl-Critic policies that have to figure out which variables are really being used. With the mainstreaming of postfix dereferencing, it seemed to me that the recognition of interpolated variables had become complex enough that a separate module to figure this stuff out was justified. Thus was born PPIx::QuoteLike.

Moose Attributes Cheeper by the Doz

So today in the Moose-pen I am going to stub in the rest of my Database::Accessor classes and the rest of my Accessor.pm attributes.

It seems I have six outstanting Database::Accessor classes to add in namely;
  • Param
  • Condition
  • Link
  • Gather
  • Filter
  • Sort
That was easy enough just a quick copy and rename job of the Predicate class without its attributes, so six more classes like this one

 package 
           Database::Accessor::Param;
    use Moose;
    with qw(Database::Accessor::Roles::Base);
     has '+name' => ( required => 0 );
1;
Now I quickly realized I should update my Roles a little seems that

Newbie Poison

After encountering CodeNewbie at OSCON 2016 I've been thinking a lot about why there are so few new developers interested in Perl. I haven't been a Perl beginner for a very long time so I went looking for resources and found FAQ for the beginners mailing list. I wanted to know how active the mailing list was so I immediately went to the web achive. Reading through the list I saw things like:

"Is there a reason why you think one CPU is better than another?"

"your code exhibits many bad elements, and you don't seem to apply all the advice I've been giving you. Please go over http://perl-begin.org/tutorials/bad-elements/ , read it and internalise it."

Condescending, abusive advice is worse than no advice at all. There's no way I'd send a beginner into that. Nobody should have to learn like that. Seeing it ruined my afternoon. Maybe I should have read more of the FAQ:

"Who owns this list? Who do I complain to?"

This is a FREQUENTLY ASKED QUESTION?

Introducing SVG::Estimate

If you do anything with 2 dimensional CNC machines such as plotters, mills, or lasers, you’ve probably used some form of vector graphics. The most popular open source vector graphics type is called SVG or Scalable Vector Graphics. If you’re doing this professionally, you need to know how to charge for that work, and if you know the length of the shapes included in that vector file, you can do a pretty good job of preparing an estimate for a customer. That’s where SVG::Estimate comes in. It does the mind melting math to tell you the length of arbitrary lines and shapes inside a vector file. 

[From my blog.]

perl6: count chinese characters in string


Hi,

This is my first post here and it will be a short one.

I was asked to count chinese characters in a string. Most of us know the annoying task of writing an essay with $n words. For chinese it will be $n characters.

Would be a shame if we take this too serious and write too much.

so:

my Str $text = "你好! 我喜欢!";

$text ~~ s:g/ \W | \d //;

say $text.chars;


And that's it.

So why even blog about it? What I think is amazing is that all worked with the first attempt.
I often just try stuff in perl6 without knowing if it will work the way I think it will work.

However most of the time, it just does... and this is why I love this language!

Keep up the great work!!

Ben

Two Moose at Play

So today in the Moose pen I am going to have a closer look at my Role from my last post . So here it is

YAPC::NA::2016 - Wednesday Night Pull Request Challenge

craigslist is sponsoring the Wednesday Night Pull Request Challenge at YAPC::NA::2016 on 6/22 at 6pm-10pm (or 'til). This event is modeled, inspired, and loosely affiliated with Neil Bower's fun and successful "CPAN Pull Request Challenge" .

Food and drinks will be provided, so PLEASE RSVP.

A primary goal of this event is to introduce participants to the wonderful world of contributing to the Perl ecosystem.

This is a beginner friendly event, and assistance will be given to anyone needing help getting started.

To make things even easier, there will be a list of eligible modules to choose from. Participants may also come with their own projects and modules to work on.

For more information and to RSVP, please visit http://www.yapcna.org/yn2016/wiki?node=PRC.

Missing Smart Match

I know that smart match is considered experimental at best and is likely going away at worst, but I hate that! In what world is:

if( grep $_ eq $scalar, @array ) { }

Better than this?

if( $scalar ~~ @array ) { }

The former doesn’t even shortcut. Some will say that I should use any like this:

use List::MoreUtils qw/any/;
if( {$scalar eq $_} @array ) { }

But any damn fool can see that it’s 2 lines of code instead of 2 characters. It’s not more readable. It’s just foolish. Some parts of smart match suck and I get that. So throw out those cases, not smart match itself.

[From my blog.]

POD speculation

Pod::Coverage

[...] expects to find either a =head(n>1) or an =item block documenting a subroutine.

In pure TIMTOWTDI spirit, it's up to you to decide which style you want to adopt. There are PROs and CONs, though.

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.