Older blog entries for chromatic (starting at number 213)

When It Works, It Works:

After wondering exactly what poor Greg Lapore was doing when he asked, innocently enough, "Why am I receiving an error message when I try to write a demo file from SDL::Tutorial?", I realized that it's because Pod::ToDemo 0.10 was irredeemably broken.

I have no idea why it seemed to work for me, but a bit of diving into the scary details of what happens when at initialization time, a bit of interface redesign, and a few more tests later, and the new Pod::ToDemo scheme in 0.20 is a little uglier for the end-user, a lot simpler for the basic, default case for the coder, and, most importantly, a working release.

Of course, you'll need the latest SDL Perl snapshot for the updated tutorials, but they're there and work now. Hopefully Dave will soon pull the patches for the new release he's threatened.

Saving Unicode Characters as Screenshots:

I have a small project that requires extracting several Unicode characters from a Word document as uncompressed high-resolution screenshots. The only problem is that I don't have Word -- nor do I run any operating system that can run Word.

Has anyone solved a similar problem? Are there any COM gurus who know the magic invocations to dump a few dozen Kana characters to images? I suspect a decent hacker could do this in 15 minutes or so, much better than the 10 hours it would take -- if I had the tools -- to convert these manually.

Drop me a line at chromatic at oreilly dot com if that's you.

Make Small Things Easier:

I spend a lot of time sending and receiving versions of articles via e-mail. These tend to be small, generally on the order of 2000 words. I like to think of myself as a good editor, being able to improve the wording and organization of things. Still, several authors want to make changes, which is fine -- many phrasings are a matter of taste and some pieces of technology and code change for the better before final press time.

Then there are authors who make larger changes. It's easy to say "Can you change this sentence here and this word there?" It's a lot more difficult when the author moves paragraphs around and reformats the text.

Oddly, this problem almost disappears on larger projects, such as books. (See The Making of BSD Hacks.) My theory is that you'll go crazy trying to merge all of these little details on a project like this.

Why isn't a similar solution viable for articles? They're too small! The overhead of setting up a repository with authentication is too big to be useful for a maximum of three or four revisions of a 2000-word article.

Does the overhead have to be that great? I don't think so. The overhead of setting up a mailing list that lasts a week for a dozen people and two dozen posts used to be too high to be worthwhile, but Mail::SimpleList shows one way to avoid that.

This subject bears more thought. There may be a general principle here.

No Compiler, Please:

I was thinking a bit about Parrot NCI this afternoon. I usually describe it by talking about C's calling conventions and Parrot's calling conventions and then explaining that you can generate the thunking layer beforehand as you know C's calling conventions won't change. That is, a C function that takes two shorts and returns a long looks the same to the thunking layer no matter what library it's from. You can compile it once and let it do its magic for any library function whose conventions it understands.

Then I realized that I had never previously realized that Perl 5 also has calling conventions. Sure, they're a lot less strict than Parrot, but any function that passes three scalars and returns one does the same stuff to the stack.

I bet porting something like NCI to Perl 5 wouldn't be very hard. Certainly it'd be nice to replace the simpler bits of XS with something that doesn't require end users to have a compiler. Complexity does increase rapidly, but there's enough regularity that you can go quite a ways.

Just Do Something:

I've been experimenting lately with task lists, both at work and away. Since I have dozens of little things to keep track of in the next three months (roll on October!), only luck would have kept me on top of things.

Of course, being prone to yak shaving, I wrote a program to keep track of these tasks. Go on and laugh, I'll wait. Ready? It works phenomenally well.

I've mentioned how much I like Maypole. I've also always admired the way Ingy makes the installation and configuration experience easy, as exemplified by Kwiki. I've tried to do the same thing with the new installer for Everything, though that's a work in progress.

Anyhow, since I run Maypole through Jellybean to power my task manager, I've been doing a bit of work on Jellybean lately. In the spirit of my new goal to Just Do SOMETHING, I wrote Jellybean::App to simplify configuring and running a Jellybean application. It still requires you to know a little bit about how Jellybean works, but once you understand that there are servers that listen for incoming requests and named containers that respond to requests, you should find this much easier than writing a little driver script.

For example, the Jellybean::App-enabled launcher for my task manager has around four lines of code and around ten or so lines of configuration data. That beats some twenty-plus lines of code. It also gives much better diagnostics when you do things incorrectly; that by itself is a major improvement.

Sure, it's syntactic sugar, but it's quite a bit easier to explain and it took me under two hours.

The Hacks of July:

This is the last day of a three-day weekend. It's always nice when a federal holiday falls on a weekend, as enlightened employers tend to make the Monday or Friday a holiday to make up for things. In one sense, I really should be finishing the book before OSCON, but in another sense I'll be a better editor having taken several days off to rest and recuperate.

Instead of working on the book, I did some hacking. The more I use Maypole, the more I like it. Part of the benefit is familiarity. It's fairly easy to do simple things, but difficult things aren't that difficult when you understand how things work.

For example, I'm having great success with my article manager database. It's even more practical now that I added an alternate view template that fills in a contract for the author. Filling in the fields manually isn't time-consuming, but it surely is tedious. Now it's just a click away.

Of course, I don't particularly want to run a web server loaded with little db-backed applications all of the time; I'd rather launch a program when I need it, fiddle around a little bit, and close it when I'm done. That's doubly-true when I'm on the go with my laptop.

That was originally the theory behind Jellybean, anyhow. I'm easily distracted though and had several other projects demand my attention. Still, the basic idea is solid and the program works.

For kicks, I wrote Jellybean::Container::Maypole to run Maypole apps under Jellybean. Maypole's installer doesn't quite like this, as it still assumes you're using Apache and mod_perl. It works, though, so I can run article_manager to launch a dedicated web server and a new tab in my browser and go about my business. Add in SQLite to make something really powerful.

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?

204 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!