Dependency Injection with Bread::Board

Jesse Luehrs will give a talk at YAPC::NA 2012 described as:

Dependency injection is a powerful method of organizing your applications. It has been referred to as “the inverse of garbage collection”, because while garbage collection frees you from having to worry about how your objects are destroyed, dependency injection frees you from having to worry about how your application objects are created.

This talk will contain an overview of what dependency injection is and how it works (you’re probably already using basic forms of it!), and will introduce the Bread::Board module, which provides a more structured form way to model the relationships between your objects.

[From the YAPC::NA Blog.]

Oracle SESSIONS_PER_USER

Connecting to Oracle with a proxy connection like this:
DBI->connect( $dsn, 'user[otheruser]', 'password', $option_list)

We recently updated DBI to 1.620 and DBD::Oracle to 1.44 (late last week I think). Today I saw an error that I have never seen before (but should have). "ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit" You see otheruser has a profile that limits SESSIONS_PER_USER to one. We're creating between one and eleven of these database connections simultaneously in different processes.

So I tried it with the older install that was using DBI 1.616 and DBD::Oracle 1.30. I didn't receive the error so it appears that the SESSIONS_PER_USER profile limit was not being respected.

We're bumping up the SESSIONS_PER_USER where appropriate and adding some checks for this error condition now that it's being thrown.

I'm curious if anyone is aware of which change may have caused this to start working correctly?

Big module sizes

I measured the size of some big modules, with B::Stats and B::C, statically compiled.
This amounts to about to the same size as dynamic usage via perl, with all options and modules used at once. I.e. the worst-case scenario.

Interestingly Module::Build is much harder to compile - you'd need 6GB RAM at least -
and much bigger in the end-result than Moose, which compiles/compresses really fine.

Modules

Module::Build

perl -e'use Module::Build: print q(k)'

ops68K
files48
src lines18K
compiled c lines1.5M
perl compiler memory360M
gcc compiler memory3.4G
executable size37M

Moose

ops91K
files109
src lines28K
compiled c lines889K
perl compiler memory218M
gcc compiler memory1.6G
executable size23M

DateTime::TimeZone

ops2.3K
files6
src lines2.2K
compiled c lines130K
perl compiler memory19M
gcc compiler memory415M
executable size32M

Typical Apps

Biggest cPanel app

The recipe for less than 2MB RAM and gcc < 4.5 is:
cc_harness -E -o$@-cpp.c $@.c
cc_harness -O0 -fno-var-tracking -fno-stack-protector \
-fno-tree-loop-optimize \
-fpreprocessed -fno-exceptions $@-cpp.c

ops467K
files539
src lines95K
compiled c lines1.5M
perl compiler memory352M
gcc compiler memory (32bit -O0)2.0G
executable size61M

Typical cPanel app

Lazy == Cache ?

While I was working on some Moose code this past week, I was struck (again) by how the lazy property of attributes functions almost like a cache.  In fact, often when working in Moose I find that when I want something to be cached, I just make it lazy and call it a day.

Let me illustrate what I’m talking about with some code.  Now, the real process of putting this code together involved a lot of blind alleys and false starts, but I’m going to present it like I came up with the final product smoothly and without interruption.  I do this for two reasons: one, it makes for less frustrating reading, and, two, it makes me look smarter. ;->

So I’m creating a little command line utility to do some moderately complex data loading.  I decide to use MooseX::App::Cmd for the basic structure—this is an excellent module that I’m using more and more these days.  Definitely check it out.

Perl Testing 101: 82% of What You Need to Be a Competent Perl Tester

James E Keenan will give a talk at YAPC::NA 2012 described as:

In fifty minutes, this presentation will provide you with 82 percent of what you need to know to be a competent user of Perl’s core testing functionality.

If you are new to Perl — or if you know Perl but have shied away from learning to write tests — this presentation is for you!

[From the YAPC::NA Blog.]

Automating On Call Jury Instructions

Early in February, I received a jury summons for the United States District Court, Southern District of California. Prospective jurors for federal jury service (at least in this court) are placed on call for a period of about 30 days. I was to call for instructions on April 1 and potentially proceed to do so periodically until May 4 (assuming I wasn’t instructed to report).

Since my initial instruction date was nearly two months away, I created an entry for it in Google Calendar, and promptly forgot about it. On Monday, April 2, I was riding the train to work when I realized that I hadn’t remembered to check my instructions. Fortunately, after arriving at my office and checking my instructions, I had been deferred to the next day.

So I added a new entry in Google Calendar, this time with an SMS reminder. I proceeded to do this for most of April, checking my instructions and duplicating the calender entry with another SMS reminder.

