Paul M. Jones

Don't listen to the crowd, they say "jump."

Damn Deserters

Via Instapundit, from L. T. Smash:

But let's put your personal considerations aside for the moment. After all, a martyr cares nothing for his own life. That is how you see yourself, isn't it?

When you were planning your dramatic "statement," did you think for a minute about how this would affect your shipmates? You are a fire control technician on the Sea Sparrow surface-to-air missile system. The Navy doesn't have a bunch of spare FCs sitting in cold storage. Your ship is going to the Arabian Gulf, and will have to pass through the "threat arcs" of Iran's Silkworm anti-ship missiles -- and in case you haven't noticed, we're not exactly buddy-buddy with the mullahs these days. The Sea Sparrow is a critical point-defense system for your ship. So your job isn't one that the Navy can afford to shrug off -- somebody else is going to have to do it.

One of two things is going to happen. Either your shipmates are going to have to pull extra shifts to cover for your absence, or -- more likely -- somebody from another ship is going to get emergency orders to take your place in the coming days. Maybe that person is married; maybe he even has kids.

And you pulled this little stunt just in time for Christmas.

When I was in Desert Shield / Desert Storm in 1990, we saw all sorts of this kind of behavior. Kids who signed up into the reserves were called to duty per their contract, and responded with "You mean I have to fight? I thought you were just giving me free money for college!"

They did whatever they could to avoid deploying to Saudi. The level of conscientious objectorship went up significantly in about two weeks, as did the pregnanacy rate among females both at home and in-theater (if you got pregnant, especially on a ship at sea, you got sent home) over the next six months.

Cowards and freeloaders the lot of them. No sense of duty, no sense of honor, no sense of commitment. They were happy to take the goods, but actively avoided returning their service. >:-


Savant 2.3.2 released

Savant sees a new release today, version 2.3.2. It's a bugfix release; the change notes are:

* can now use assign() to assign a null value by name (thanks, Michael Caplan)

* the dateformat plugin now correctly refers to named custom formats (thanks, maxim at inform-link dot co dot uk)

* added tests for named custom dateformat strings

In related news, it seems that Monte Ohrt (or someone using his name) of Smarty fame wanted to take issue with some of my comments about caching over at the house of Reverend Jim. Give Jim some traffic and see for yourself which point of view you agree with; when you're done, be sure to check out his photography work.

Finally, the Savant site has seen quadruple its normal traffic in the past 24 hours. Normally it gets about 1000 hits/day, but right now it's at 4000. Could it be that my new article for PHP Magazine on Savant has been released?

Savant is a template system for PHP that uses PHP itself as the template markup language. Savant has plugins, output filters, customized error handling, and allows you to hook in a compiler object to deal with customized non-PHP template markup. I call it the simple, elegant, and powerful alternative to Smarty.

Update: Looks like SitePoint Tech Times has a link to Savant, which explains the traffic increase. Thanks to Sean from #pear on IRC for the information, and thanks to the SitePoint folks for mentioning the project.

Update 2: At midnight: 6763 hits in 24 hours. Sweet. :-)



DB_Table: Pre-Defined Per-Query Fetchmodes

Ian Eure just provided a patch to DB_Table that is genius in its simplicity. While I have not tested it, the patch looks like it will cause no trouble. In short, in your predefined SQL queries, you can specify that the query should return in DB_FETCHMODE_ASSOC, DB_FETCHMODE_ORDERED, or any other fetchmode. For example:


// predefined query for a list of all rows
$this->sql['list'] = array(
    'select'    => '*',
    'from'      => $this->table,
    'order'     => 'some_column DESC',
    'get'       => 'all',
    'fetchmode' => DB_FETCHMODE_ASSOC
);

// predefined query for a single row
$this->sql['item'] = array(
    'select'    => '*',
    'from'      => $this->table,
    'get'       => 'row',
    'fetchmode' => DB_FETCHMODE_OBJECT,
    'fetchmode_object_class' => 'myDataObjectClass'
);

With that, you can call $dbTable->select('list') and get an array of rows, or call $dbTable->select('item', "id = '9'") and get an object of type myDataObjectClass.

