Older blog entries for chromatic (starting at number 207)

Happiness Is...:

Happiness is ... free wireless in your hotel room.

Of course, if your laptop has a metal case and the wireless is in the lobby and, while your room is the one closest to the lobby, it's not really that close to the lobby and you have to have your laptop slightly sideways on the desk and keep adjusting its orientation to make it work stably, it's more Advanced Happiness Substitute than anything else. Oh yeah, and the "having to be in a hotel room instead of my nice comfy house" isn't exactly happiness either. Still, free wireless and the kind of quiet that lets me code for a couple of hours uninterrupted isn't so bad.

On the other hand, I keep running into limitations in both my knowledge and the capabilities of the software I'm using. That is a sign I'm on the right track.

This Parrot Plays Games:

Having promised to talk about Parrot SDL last night, I did indeed talk about Parrot SDL last night. It was a rambling talk through the whys and hows of Parrot, SDL, NCI, and, finally, Parrot SDL. As usual, you can look at my Introducing Parrot SDL slides online.

When you're finished with that, gaze in awe at my Parrot SDL homepage, download a snapshot, and try this out on your own.

(As you might expect, a recent checkin accidentally broke my style of method calling. I tried to debug it yesterday, but couldn't track it down to any one thing in time for my talk. It is a little tricky to demonstrate any graphical examples when method calling's broken. Fortunately, I figured out exactly what was failing this morning and the patchmonster fixed it nearly immediately. That guy scares me in a good way.)

If games aren't your style, Dan's Building a Parrot Compiler article went up today. Hmm, you'd think someone planned it that way.

Parrot SDL Objecty Goodness:

As seen in today's earlier Introducing Parrot SDL weblog (yes, that's my work weblog with a four-year old candid photo), I'm porting the existing Parrot SDL code to use real objects. Parrot barely had object support when I started this again several weeks ago. It's much nicer now.

After ninety minutes of hacking, including writing a small patch to improve subclassing exception messages, I can now load and display images and handle multiple surfaces simultaneously. Animation support is very near.

It's surprising that not only is PIR growing more and more familiar, but that it has workable idioms. Very few people have done or are doing anything large with the language, so I'm blazing a trail. How cool is that?

It's also surprising how nice the actual working code is. The bulk of the code in my example actually sets up parameters. Even considering that, aside from some function and method call sugar, you can only have one operation per line, this is surprisingly compact.

I still plan to port the two existing examples to the new code before checking anything in, but here's a followup to the blue rectangle example. This version displays the now-familiar Parrot logo.

.pcc_sub _main non_prototyped, @MAIN
	load_bytecode "library/SDL/App.imc"
	load_bytecode "library/SDL/Rect.imc"
	load_bytecode "library/SDL/Image.imc"

.sym pmc app .sym int app_type

find_type app_type, 'SDL::App' new app, app_type

.sym pmc args new args, .PerlHash set args['height'], 480 set args['width'], 640 set args['bpp'], 0 set args['flags'], 1

app.'_new'( args )

.sym int rect_type .sym pmc dest_rect .sym pmc source_rect

find_type rect_type, 'SDL::Rect' new dest_rect, rect_type new source_rect, rect_type

new args, .PerlHash set args['height'], 100 set args['width'], 100 set args['x'], 270 set args['y'], 190

dest_rect.'_new'( args )

set args['height'], 56 set args['width'], 100 set args['x'], 0 set args['y'], 0

source_rect.'_new'( args )

.sym pmc image .sym int image_type

find_type image_type, 'SDL::Image' new image, image_type

image.'_new'( 'examples/sdl/parrot_small.png' )

app.'blit'( image, source_rect, dest_rect ) app.'update_rect'( dest_rect )

sleep 2

app.'quit'() end .end

Death of a Thousand Little Bugs:

Well, perhaps death of three little bugs anyhow.