I’m embarrassed to admit that it wasn’t until the last week of April that it occurred to me that I could automate the whole process. After all, isn’t automating drudgery the whole reason I ended up programming Perl in an engineering support group at my day job?

Is Try::Tiny still recommended for exception handling in Perl 5.14 or later?

Because I am interested in the result, I wanted to make the community aware of this question on StackOverflow. If you have an opinion answer there. Perhaps I will summarize the results here when the discussion warrants.

When is line 1 not line 1?

When eval-ing a simple use without a final semicolon, and doubly so on Solaris.

Sometimes eval 'some deadly code' dies at line 2 instead of line 1.

Perl 6 Lists and Arrays vivified: lazy, infinite, flat, slurpy, typed, bound, and LoL'd

Patrick Michaud will give a talk at YAPC::NA 2012 described as:

One of the significant new features of Perl 6 is its support for lazy and infinite lists, arrays, sequences, and other data structures. However, these new features have far-reaching impacts on the whole of Perl 6 design and implementation. Over the past several years there have been many attempts at a coherent design and implementation of Perl 6 lists, each leading to new challenges to be addressed and resolved.

In this talk I’ll shed some light on Perl 6 lists, arrays, sequences, and other structures, explaining some of the fundamentals of how they work and can be used in Perl 6 programs. Lots of examples will be given, with particular emphasis on the lazy, infinite, and flattening behaviors of lists and some of the new range and sequence operators. I’ll also describe how these features have affected Perl 6 development, including an introduction to some of the newer data types such as LoLs, Parcels, Captures, Iterators, and Positionals.

Come to this talk and learn how Perl 6’s list features can result in more elegant and faster code.

[From the YAPC::NA Blog.]

Compiler progress with 5.16

The latest B::C package on CPAN 1.42 works stable for almost all perls until 5.14, but so far did not work good enough for the upcoming 5.16 release.

I couldn't even pinpoint to a specific perl change which caused the problems. I know that hashes need a different initialization now. Empty hashes need to declare

HvTOTALKEYS(hv) = 0

after creation, and readonly hashes must be set readonly after they were created.

DynaLoader and %INC handling is much stricter now with 5.16.

Building C/C++ libraries and applications with Module::Build‎

Alberto Simões will give a talk at YAPC::Europe 2012 described as

In this talk I will present the recipe I am using to build Perl Modules that depend on C or C++ libraries (and that ship those C or C++ libraries with the module itself).

The recipe uses a mixture of Module::Build custom building module, ExtUtils::CBuilder for C compiler interface, ExtUtils::LibBuilder to adapt some ExtUtils::CBuilder defaults that make standards library build impossible, and Config::AutoConf for externals libraries and headers detection.

This recipe has been used in a lot of different modules I maintain: Lingua::Identify::CLD, Text::BibTeX, Lingua::Jspell and the recent Lingua::FreeLing2 (still beta) and Lingua::NATools (still not released at the date).

Quantum-Relativistic Time-Travel in Lisbon

My brief visit to Portugal just expanded a little.

In addition to the two public classes we’re running (and, yes, there are still a few seats left for either day), I’m now also going to be delivering my infamous Temporally Quaquaversal Virtual Nanomachine Programming In Multiple Topologically Connected Quantum-Relativistic Parallel Spacetimes…Made Easy! presentation, as a free seminar next Thursday night.

This talk has already melted hundreds of geek neocortexes in both London and Oslo in the past fortnight; next week it will wreak its terrible destruction on Lusitanian minds as well.

So, if you’re in Lisbon, don’t miss out on my most brain-twisting talk ever. Thursday May 3 from 7pm at Edifício Fórum Picoas. Entry is free and everyone is welcome (though you do need to register to ensure a seat).

Damian

PS: My sincere thanks to SAPO for sponsoring this event.

LiveText is sponsoring YAPC::NA 2012, and they’re...



LiveText is sponsoring YAPC::NA 2012, and they’re hiring!

Looking for the Position that Fits your Work Style?  

Education is one of the most relevant topics in our nation, because it is important.  LiveText is doing forward looking work in education that is making a difference.  We’re looking for “difference making” people. If you’re a smart and energetic self-starter who would like to “make a difference” in transforming education, we want to talk to you!

By hiring top people and nurturing a culture that empowers and rewards those people, we are building one exceptional company.

Open positions include: 

  • Software Engineer
  • MySQL Database Administrator
  • User Interface Designer
  • Systems Administrator
  • System Architect

