OSCON 2003 Day Two

by chromatic

Related link: http://conferences.oreillynet.com/pub/w/23/tuesday.html

Tuesday was overcast and cool, though the west looked much clearer. I again rode the train in to town and hiked a few blocks to the hotel. Fortunately, I was on the train earlier and was able to grab a seat to write Monday's weblog.

The Speaker's Lounge was filled with people taking advantage of wired connections and a critical mass of people. The Fotango guys were all wearing hand-made Ponie shirts, though very few people actually knew what Ponie was then. (The Perl community knew Larry was announcing something, but more on that later.)

I sneaked in to Pragmatic Dave Thomas's "Ruby in a Day" talk. Ward Cunningham was there, writing three Ruby programs for every code snippet Dave demonstrated. I was highly impressed; though Ruby is a consistent and easy-to-learn language, Dave was speeding through things. In an hour, he'd gone from "Hello, World" with arrays to iterators, blocks, and advanced block use.

Lunch came next, so it was back to the Speaker's Lounge to talk again to Damian Conway and Allison Randal. I swept through the Exhibitor's Hall as it was being setup. The Perl Foundation has a booth, as does the O'Reilly Network (and I don't have to be there). The hall opens today (Wednesday), so go down, see all of the booths (I saw a couple of huge model rockets being wheeled in), and grab some swag.

The full-day tutorials ("Advanced OOP", by Damian Conway; "A Day of Extreme Programming", with Marty and Karen Pauley; "Ruby in a Day", by Dave Thomas). That afternoon, though, the Perl 5 Porters meeting was moved up to 3:30 pm, so I ducked out early and played Zendo with gamemaster Tom Phoenix for a little while.

The big news in the p5p meeting was the upcoming Ponie announcement. We discussed the idea for a little while and then discussed the public reaction. It's important to note that Ponie is not a complete rewrite of Perl 5. It's a port of as much of the Perl 5 internals as possible.

The really important bit is making Perl 5 use Parrot's PMCs. Perl 5's fundamental internal data structures are SVs (scalars), AVs (arrays), HVs (hashes), CVs (code/subroutines), GVs (globs), and so on. They're each defined in a header and a code file, as in sv.h and sv.c. These data structures are very C-centric; an SV is basically a struct. Given an SV, you can call functions defined in sv.c, such as sv_upgrade().

Parrot's PMCs are similar in a way but different in a way. It's easier to think of them in terms of actual objects, from an object-oriented standpoint. Each PMC holds a vtable of function pointers that can be thought of as methods. Instead of calling sv_do_something( sv ), you'd say something more like pmc->do_something().

The really nice part of this is that it removes a lot of special cases, especially switch statements within the functions themselves. If you need to do something a little different, just replace the function in the PMC's vtable. This gets rid of the need for Perl 5's "magic" that enables things such as tie(). Yes, PMCs are subclassible and inheritable.

I'm glossing over a lot of details here, but the important part is that by "simply" replacing SVs, AVs, HVs and their friends with the appropriate PMCs (which have mostly already been written), Ponie will reduce a lot of unnecessary complexity while reusing the important complexity — Perl's existing and working parser and lexer. (It was either Kurt Starsinic or Graham Barr who pointed out that that's at least half of the complexity of Perl 5.)

PMCs are also tremendously faster, as is Parrot's opcode dispatch — the basic code that handles the underlying Parrot operations. Because Parrot has a blazingly fast JIT compiler (that turns platform-independent opcodes into very fast, platform-specific machine code), most operations should be very quick.

The other really nifty part of the Ponie announcement is the plan to write an XS compatibility layer for Ponie. Several of the most important and complex Perl modules, including mod_perl and the DBI, have C and C++ components. XS is used as an interface between C and Perl. Because the internals of Ponie will be slightly different, there needs to be a way to do the same things with the new internals without having to rewrite lots of custom XS code. Since XS is pre-processed, this isn't impossible.

Perl 5.8.0 has a tremendous test suite that's only improved for 5.8.1 and the upcoming 5.10.0. It's written at the Perl level, so Ponie can use these tests to judge their progress. It's likely that Ponie will find bugs in Perl 5 and in Parrot that can be fixed for all three projects.

As the meeting wound down, Ziggy and Ask started filming their TPC video. Expect a lot of strange revelations from noted Perl hackers.

Tuesday night featured the First Annual States of the Unions addresses. Daniel Steinberg has written a nice feature about them for the OSCON coverage page — rather than duplicate what he wrote, just go read that.

ActiveState also hosted their annual party at a nice bar on the waterfront. I ducked out early to try to get to bed before midnight. Hey, it almost happened. See you tomorrow!