Today, after work (and don't talk to me about reviewing copyedits; it was hard to imagine anything more tedious than cleaning up a manuscript before submitting it to production, yet it exists!) I wrote up a patch to fix a header-including problem in SDL Perl. I have yet to hear if that works.

For my next trick, I went through the huge multi-thousand line patch of changes from the SDL Perl repository to the latest release, applied the smaller and less risky changes, and divided the rest into individual chunks. All tests still pass here.

With that work out of the way (hey, applying patches is fairly easy, it was breaking that huge diff into manageable chunks that was such a psychic barrier), I next bundled up Test::MockObject::Extends with Test::MockObject and uploaded a new version of the latter to the CPAN. T::MO::E will make your life easier or double your money back.

Finally, instead of sneaking around behind the backs of my absent buddies and playing Crystal Chronicles solo (and it's better in teams), I fixed a known bug in Mail::SimpleList that caused bounce messages and errors. On top of that, I improved the unsubscribe message slightly. Hey, since this software helps finish the new Perl 6 and Parrot Essentials book, it's important. Please upgrade, if you're running this code. (If you're not, you probably should be. At least, you could be.)

This weekend's trick will have to involve some Parrot SDL hacking, or else next month's PDX.pm meeting will be quite dull. Fortunately, my rather unplanned month-long hiatus meant that the fabulous Jens Rieks found all of the nasty bugs and corner cases in objects, libraries, and NCI, so they're mostly fixed and possibly even documented.

That, and writing a couple of Linux Desktop Hacks. Any GNOME writers in the audience care to join in?

Multipart Mail Hacks:

At the risk of finding a brown paper bag bug, I've released the latest version of my mailhacks modules. See my Perl projects page or wait for the Mail::Action 0.30, Mail::SimpleList 0.87, and Mail::TempAddress 0.56 to hit the CPAN.

Tomorrow's project? Test::MockObject::Extends.

(Mini-rant: Mail::Box is huge to pull in just for message handling, but it appears to work. It'd surely be nice if it were split into smaller pieces, though. I don't need IMAP, POP3, mbox, or maildir handling to parse a message.)

Mocking Parts of Objects:

The more I use Test::MockObject, the more I discover that I only need to mock small pieces of well-designed objects.

This came to a head today when I made the template() method of Jellybean::Response a little smarter. Instead of making repeated method calls to set individual pieces of template data, you can now pass a hash reference containing multiple pieces of data. That's less code! You can also request the whole template data in one chunk, too, but that's a separate issue.

My tests use a mock object to test that containers set template data correctly in the response object. After I improved template(), I converted one container to the new format. Suddenly, four tests failed. Since I'd mocked a template() method, the test code no longer matched the capabilities of the object it mocked.

Clearly, there was room in the world for Test::MockObject::Extends. So I wrote 52 lines of code (with liberal spacing and brace placement) and 44 lines of tests. More importantly, it required adding one line to the Jellybean test, changing another line, and deleting the not-so-accurate mocked template() implementation. Presto, all tests pass again.

I seem to promise to add documentation and post the code quite a bit lately, so replay the last few messages.

Oh yeah, dissatisfaction with the state of the world is great when it motivates me to improve things that need improving, but I originally set out today to add two small features to my article managing program. Of course, that lead me to make the templating simpler there, which lead to me refactoring and adding one nifty new feature to the Jellybean templating system.... So that's why I rarely finish anything. I'm too productive.

Vacation? Well, Not Really:

Due to a major family emergency, I'm spending the week with my parents. While that means spending time on family business -- and most definitely not on my usual work -- it does leave some other time for hacking and such.

Yesterday, I hooked Class::DBI to SQLite to Jellybean. (Yes, the latter really needs a release soon.) This isn't an academic exercise; I need a better solution to manage authors and articles. Now I have a database hooked up to a personal web server that lets me view, create, and edit author and article status information. It's a small step to write and send contracts automatically. It'll also be nice to have an API to our publishing system at work, but one step at a time.

Today, I ported Mail::Action (parent of Mail::SimpleList and Mail::TempAddress) from Mail::Internet to Mail::Message. This simplified the code slightly. More importantly, it will handle better multipart messages. I need to add a couple of enhancements, especially to signature handling, but now it's possible to send and receive attachments. Very handy. These'll probably hit the CPAN in the next couple of days as I revise the documentation.

Tomorrow or Friday I ought to port SDL Parrot to the new object system. I'm waiting for Leo, Dan, or Melvin to add the nice IMCC shortcuts, though. It's terrible being an early adopter and a trailblazer.

I also have some minor patches to Text::WikiFormat lying around. Oh, and there's SDL Perl stuff to manage, too. Still, progress is progress.

On Technical Writing: Gerunding It Up:

Some days, I'm tempted to propose a book on effective technical writing. Then I realize that my editors could produce examples of my bad prose. Also, the writers I work with are overwhelmingly quite nice, intelligent, and fully capable of fixing most minor issues with better feedback.

Still, it's nice to believe that the world is a better place for me having changed a heading from "Using $application To $verb $task" to "$verb-ing $task".

What's important? Is it the tool? In this case, no. It's getting something done. How is less important than what.

You have limited space in headings. Use it wisely.

Open Source Spyware:

I've not really looked, but open source lags behind proprietary software in the spyware category. Someone should rectify this as soon as possible. I propose the Open Spyware Project to create homepage hijackers, ad servers, and spam zombies.

Granted, we'll have a bit of a battle convincing users to download and to install our software. We'll also have a hard time dealing with anti-spyware programs -- especially the proprietary ones. I'm not sure how many Linux distributions will pick up the code. I'm pretty sure we won't see *BSD ports or packages any time soon.

Still, it will be nice to pit the security of open source code against proprietary code.

Your reward for reading this far is my admission that I'm completely joking in the first paragraph. I reserve the right to mock anyone who thinks I'm serious. (Yes, I lament the death of good satire.)

Ahh, Inexorable Progress:

(Yes, I am aware of the synonym inflexible.)

After two more bits of hacking, events work with SDL Parrot. That is to say, I can move the little parrot logo around on screen by pressing and releasing the cursor keys. I can even shut down the program cleanly by pressing Escape.

Okay, so it's a little grotty and not documented. (You'd be impressed by the rest of the documentation, however.) True, I can only detect five keys (up, down, left, right, and Escape) and I make no distinction between key up and key down events. Of course, two hours ago, I could barely report a key detection. This is progress.

There are two ways to detecting keyboard events. One is to pass a list of events and callbacks to a loop. The other is to process incoming events and run through the state machine yourself. Since I like first-class functions so much, I went with the callback approach.

Since I'm writing examples at the same time, the necessary abstractions are beginning to appear. It may be time to delve into PIR object syntax. I'll have something really cool to show off by the time OSCON rolls around.

198 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!