mikepk.com about current projects contact

GrazrScript v1.2 Beta

March 20, 2007

GrazrScript has taken a pretty major step today, we've released a new version that integrates procedural scripting! We're continuing to keep GrazrScript in Beta but this is such a significant development in the functioning of GrazrScript that it needed a new major functional revision number, so I'm proud to announce GrazrScript 1.2 Beta.Marble1.2.png

When Adam and I originally talked about the vision for GrazrScript we started by imagining an entirely new programming language designed from the ground up specifically for feeds. After spending time fleshing out our vision we realized that in designing a programming language we'd be re-implementing a lot of language features that weren't feed specific but necessary for a useful programming language. Did we really want to worry about new syntax, how to do loops, and burning a lot of our startup time on the necessary details that weren't really new functionality?

We realized that the procedural and object oriented programming could be done with an already existing programming environment like JavaScript. The more we thought about it, the more a natural fit JavaScript seemed. JavaScript is a robust and interesting programming language, is gaining lots of new users, and it already exists in an embedded environment (in a browser in script segments inside (x)html). By embedding a server-side JavaScript interpreter we realized the we could add the feed specific behaviors we wanted and build upon an existing fully-fleshed-out programming language. The team did a great job adding a Mozilla open source JavaScript interpreter to handle our own embedded procedural code. Using this we now have access to all of core JavaScript version 1.5. We also integrated it with the existing substitution logic that GrazrScript already handles. Using the field substitutions in the existing model, they become global variables inside the script block so you can operate on them.

We decided for both simplicity and symmetry that we would follow the same model as when embedding scripts inside HTML, for GrazrScript procedural code we use script blocks inside OPML to handle our scripting environment.

newrings_cassini_small.jpgOne application I've wanted for a while is a simple way to browse the NASA Astronomy Picture of the Day, a site I like but don't look at everyday. I wrote a small chunk of Javascript to take the current date and create links to the last X days worth of APOD pictures. Using a launched widget, I can quickly scan through all the latest images.

Here's the code I wrote, notice it lives inside a namespace escaped <script> tag just like javascript inside HTML. I use the core JavaScript object for Date and a simple loop that's based on a user input from a form. I know the URL pattern for the APOD images so I created an auto link generator based on that pattern. This isn't a feed application exactly, but it does highlight some of the other uses that OPML and outlines can have as well as our JavaScript integration.

To get the full effect, launch the Grazr into it's own window and have it control another page that shows the images.

We've updated our GrazrScript tutorial with details about this new release. There are several new sections discussing the specific additions of the procedural code integration. These include a procedural GrazrScript overview, script error handling, our internal outline object and methods, as well as some details on our integration with Javascript and what's currently available. Check it out.