Javascript
FRIDGEMAGNETS 0.4
Following hot on the release of Right Now!, I've now finished the first draft of the Fridgemagnets client. This is a very (very!) rough draft with significant performance problems, especially under Firefox, a lack of rotational filters under IE, and is missing some major features: The ability to tweet your poem, the ability to reshuffle the word list, the ability to choose alternative word lists, the ability to bookmark your poem, the ability to put utility words back into the "play" list with a shuffle ('a', 'an', 'the', '-ed', '-ing', '-s', '-r'), knowing the difference between words and suffixes, tracking words by their reference and not the word itself (this confuses that 'is a poem' algorithm still). Also, I want to put some decorative flash on the page (credits, etc.), and I want it to be phone-ready responsive.
Fridgemagnets attempts (and mostly succeeds) at implementing a write-only DOM layer: once objects are on the board, I tried hard not to ask the DOM for positions or direction. Only under certain circumstances, such as a drag/stop event, do I need to ask the DOM "Where did that land?" Otherwise, I tell the DOM what I want it to know. This was mostly done for learning; I've read several different responsive design blogs where querying the DOM is the biggest time-eater in an app.
That doesn't mean this program is at all efficient. There's huge CPU wasteage in repeatedly querying and shuffling the lists of words and their bounding boxes in order to determine which ones are in proximity to other ones, which ones constitute "the poem," and so forth. I expect to be looking hard at the way these features are used, and fixing them as I can. Coffeescript isn't Haskell, and doesn't have Haskell's marvelous internal caching mechanisms.
One thing I am very proud of is my solution for the Separating Axes Theorem, which is a space-and-time efficient way of telling if an object is in collision with other objects. I'd never written anything quite like that before, and it was a pleasure to stretch my brain around a seemingly arbitrary geometry where everything is in the 2D plane, but the axes of projection are abstracted and their distance to the measured objects irrelevant. (It's also annoying that game programmers use the word "axis" for what is generally just a "line.")
I'm happy with the algorithmic description of "a poem," but not with some of the underlying querying of the list of words and their bounding boxes to determine what is and is not part of the poem. That's gonna take some more think. All in all, though, a very nice start.