Skip navigation

Category Archives: Web Programming

For the past year or so I’ve been working on a new media poem called Black River Ghosts.  While the work is nowhere near ready to be presented to the public, I’ve been using some of its functionality on the social networks, and in a few spots these test cases/previews have been actually garnering praise.

Anyone familiar with my work in networked literature knows I have an ongoing fascination with poetry generators–applications that write poems based on datasets and randomizing algorithms. The motivations behind this obsession are very simple, if problematic on the theory tip: a good poetry generator allows the “author” to relinquish control; other than providing a dataset and some compositional templates, the generative poet does not compose the generative poem. The poem is instead composed by a combination of the underlying code and the reader’s initializing of the application.

I have more than a thimbleful of thoughts as to why this is a worthwhile paradigm for new media poetry, and why I often feel new media poets who don’t at least dabble in the margins of this paradigm might be missing some of the point of a networked literature, but those will be saved for a future post. Instead, I’d like to introduce you to a PHP framework that I’ve been using to create the piece, and offer some thoughts on how working in this way requires a different conception of poem composition.

CakePHP is rapid application development framework for creating web apps with PHP, and, though I’m very much a n00b as far as its use goes, so far it seems the best choice for building complex applications quickly and with as little code as possible. CakePHP leverages the Model-View-Controller design pattern to modularize the various components of a software project. This means that the application is coceptualized as having 3 layers: a model, which represents a data source; a controller, which encompasses the logic involved in working with the data from the data source; and a view, which is comprised of all the presentational or visual display functionality. MVC applications separate these layers into seperate files, thus promoting reusability and easy refactoring.

The benefits of using MVC are obvious; you can very quickly set up the bones of your app, and very easily extend and revise it. CakePHP provides a framework for doing this by favoring “convention over configuration”; by applying conventions to file names, database table names, and other assets, CakePHP provides a structure that makes simply creating and writng methods for certain classes build a rich structure for your web application.

I started writing Black River Ghosts with CakePHP initially just to get my head around how to use the framework. I already had the beginnings of a dataset; a file of distinct lines of text i’d started for the project. It became obvious very quickly that I could better make use of CakePHP and the poetry if I broke the lines down into records keyed by grammar. I tagged the poetry with parts of speech: nouns, verbs, prepositions. And then I started adding to the dataset, building a table of lines of poetry that represented (very subjectively) parts of speech to me.

As I worked, I became aware of how composing poetry like this, directly into a database, with the thought that each line, each unit, would go toward composing a sentence, is a fundamentally different way of composing poems linearly, as the popular conception of poetry has taught us. The form imposes some limitations; if you’re relying on “states of consciousness,” you must rely on them in targeted bursts, and you must keep in mind that what you’re writing will be combined and recombined with all of the other elements in the set.

The resultant text, though, definitely has a rush to it. Because I’m working with phrases instead of bare words, the sentences flood with a certain lyricism I’m enjoying. As algorithmically-generated text, these early tests of my code are yielding results I like.

Aptana StduioAs a developer, I’m pretty picky about my tools. The old debate about whether ’tis better to use a plain text editor or a full-fledged Integrated Desktop Environment was settled for me long ago; quite simply, I spend too much time with my head in code to do everything manually, as a plain text editor would require.  No, I have very specific requirements of my editing environment, which is where I spend the greater portion of my day: I need code-folding, brace-matching, an outline of properties/methods…

Early on I was a huge fan of the Eclipse development environment. Eclipse, it seemed, sought to be the swiss army knife of dev tools; though it was primarily intended for Java, it’s plugin architecture allowed it to be extended to develop in any language a plugin was provided for. This allowed me to use one application to write in multiple languages and idioms, which was just fine by me. Since the majority of my work is LAMP-related (Linux, Apache, MySQL and PHP/Perl), I found that Eclipse coupled with the PHPEclipse plugin was perfectly suited to the way I write code.

But the PHPEclipse plugin had issues, as I was soon to find out. The version of Eclipse in the Debian and Ubuntu repositories is old, and the PHPEclipse plugin has some issues working on these platforms. This was fine when I used WindowsXP as my primary Desktop OS, but when I started using Linux on the desktop this stopped me in my tracks. And while there are some fine environments out there for the Linux platform, I missed the ease and familiarity of my Eclipse interface.

Luckily, Aptana stepped in to fill the gap. Aptana can be downloaded as either a standalone application or an Eclipse plugin, and was built on the Eclipse platform. And Aptana is geared toward web development, offering a rich set of tools for working with HTML, CSS and Javascript. It’s very AJAX (Asynchronous Javascript and XML) aware; in fact, when creating a default web project in Aptana, you’re given the option of downloading and making part of your project many of the most popular and innovative Javascript libraries, such as JQuery and Prototype. And it fits my workflow snugly; not only do I have all of the functionality and extensibility of Eclipse at my disposal, but Aptana has it’s own set of plugins to aid in the development of PHP and Adobe AIR applications, and also features a very rich interface and code snippet library (featuring, thankfully, a whole range of snippets for editing .htaccess files).

Aptana, installed as an Eclipse plugin, works on both Windows and Ubuntu-another selling point for me. I run a dual boot system, and any opportunity to use the same software on both sides of my box is welcome.

Over the last two years, I, along with many another developer, have developed a bit of a man-crush on John Resig, the primary creator of the jQuery Javascript Library. jQuery has taken a lot of the pain out of writing cross-browser javascript, and replaced it with a much more intuitive syntax and a compressed idiom of expression that, to me, makes the chore of writing scripts that reliably work on all browser platforms much less debilitating.

This is an enlightening presentation by John on the challenges of scripting for the Document Object Model, or DOM, the conceptual framework that allows developers to work with documents in a dynamic way. This is particularly relevant to anyone who develops work presented in the browser. It’s interesting to note that many of John’s points have little to do with the DOM itself, as an abstract entity; it’s the implementation of the DOM by the different browser manufacturers that causes issues. While the Browser Wars are often declared over by many writers on the subject, it’s shocking to see some of the current inconsistencies dug up here. As the Web gains more and more primacy as information repository and communications medium, should the people’s access really be so shaped by market concerns?