« Moving | Home | Tech Frustrations »

Typical Blog Entry and Mason

By Jacob Cohen | August 24, 2005

So this entry is more like a typical blog entries than any I have done in the past. For one thing, I can’t stop reading this comic.

I am playing with the notion of redoing some portions of this site using Mason, a perl-based web site language similar to PHP or JSP. Part of the motivation for doing this is that I never really got into PHP too deeply. When I began using it, back in version 3, it was lacking some major features which were later bolted on. Some of these were done in a funky way in order to maintain backwards compatibility, and others threw compatibility out the window and went ahead and substantially changed existing APIs.

Some of each of these types of changes would accompany each new version of PHP, which would come out about once every two weeks. It was a headache just trying to keep a web site up and running across PHP version upgrades. As a result, I haven’t really followed PHP through its development in versions 4 and 5. On the other hand, I already know perl very well, so development in Mason feels more natural.

I’ve written the layout engine, which once stripped of blank lines and comments, is about thirty lines of perl code. It takes an array of data, and a nested hash/array description of how it should be layed out. This layout is converted into a single top-level grid (no nested tables are needed) and then the data is populated into the grid via a display callback. It cleanly seperates the layout logic from the data. To modify how a page looks, I just need to modify the layout descriptor structure. I don’t even have to touch the layout engine code, or the data itself.

Topics: General |

Comments

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word