Life is in transition for me now. Two weeks ago, we got to bring our handsome baby boy home, and I haven't been sleeping much since (though more than Jen). On top of the sleep deprivation, however, comes more exciting news: I've been hired as a PHP Developer by Zend Technologies!
I was approached by Daniel Kushner in late July regarding another position at Zend, and was flown out at the beginning of August. While I felt the interview went well, I harbored some doubts; work got fairly busy shortly thereafter, and then, of course, Liam was born, and the interview went completely out of my head. Until about three days after Liam's birthday, when Daniel contacted me again about the PHP Developer position.
Work started yesterday, and I was flown to Zend's offices in Cupertino, CA, for orientation and to sit down with both Daniel and others to prepare for the projects on which I will be working. Thankfully, the job will not require that I move, and I will be working out of the 'home office' in Vermont when I return later this week.
The decision to leave NGA was difficult, but the opportunity to work with Zend is just too good to miss. I am honored to be selected by them, and hope this is the beginning of many good things to come.
I've been extremely busy at work, and will continue to be through the end of March. I realized this past week that I'd set a goal of having a SourceForge website up and running for Cgiapp by the end of January — and it's now mid-February. Originally, I was going to backport some of my libraries from PHP5 to PHP4 so I could do so… and I think that was beginning to daunt me a little.
Fortunately, I ran across a quick-and-dirty content management solution yesterday called Gunther. It does templating in Smarty, and uses a wiki-esque syntax for markup — though page editing is limited to admin users only (something I was looking for). I decided to try it out, and within an hour or so had a working site ready to upload.
Cgiapp's new site can be found at cgiapp.sourceforge.net.
Shortly after I wrote this original post, I figured out what the strength of Gunther was — and why I no longer needed it. Gunther was basically taking content entered from a form and then inserting that content (after some processing for wiki-like syntax) into a Smarty template. Which meant that I could do the same thing with Cgiapp and Text_Wiki. Within an hour, I wrote an application module in Cgiapp that did just that, and am proud to say that the Cgiapp website is 100% Cgiapp.
I picked up on this article on Friday, glanced through it and moved on, but noticed this evening it had been slashdotted — at which point I realized the author is the current CGI::Application maintainer, so I looked again.
At my first glance through it, it appeared the author was looking for a nice, easy-to-use pre-processor script for generating a site out of templates and content files. To that end, he, in the end, recommended ttree, part of the Template Toolkit distribution.
However, the real gist of the article — something that should probably have been summarized at the end — is that the author was looking for a free and OSS replacement for DreamWeaver's Templates functionality. This functionality allows a developer to create a template with placeholders for content, lock it, and then create pages that have the bits and pieces of content. Finally, the developer compiles the site — creating final HTML pages out of the content merged with the templates.
Now, I can see something like this being useful. I've used webmake for a couple of projects, and, obviously, utilize PHP in many places as a templating language. However, several comments on Slashdot also gave some pause. The tone of these comments was to the effect of, "real developers shouldn't use DW; they should understand HTML and code it directly." Part of me felt this was elitist — the web is such an egalitarian medium that there should be few barriers to entry. However, the webmaster in me — the professional who gets paid each pay period and makes a living off the web — also agreed with this substantially.
I've worked — both professionally and as a freelancer — with individuals who use and rely on DW. The problem I see with the tool and others of its breed is precisely their empowerment of people. Let me explain.
I really do feel anybody should be able to have a presence on the 'net. However, HTML is a fragile language: trivial errors can cause tremendous changes in how a page is rendered — and even crash browsers on occasion. The problem I see is that DW and other GUI webpage applications create, from my viewpoint, garbage HTML. I cannot tell you how many pages generated by these applications that I've had to clean up and reformat. They spuriously add tags, often around empty content, that are simply unnecessary.
The problem is compounded when individuals have neither time nor inclination to learn HTML, but continue using the tool to create pages. They get a false sense of accomplishment — that can be quickly followed by a very real sense of incompetence when the page inexplicably breaks due to an edit they've made — especially when the content is part of a larger framework that includes other files. Of course, as a web professional, I get paid to fix such mistakes. But I feel that this does everybody a disservice — the individual/company has basically paid twice for the presentation of content — once to the person generating it, a second time to me to fix the errors.
This is a big part of the reason why I've been leaning more and more heavily on database-driven web applications. Content then goes into the database, and contains minimal — if any — markup. It is then injected into templates, which go through a formal review process, as well as through the W3C validators, to prevent display problems. This puts everybody in a position of strength: the editor generating content, the designer creating the look-and-feel, and the programmer developing the methods for mapping content with the templates.
There's still a part of me that struggles with what I perceive as an elitist position. However, there's another part of me that has struggled heavily with the multitasking demands made on all web professionals — we're expected to be editors, graphic designers, programmers, and more. In most cases, we're lucky if we're strong in one or two such areas, much less passionate about staying abreast of the changing face of our medium.
It's now been confirmed: I'm a geek.
Okay, so that probably comes as no shocker to those of you who know me, but it's the little things that make me realize it myself.
I've been frequenting Perl Monks for a couple of years now, mainly to garner ideas and code to help me with my personal or work projects. I rarely post comments, and I've only once submitted a question to the site. However, I do frequent the site regularly, and the few comments I've put in — generally regarding usage of CGI::Application — have been typically well-moderated.
Well, yesterday I made a comment to a user asking about editors to use with perl. I was incensed by a remark he made about VIM not having the features he needed. Now, as I said in my comment, I've used VIM on a daily basis for over two years, and I'm still discovering new features — and I've used all of the features he was looking for.
This is where I discovered I'm a geek: my comment made it into the Daily Best for today, peaking around number 5. The fact that that made my day indicates to me that I must be a geek.
Oh — and VIM rules!
I've often suspected that I'm not a SQL guru… little things like being self
taught and having virtually no resources for learning it. This has been
confirmed to a large degree at work, where our DBA has taught me many tricks
about databases: indexing, when to use
DISTINCT, how and when to do
and the magic of
TEMPORARY TABLEs. I now feel fairly competent, though far
from being an expert — I certainly don't know much about how to tune a server
for MySQL, or tuning MySQL for performance.
Last year around this time, we needed to replace our MySQL server, and I got handed the job of getting the data from the old one onto the new. At the time, I looked into replication, and from there discovered about binary copies of a data store. I started using this as a way to backup data, instead of periodic mysqldumps.
One thing I've often wondered since: would replication be a good way to do backups? It seems like it would, but I haven't investigated. One post on the aforementioned Slashdot article addressed this, with the following summary:
Concise and to the point. I only wish I had a spare server on which to implement it!
I've had a few people contact me indicating interest in Cgiapp, and I've noticed
a number of subscribers to the freshmeat project I've setup. In addition, we're
using the library extensively at the
National Gardening Association in developing our new
site (the current site is using a mixture of ASP and Tango, with several newer
applications using PHP). I've also been monitoring the
mailing list. As a result of all this activity, I've decided I need to develop a
roadmap for Cgiapp.
Currently, planned changes include:
Version 1.x series:
stripslashes(the Smarty "function" call will be
param()bugfix: currently, calling
param()with no arguments simply gives you a list of parameters registered with the method, but not their values; this will be fixed.
CGI::ApplicationML brought up and implemented the idea of an
error_mode()method to register an
error_modewith the object (similar to
run_modes()). While non-essential, it would offer a standard, built-in hook for error handling.
$PATH_INFOtraversing. Again, on the
CGI::AppML, a request was brought up for built-in support for using
$PATH_INFOto determine the run mode. Basically, you would pass a parameter indicating which location in the
$PATH_INFOstring holds the run mode.
Version 2.x series:
Yes, a Cgiapp2 is in the future. There are a few changes that are either necessitating (a) PHP5, or (b) API changes. In keeping with PEAR guidelines, I'll rename the module Cgiapp2 so as not to break applications designed for Cgiapp.
Changes expected include:
Inherit from PEAR. This will allow for some built in error handling, among
other things. I suspect that this will tie in with the
may also deprecate
load_tmpl(). In the perl version, you would
instantiate a template using
load_tmpl(), assign your variables to it,
and then do your
fetch() on it. So, this:
$this->tmpl_assign('var1', 'val1'); $body = $this->load_tmpl('template.html');
$tmpl = $this->load_tmpl(); $tmpl->assign('var1', 'val1'); $body = $tmpl->fetch('template.html');
$tmpl = $this->load_tmpl('template.html'); $tmpl->assign('var1', 'val1'); $body = $tmpl->fetch();
(Both examples assume use of Smarty.) I want to revert to this behaviour for several reasons:
Portability with perl. This is one area in which the PHP and perl versions differ greatly; going to the perl way makes porting classes between the two languages simpler.
Decoupling. The current set of template methods create an object as a parameter of the application object — which is fine, unless the template object instantiator returns an object of a different kind.
Smarty can use the same object to fill multiple templates, and the
current methods make use of this. By assigning the template object
locally to each method, this could be lost. HOWEVER… an easy
work-around would be for
load_tmpl() to create the object and store
it an a parameter; subsequent calls would return the same object
reference. The difficulty then would be if
load_tmpl() assumed a
template name would be passed. However, even in
CGI::App, you decide
on a template engine and design for that engine; there is never an
assumption that template engines should be swappable.
Existing Cgiapp1 applications would need to be rewritten.
Plugin Architecture: The
CGI::App ML has produced a
namespace that utilizes a common plugin architecture. The way it is done
in perl is through some magic of namespaces and export routines… both of
which are, notably, missing from PHP.
However, I think I may know a workaround for this, if I use PHP5: the
__call() overloader method.
My idea is to have plugin classes register methods that should be
accessible by a Cgiapp-based class a special key in the
__call() method would check the key for registered methods; if
one is found matching a method requested, that method is called (using
call_user_func()), with the Cgiapp-based object reference as the first
reference. Voilá! instant plugins!
Why do this? A library of 'standard' plugins could then be created, such as:
Since the 'exported' methods would have access to the Cgiapp object, they could even register objects or parameters with it.
If you have any requests or comments on the roadmap, please feel free to contact me.
The new weierophinney.net/matthew/ site is now up and running!
The site has been many months in planning, and about a month or so in actual coding. I have written the site in, instead of flatfiles, PHP, so as to:
I've written it using a strict MVC model, which means that I have libraries for accessing and manipulating the database; all displays are template driven (meaning I can create them with plain-old HTML); and I can create customizable applications out of various controller libraries. I've called this concoction Dragonfly.
There will be more developments coming — sitewide search comes to mind, as well as RSS feeds for the blog and downloads.
After working on some OO classes yesterday for an application backend I'm
developing for work, I decided I needed to create a
BREAD class to make this
simpler. You know, Browse-Read-Edit-Add-Delete.
At first, I figured I'd build off of what I'd done yesterday. But then I got to
thinking (ah, thinking, my curse). I ran into the
BREAD concept originally
CGI::Application; a number of individuals had developed
CGI::Apps that provided this functionality. I'd discarded them usually because
they provided more functionality than I needed or because they introduced more
complexity than I was willing to tackle right then.
But once my thoughts had gone to
CGI::App, I started thinking how
nice it would be to have
CGI::Application for PHP. And then I thought, why
not? What prevents me from porting it? I have the source…
So, today I stayed home with Maeve, who, on the tail end of an illness,
evidently ran herself down when at daycare yesterday, and stayed home sleeping
most of the day. So, while she was resting, I sat down with a printout of the
non-POD code of
CGI::App and hammered out what I needed to do. Then, when she
fell asleep for a nap, I typed it all out and started testing. And, I'm proud to
say, it works. For an example, visit
my development site to see a
very simple, templated application in action.
I just read coverage of a panel of programming luminaries on Salon; the topic of discussion was about the state of programming. In the course of the discussion, the subject of Open Source came up. Several of the luminaries — which included architects of the Mac OS and Windows, as well as others — derided the community for basically reinventing the wheel, and wheels that need to be re-thought entirely anyways. One questioned, "Why is the idealism just about how the code is shared — what about idealism about the code itself?"
Andy Hertzfeld (who helped develop the original Mac OS) was sitting on the panel, and jumped in. He has been working with Eazel and Chandler in recent years, and thus has an inside view of open source. His initial comment: "It's because they want people to use the stuff!" Basically, they program Windows- or Mac-like interfaces because then people will be willing to try it out. They program office suites because people "need" an office suite to be productive. Such offerings hook them into the OSS movement.
Another participant, Dan Bricklin (of VisiCalc, a pioneering spreadsheet program) shared an anecdote from Bill Gates. Evidently, Gates gave an interview (with Lammers — look up this person) in which he explained that his work on MS's BASIC compiler was done by looking at how other programmers had accomplished the task. In his own words, "The best way to prepare is to write programs, and to study great programs that other people have written. In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating systems."
So basically, Gates was an early adopter of OSS methodologies… Interesting to see that today he's so protective of MS code. Guess money might do that to you.
I've been researching and coding for a couple months now with the decision that
I'd rewrite the family website/portal using
I still like the idea, but a couple things recently have made me rethink it.
For starters, the perl DBI is a bit of a pain to program. At work, I've become very accustomed to using PEAR's DB library, and while it's in many ways derived from perl's DBI, it's much simpler to use.
Then there's the whole
HTML::Template debacle. There's several ways in which
to write the templates, but they don't all work in all situations, and, it seems
they're a bit limited. We've started using PHP's Smarty at work, and it's much
more intuitive, a wee bit more consistent, and almost infinitely more
extendable. I could go the
Template::Toolkit route for perl, but that's almost
like learning another whole language.
Then, there's the way objects work in perl versus PHP. I've discovered that PHP objects are very easy and very extendable. I wouldn't have found them half as easy, however, if I hadn't already been doing object oriented programming in perl. One major difference, however, is how easy it is to create new attributes on the fly, and the syntax is much easier and cleaner.
Add to that the fact that if you want to dynamically require modules in perl,
you have to go through some significant, often unsurmountable, hoops. So you
can't easily have dynamic objects of dynamically defined classes. In PHP,
though, you can
include_once at any time without even
The final straw, however, was when I did my first OO application in PHP this
past week. I hammered it out in a matter of an hour or so. Then I rewrote it to
incorporate Smarty in around an hour. And it all worked easily. Then I wrote a
form-handling libary in just over two hours that worked immediately — and made
it possible for me to write a several screen application in a matter of an hour,
complete with form, form validation, and database calls. Doing the same with
CGI::Application took me hours, if not days.
So, my idea is this: port
CGI::Application to PHP. I love the concept of
CGI::App — it's exactly how I want to program, and I think it's solid.
However, by porting it to PHP, I automatically have session and cookie support,
and database support is only a few lines of code away when I use PEAR; I'll add
Smarty as the template toolkit of choice, but make it easy to override the
template methods to utilize . I get a nice MVC-style application template, but
one that makes developing quickie applications truly a snap.
This falls under the "right-tool-for-the-job" category; perl, while a wonderful language, and with a large tradition as a CGI language, was not developed for the web as PHP was. PHP just makes more sense in this instance. And I won't be abandoning perl by any stretch; I still use it daily at work and at home for solving any number of tasks from automated backups to checking server availability to keeping my ethernet connection alive. But I have real strengths as a PHP developer, and it would be a shame not to use those strengths with our home website.