LiveText provides schedule flexibility, an open office environment, and a full benefits package that includes: Medical, Dental, Life Insurance, 401k, and Paid Vacations/Holidays.

 If you’re interested in any of the open positions, visit the LiveText booth located within Exhibit Hall B of the Job Fair and Expo. Resumes may also be forwarded to, “resume@livetext.com”.

[From the YAPC::NA Blog.]

Eclipse: Unable to locate companion shared library

Eclipse executable launcher error: Unable to locate companion shared library now includes my answer for when Cygwin's unzip utility fails (hint: use another unzip program).

Ninja Code

As this is only my second post—my first merely being a plug for a Damian Conway talk at my local Perl Mongers meeting—I thought I’d keep it short and silly.

At OSCON 2008, Amazon had a prominent booth advertising heavily that they were hiring. They didn’t want to hire just anyone. No, the question posed on the large sheet of poster board was, “Are you a ninja coder?” This was combined with a raffle, which as anyone who has ever been to a conference knows, is the most common tool used to get people to hand over their contact information. To enter, one had simply to look over some Perl code written out on that same poster board and tell them what it did. It looked a little something like this:

Alien::Base Perl Foundation Grant Report Month 2

After last month’s breakneck development pace, I knew this month wouldn’t be as gratifying, and indeed it turned into quite a slog.

This month involved lots of little bug fixes, posting dev releases to CPAN, then waiting for test results from CPANtesters. As a side note, there are a larger number of reports coming from Solaris and BSD than I would have expected. Sadly one of the bugs that still hasn’t been sorted out is this recurring Solaris bug when changing working directory. It would appear that I am going to have to find a Solaris box or VirtualBox appliance, since waiting for test results for every fix attempt would take far too long.

Perl for Big Data

Martin Holste will give a talk at YAPC::NA 2012 described as:

Hadoop is overrated.  Come see what modern Perl can do with map/reduce on terabytes of data with an extremely simple, maintainable architecture by orchestrating the inserting and querying of data on enormous scales.  This talk will deconstruct the Enterprise Log Search and Archive (ELSA) project which is fully written in asynchronous, object-oriented Perl and provides a framework for Big Data analytics in a modular, pluggable architecture with the flexibility and customization that only Perl can provide.

[From the YAPC::NA Blog.]

My definition of "stable"

I catch myself always saying, "No, not yet stable enough." I cannot release it, even though it passes all tests. Which you can interpret that the tests suck. Not enough coverage, bad testcases, ...

Well, that is always the case. You can never have enough tests. Problem is that in my case, the compiler, testing costs a lot of time. LOT of time! I usually spend a week to do the final release testing, but more often it lasts several weeks, because one round of test results influence the decisions of TODO, SKIP and mandatory PASSing tests, and then I'll redo the tests. On all versions, with all platforms. You could rely on cpantesters to do that for you, but it is better to do the most common combinations by your own. That's why I use perlall with a few hundred perls.

For Want of a Newline

Recently I had the pleasure of spending three hours debugging an obscure bug. An obscure bug I caused by introducing a newline. That little punk, 0x0A.

I released a new version of a command line program. For me, it’s an elegant piece of work, combining a marvelously complex-but-intuitive configuration for system administrators with an absolutely simple interface for users. To use the command, the user runs it with a couple of arguments and it prints out a single line of useful text derived from that marvelously complex configuration.

But, it doesn’t print a newline.

It’s never printed a newline. The original author didn’t include one for some reason. Anyone who has ever encountered a command like this knows well my irritation.

my awesome prompt> some_lame_command
my awesome prompt>e answer

Argh!

The workaround I’ve seen used, after seeing the above is to face-palm, then run the command again, only differently.

Post-mortem Linguistics in Zurich

For reasons I don’t entirely understand, it’s been quite a few years since I last gave a public talk in Zurich. Happily, we’ve been able to remedy that on this visit.

Digicomp run a regular seminar series entitled ”Open Tuesday” on the first Tuesday of each month, and I’m going to be speaking at that event on (no surprise) Tuesday May 8, from 6pm. Specifically, I’ll be giving my Fun with Dead Languages seminar.

The event is completely free, but they do need people to register so they can manage numbers correctly (just follow the “shopping cart” link on the Open Tuesday webpage)

Meanwhile, my various Perl-related classes at ETH are slowly filling, but there are still plenty of places left if you’re interested in some (entirely new) classes on Test-Driven Development, OO or API design, or optimizing your Perl development processes.

So if you’re in Zurich in early May, sign up for one (or more!) of my events. At very least, drop in to the “Open Tuesday” talk and see me do great and terrible things with ancient langauges.

Damian

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.