• Spreadsheet::WriteExcel is dead. Long live Excel::Writer::XLSX.

    The following is by John McNamara. If you do anything with getting data to users that winds up in Excel, you owe it to yourself to look at John's module.

    Last week I released a new version of Excel::Writer::XLSX to CPAN that was 100% API compatible with Spreadsheet::WriteExcel. This marked a milestone as I am now able to move past WriteExcel's feature set and move on to new features that I wasn't able to support previously.

    This was achieved with 30 CPAN releases in almost exactly a year. By comparison, WriteExcel took almost 10 years. This gives a fair indication of the disparity of effort required to implement a feature in the pre-Excel 2007 binary xls format as opposed to the new XML based xlsx format.

    So, from now on, all new features will go into Excel::Writer::XLSX and Spreadsheet::WriteExcel will be in maintenance mode only.

    The first of the new features, conditional formatting, was added yesterday. For a long time has been the most frequently requested feature for WriteExcel but it was always too big a feature to implement in the available time that I had.

    With Excel::Writer::XLSX you can now add a format like the following:

    $worksheet1->conditional_formatting( 'B3:K12',
    {
    type     => 'cell',
    format   => $light_red,
    criteria => '>=',
    value    => 50,
    }
    );
    

    This will result in output like the following, full example here:

    conditional_format.jpg

    Excel::Writer::XLSX has also been designed differently from Spreadsheet::WriteExcel to allow it to implement some features that previously weren't possible (or at least easy). One of these is the separation of the data and the formatting.

    It was a common assumption with new users of WriteExcel that you could write data to a spreadsheet and then apply the formatting afterwards. However, for design reasons related to performance and Excel's file format this wasn't easily implemented. With Excel::Writer::XLSX the back-end architecture is different and this type of feature is not only possible but will be added soon.

    If you are a user of Spreadsheet::WriteExcel then now is probably a good time to try out Excel::Writer::XLSX so you can get the new features when them come on-line.

    John McNamara is a software engineer living in Ireland. Once a month he drinks a pint of Guinness with Tim Bunce to discuss Perl and open source. He spends a lot of time looking at hexdumps so that you don't have to.

  • There's only one useful way to handle your detractors

    This is a repost from my main blog, but it applies to all of us working on Parrot and Perl 6. Keep on keeping on, ignore the trolls, and keep moving forward to completing the vision. Here's a Reddit/Slashdot/whatever thread that never happened:
    Internet crank on Reddit: "Hey, Steve Jobs, I guess that new iPad looks cool, but I think iPad is a stupid name, it makes me think of sanitary napkins."

    Steve: "Yeah, well, here's why we called it that. (Long explanation justifying his choices)"

    Crank #2: "Well, why didn't you call it the iTablet? I think that would have been a good name. What does everyone else think?"

    Crank #3: "What does it have to be iAnything? I'm tired of the i- prefix."

    Steve: "We thought about that, but ... (More explanation about his choices)"

    Crank #1: "And really, isn't it just a bigger iPod Touch? I would never carry that around with me. And come on, you're just trying to redo the Newton anyway LOL"

    Steve: "My logic behind the iPad is (vision, business plan, blah blah blah)"

    Can you even imagine Steve Jobs in this sort of time-wasting and emotionally draining tit-for-tat in a thread on Slashdot? On reddit? In some blog's comment section? Of course not. Justification of his plans would take away from the amazing things that he needed to achieve. Naysayers are part of every project. How many people do you think pissed on Jimmy Wales' little project to aggregate knowledge? Nobody's going to spend their time writing encyclopedia entries! And yet there it is. On a personal level, if I listened to everyone who thought I was wasting my time improving on find + grep you'd never have ack. We all have to persevere in the face of adversity to ideas, but there's more than that. We need to ignore our detractors. Despite how silly and time-wasting it is to argue your motivations and reasons for undertaking a project, many of us feel compelled to argue with everyone who disagrees with us. I suggest you not waste your time. On the Internet, the attitude is "Why wasn't I consulted?" Every anti-social child (measured by calendar or maturity) with a keyboard thinks it's his responsibility to piss on everything he doesn't like. They'll be there always. You can no more make them go away than you would by arguing with the rain. What are you hoping to achieve by arguing with someone who doesn't like your project? Do you expect that he'll come around to your way of thinking? It won't happen through words. Not only does arguing with your critics waste your precious time, but it tells them, and every other crank reading, that you're willing to engage in debate about what you're doing. Don't encourage them! Let them find a more receptive target. I'm not saying that factual misstatements need to be ignored. If something is provably incorrect, go ahead and counter it with facts. However, most of the time these message thread pissing wars get down to "I would not be doing what you are doing, and therefore you are wrong for doing so." The only thing that has a chance of silencing your critics is success at what you do. Arguing with the naysayers doesn't get you any closer to that.
  • Notes from Damian Conway's sessions at OSCON 2011

    Here are my notes on two sessions from Damian Conway: The Conway Channel, and (Re)Developing in Perl 6. My notes are scattershot because it's awfully hard to watch and listen and take notes in a Damian. I wish he'd post his slides, but I understand why he doesn't/can't.

    (These notes are extracted from my notes from OSCON 2011. Other topics include API design, PostgreSQL, Jenkins and Cornac.

    The Conway Channel

    The Conway Channel is Damian Conway's annual discussion of new tools that he's created in the past year.

    Regexp::Grammars is all sorts of parsing stuff for Perl 5.10 regexes, and it went entirely over my head.

    IO::Prompter is an updated version of IO::Prompt which is pretty cool already. It only works Perl with 5.10+. IO::Prompt makes it easy to prompt the user for input, and the new IO::Prompter adds more options and data validation.

    # Get a number
    my $n = prompt -num 'Enter a number';
    # Get a password with asterisks
    my $passwd = prompt 'Enter your password', -echo=>'*';
    # Menu with nested options
    my $selection
    = prompt 'Choose wisely...', -menu => {
    wealth => [ 'moderate', 'vast', 'incalculable' ],
    health => [ 'hale', 'hearty', 'rude' ],
    wisdom => [ 'cosmic', 'folk' ],
    }, '>';
    

    Data::Show is like Data::Dumper but also shows helpful debug tips like variable names and origin of the statement. It doesn't try to serialize your output like Data::Dumper does, which is a good thing. Data::Show is now my default data debug tool.

    my $person = {
    name => 'Quinn',
    preferred_games => {
    wii => 'Mario Party 8',
    board => 'Life: Spongebob Squarepants Edition',
    },
    aliases => [ 'Shmoo', 'Monkeybutt' ],
    greeter => sub { my $name = shift; say "Hello $name" },
    };
    show $person;
    ======(  $person  )====================[ 'data-show.pl', line 20 ]======
    {
    aliases => ["Shmoo", "Monkeybutt"],
    greeter => sub { ... },
    name => "Quinn",
    preferred_games => {
    board => "Life: Spongebob Squarepants Edition",
    wii => "Mario Party 8",
    },
    }
    
    Acme::Crap is a joke module that adds a crap function that also lets you use exclamation points to show severity of the error.
    use Acme::Crap;
    crap    'This broke';
    crap!   'This other thing broke';
    crap!!  'A third thing broke';
    crap!!! 'A four thing broke';
    This broke at acme-crap.pl line 10
    This other thing broke! at acme-crap.pl line 11
    A Third Thing Broke!! at acme-crap.pl line 12
    A FOUR THING BROKE!!! at acme-crap.pl line 13
    

    As with most of Damian's joke modules, you're not likely to use this in a real program, but to learn from how it works internally. In Acme::Crap's case, the lesson is in overloading the ! operator.


    (Re)Developing Perl 5 Modules in Perl 6

    Perl isn't a programming language. It's a life support system for CPAN.

    Damian ported some of his Perl 5 modules to Perl 6 as a learning exercise.

    Acme::Don't

    Makes a block of code not get executed, so it gets syntax checked but not run.

    # Usage example
    use Acme::Don't;
    don't { blah(); blah(); blah();
    

    Perl 6 implementation

    module Acme::Don't;
    use v6;
    sub don't (&) is export {}
    

    Lessons:

    • No homonyms in Perl 6
    • No cargo-cult vestigials
    • Fewer implicit behaviours
    • A little more typing required
    • Still obviously Perlish

    IO::Insitu

    Modifies files in place.

    • Parameter lists really help
    • Smarter open() helps too
    • Roles let you mix in behviours
    • A lot less typing required
    • Mainly because of better builtins

    Smart::Comments

    • Perl 6's macros kick source filters' butt
    • Mutate grammar, not source
    • Still room for cleverness
    • No Perl 6 implementation yet has full macro support
    • No Perl 6 implementation yet has STD grammar

    Perl 6 is solid enough now. Start thinking about porting modules.

  • ack 1.96 released, now ignores minified Javascript files

    I released ack 1.96 last night. ack is a code searching tool like grep that is tuned for programmers with large trees of heterogeneous source code. Details about ack are at betterthangrep.com. You can install App::Ack from the CPAN, or follow other instructions at betterthangrep.com. Details of the update: * Now ignores minified Javascript files. Anything matching -min.js or .min.js is ignored. * Lua can now get detected from the shebang line. Thanks, Matthew Wild. * Added support for version numbers in executables in shebang detection. Now if your Perl program's shebang refers to /usr/local/bin/perl-5.14.1, ack will find it. * Added Groovy support (--groovy). * Added .pm6 as a --perl extension.
  • Nurturing new open source contributors

    In a recent non-public thread on Google Plus about what someone saw as too much low-quality code on CPAN, Brian Cassidy gave some great thoughts (quoted with his permission) about how to handle contributions from newcomers:

    New authors should not be "beaten" for not following standard practices, rather coached and mentored into becoming productive members of our culture. Disciplining new authors is counter not only to our culture, but it goes against the release early/release often mantra we often hear in the open source ecosystem.

    It's very easy to dismiss someone as ignorant and cast them aside (in retrospect, I'm ashamed to say I've done it too). The hard road is to offer them a hand, show them the ropes.

    Not everybody has time for that, and we'll never save people from themselves (no matter how hard we try). But before you rush to dismiss someone's effort (that they've submitted for public scrutiny, no less) think about how you would've like to have been treated when you were new.

    A kind word of encouragement can go a long way.

    Do you have tales to tell of how you helped guide a newcomer, whether in Perl or elsewhere? Please post your stories.