This is only in CVS right now, as I'm trying to add various Oracle restrictions to DB_Table, but it was just too neat to not add in right away. Thanks, Ian Eure.

DB_Table is a PHP class to automatically create RDBMS tables and XHTML forms. It includes a "poor man's" data type abstraction wherein the database is forced to store date and time data in ISO formats, which means you do not need to do date/time magic on your queries before executing them (and you don't need to do magic on the return results, either).


Paying for Performance

The inestimable Rum Smuggler contacted me via private channels to point out Paying for Performance from the Marginal Revolution.

Every three weeks students are tested and if they improve they are paid on the order of $20.  Control groups are also tested.  Early results are very encouraging.  No other reform has anywhere near the bang for the buck as paying the students.

But that's ... that's so **easy**! Instead of paying the monopolist government school bureaucrats more, pay the kids.

Whiny nosy Mrs Grundy sniffs, "Outrageous; they should they learn for the joy of learning." In a perfect world, that's true -- but they must be taught the long-term joy with short-term rewards. If we must coax the thirsty to water with gold, then we will quench their thirst just as surely as if we had browbeaten them toward it with "it's for your own good, you'll thank me later" ... and maybe with more success.


Americans for Fair Tax

Visit the Americans for Fair Tax site right now. It's essentially a 24% national sales tax with a very high "deductible" (effectively, you don't have to pay it if you are at or below poverty level). Here's a thumbnail sketch:

The FairTax is a federal retail sales tax that replaces the entire federal income and Social Security tax systems, including personal, gift, estate, capital gains, alternative minimum, Social Security/Medicare, self-employment, and corporate taxes. The FairTax allows Americans to keep 100 percent of their paychecks (minus any state income taxes), ends corporate taxes and compliance costs hidden in the retail cost of goods and services, and fully funds the federal government while fulfilling the promise of Social Security and Medicare.

But what about the poor? They fare better under the Fair Tax than they do under the current system. Seriously. Read it and sign up.


YaWiki 0.18 alpha released

YaWiki 0.18 alpha is ready for download. The change notes are:

* updated to take advantage of Text_Wiki 0.22 and later

* configuration change: Text_Wiki parsing and rendering is much more configurable via [Text_Wiki_*] groups in Yawp.conf.php (instead of via the [yawiki] group)

* now supports RSS feeds for all pages in all areas, all pages in one area, or one page in one area

* yawiki::getPage() now takes optional $area, $page, and $dt arguments

* clicking on the "Revert" button when no date-time is selected now reverts to the most-current saved version

* cannot delete Main (or other default) area in area_list.php

* other areas in the wiki are automatically set up as interwiki sites

* acl.php area name list now shows a '*' wildcard

* there is now a "settings" link on area_list.php (clicking on the area name will take you to the page list)

One big deal is that you can configure Text_Wiki directly now, with all the new CSS options that Text_Wiki 0.23.1 has. Another is that public RSS feeds are available for the entire wiki, one area (all pages), or one page in an area. No RSS feeds for comments yet, because that's part of a separate project (Yet Another Comment System, or Yacs, which has until now been embedded in YaWiki in pre-alpha form).

With this release, I am willing to call YaWiki feature-complete for a 1.0 release. Keep the bug reports coming (there have been remarkably few, hope it stays that way) and I'll start commenting and documenting in earnest. With luck it can go beta over the next couple of months, then a stable release early next year.

YaWiki is a wiki-like CMS (or a CMS-like wiki, if you prefer) designed for collaborative documentation efforts. It is built from PEAR and PEAR-compliant components such as Savant, DB_Table, Text_Wiki, and uses the Yawp foundation for rapid application development.


Savant and The Right Reverend Jim

RevJim has a great critique on one of my many posts about Savant vs. Smarty. His analysis is accurate, fair, and open. You really should read the whole thing. In the mean time, here are some highlights of what I want to respond to:

As of a few verisons ago, PHPSavant has a compiled templates option. In the event that your security needs would keep you from allowing template authors direct access to PHP, you can author a PHPSavant template compilation class that will, when activated, convert template markup of your own design into proper PHPSavant template code.

