PortLAMP Courses: Wednesday
by Daniel Smith
I'm beginning this entry in a full-up Rendezvous area, where a plethora
of power strips and decent wireless coverage happen to be in
the same place. My thought for the day, outside of all things
Open Source, is that we need wireless power. Sure, it might
be dangerous, but I've seen a couple of tripping over power cord
incidents that could have resulted in some serious amounts
of embarassment, and perhaps a hangnail. On a more serious
note, I really look forward to the day when laptops have
the battery life of (at least) a mobile phone, are quieter
than my cats in some tuna-induced stupor, and do not
double as portable heaters.
There are a lot of PHP sessions today, plus two keynotes (Tim O'Reilly
going over Open Source paradigm shifts, and Paul Buck of IBM
talking about Eclipse (an IDE on steroids). I'll come back
to Eclipse tomorrow, but will say I have a good first impression
A quick note/reminder for some: a lot of the talks are available off of the OnlineSlides page of the Wiki
Robert Kaye has a nice take on Tim's speech in his weblog. I won't repeat that here, but will instead share a couple of thoughts on the notion of "adhocracy".
Tim notes the term "adhocracy" from Cory Doctorow's book "Down and Out in the Magic Kingdom", defined as:
"Like-minded developers can find each other and work in ever-shifting groups"
He thinks of Usenet as "the mother of Open Source". Another big
influence has been a program by Larry Wall. Nope, not Perl, but Patch.
It used to be pretty common to download a multipart shell archive
of some package from a Usenet newsgroup, and to keep it up
to date by downloading patches from yet another newsgroup (and
applying them to the source with Patch). Even with all of this
clunkyness, sometimes having to wait for a daily UUCP connection
to get the latest newsfeed over the "company modem", there was
still a sort of thrill to see the new stuff in certain newsgroups.
We knew others were out there, somewhere, on the other end of
Getting back to Tim's keynote: the users started to talk to each
other over Usenet and mailing lists, and started to help build the
apps. Major apps commonly have key contributers from different
countries. Tim made the point: "networking is a key driver for
I think of the leaps made from the late 80's till
now, where WiFi is really starting to take hold, and wonder how that
will affect things. The mechanism for the collaborative process just
keeps speeding up, and has become ubiqitious in some places (how
will it change things when high speed access is available
I've been listening to how PHP can talk to Java and COM, how
to do web services in PHP, what Yahoo does with PHP, and
an intro to PEAR. It's easy after a few hours to enter
a sort of PHP Reality Distortion Field. Fact is though,
you Really Can do a lot with it!
John Coggeshall spoke about how to use the Java and COM
extensions to PHP to get at those environments from within
a PHP script. A large caveat, especially in the case of
Java, is that while this is a handy thing to do, it is
more of a "use an existing component" idea than "we
are doing this because we need blazing speed".
The ext/java extension allows PHP developers to get at
properties of Java classes. One example would be
to use a Java class to create a .zip file. A couple
PHP: Web Services
Adam Trachtenberg's talk on Web Services in PHP was a less theoretical version of Sterling's versionon Tuesday (it was good for me, as a newbie to this, to hear some things
again). Adam's definition of a web service is:
"A web service is a network access interface to an application,
built with XML, and usually HTTP".
...or another way to think of it: Standardize the way you get data back and forth.
PHP: The Yahoo Performance Angle
Michael Radwin presented "One Year of PHP at Yahoo!" Yahoo has
been using PHP for a year, and in no small fashion. They get
232 million users per month, have 112 million active registered
users, and get 1.9 billion hits a day. They must trust PHP!
Michael had ideas in several areas as to how to use PHP on a very
large site. I will focus on the performance aspects:
scaling: Install an accelerator. With no code mods, you can get a dramatic increase in performance by having parsed pages cached in memory.
profiling: Write for functionality first. Use APD ("gprof for PHP"). Use faster PHP calls, such as
include files: try to minimize include files. Each one
results in several system calls (on the other hand, using an
accelerator can reduce the number of calls to one. Balance
performance and reusability. Keep your
abstraction: use abstraction sparingly. Don't add a bunch
layers, as it can be costly. OO is slow in PHP4, faster in PHP5.
Pear::DB, in particular, is aimed at a sort of lowest common denominator.
It adds a layer that gets hit with every call to your database. (remember,
I am just writing about Yahoo and their quest to maximize performance,
so do not send me comments suggesting I am an anti-OO heretic)
C/C++: Yahoo has about 70 extensions in C/C++ internally.
TRe code is highly specific for their own use, so they won't be
releasing it as Open Source. It's a big win for speed, and
interfacing with legacy systems. The downsides are all of the
usual (my quote) "why you would use scripting instead of
C/C++" concerns, such as memory management, speed of prototyping, etc.
PHP: Pear, PECL, and Open Licensing
Shane Caraveo of ActiveState
talked about the PHP Extension and Application Repository (PEAR). PEAR provides an OO class system for PHP packages,
and coding and versioning standards. It makes it easy to
install and update packages. It has a large developer community,
and the licensing is very open (a goal of PEAR is to make
it easy to use packages in the commercial environment).
What PEAR is to PHP classes, PECL is to C/C++ extensions.
Current PHP extensions that are part of the PHP4 distribution
are being moved to PECL. The sheer number of them has
complicated the process of getting PHP releases out (getting
all of the extensions synced up), so off they go to their
own package management universe.
Another acronym to mention is PFC. PFC is the PHP Foundation Classes.
They are held to a higher standard of QA and API design than
other PEAR classes. They are meant to be a core subset
that are used to bootstrap other classes.
Having a large collection of PHP classes is great, but what is
it like to install them on your system? The PEAR installer
has multiple UIs (CLI, Gtk, and a web front-end). It is
easy to do an inventory of clasaes you have, to grab
new packages, to update everything, and to uninstall them.
Of particular interest is a script you can get just by visiting go-pear.org. Go to the site, save the script, and
run php on it. It automates the process of installing PEAR.
To get started on the PEAR web installer, run from a command line:
% pear install PEAR_Frontend_Web