...

Smarty has the advantage over PHPSavant because the template compiler and, therefore, the language of the template is already written. This means, first and foremost, that I don't have to write a full-featured, flexible template compiler like I would with PHPSavant. This also means, though this is less important, that users of differnet Smarty based applications can join forces to teach one another and lead by example when it comes to what Smarty is capable of. With PHPSavant, those authoring templates in PHP would be able to help one another. But the users of applications that employed PHPSavant with a template compiler would find themselves in less company.

He concludes, "if PHPSavant were to implement a template compiler that was as featureful as the Smarty template language and provide a means in which to request template compilation only if a template had been changed, Smarty would, unless there are any major speed differences, have no reason to exist whatsoever as PHPSavant would cover the needs of both the 'pure PHP template junkies' and the 'template tag sugar addicts'."

Jim, please tell me you didn't try to set me up for this one. :-)

Such a compiler already exists in basic form as part of the standard Savant2 distribution. It converts a limited markup, and only compiles when the template source has been modified. While not 100% locked down, part of the plan is to add a feature suggested by Joshua Eichorn to have the PHP tokenizer extension pass through the script to make sure only "whitelisted" PHP has been generated.

The markup is as follows:

Markup Action
{$this->var} Prints an assigned variable
{$var} Prints a local variable
{if (...): } Starts an if block
{elseif (...): } Starts an elseif block
{else (...): } Starts an else block
{endif} Ends an if/else/elseif block
{for (...): } Starts a for loop
{endfor} Ends a for loop
{foreach (...): } Starts a foreach loop
{endforeach} Ends a foreach loop
{while (...): } Starts a while loop
{endwhile} Ends a while loop
{['pluginName', $this->arg0, $arg1, 'arg2', ...]} Activates the plugin named 'pluginName' with an argument list
{* ... *} comments
{tpl 'template.tpl.php'} Includes a template

The markup is converted directly to PHP and matches very closely the PHP an author himself would write; the compiled PHP code is very clean and easy to debug.

While this basic example compiler is not as full-featured as the Smarty compiler, any basic functions that are missing can easily be added, if for no other reason than the codebase is much prettier (it adheres to the PEAR standard) and nicely object-oriented. Savant is also a lot lighter than Smarty, so there's less code to slog through.

Does this mean there's no reason for Smarty to exist? Certainly not; while I have no use for Smarty, that does not mean there is no use for it period. But the existence of this basic compiler, I think, goes a long way toward satisyfing some of RevJim's desires regarding a non-Smarty template system.

On a related note, Jim is dead-on about collaborative effort between users of different markups; because Savant does not dictate what compiler you must use, anybody can come up with any kind of markup they want. It would be easy for this to lead to chaos on the compiler front.

However, I see this as a strength, not a weakness. Because the compiler is separated from the core templating system, the "best" or "most useful" compilers can evolve separately from the core template functions. Different communities can write compilers to suit their particular needs, all while using the same core functions and plugin sets. Thus, you get the best of both worlds; a relatively static core package (top-down) that provides an easy, dynamic, and well-defined way to extend and enhance the functions of that package (bottom-up).

UPDATE: See the Savant2_Compiler_basic documentation for more information.

UPDATE: Jim responds! It's bloggy ping-pong! :-)


New Text_Wiki Mailing List

If you use the Text_Wiki package you can now subscribe to its dedicated mailing list at users-subscribe@textwiki.tigris.org.

One of the inconveniences of PEAR is that is has no package-specific mailing lists. Thus, if you want to talk about a specific package and no other, you have to get all the traffic whether or not it is related to the package in which you are truly interested. As I said, it's an inconvenience, but having it would be a nice touch. Thank goodness for Tigris. :-)

Text_Wiki is an object-oriented PHP library to parse wiki text and then render it into any of a number of formats. Each parsing and rendering rule is its own class, so you can add/change/delete parsing rules quite easily. Aaron Wormus gives it a favorable review (thanks Aaron! :-) and provides some example code on how to write your own rules at the end of PHP Barnstormer #15.