Thursday, August 04, 2005

Babble: The Word Game Superchild of Boggle and Scrabble

Well I'm getting very little work done at the moment mainly due to this annoying addictive game: Babble: The Word Game Superchild of Boggle and Scrabble. The worst of it is, after playing it for a couple of days 'manually' the programmer in me forced me to see how good a solver I could write. Unfortunately it has turned out to be perfect so now I'm trying to find a way to get it to help me without giving the game away totally!

Wonder if there would be any call for a website giving stats and/or hints on today's puzzle?

Sunday, July 31, 2005

Bye bye, Cheetah

Well, over the last week I finally took the plunge and wrote my own templating system. It's semantically pretty similar to Cheetah, but using PHP-like <% %> syntax. It's working title is simply Blocks.

Basic features:
  • All the functionality from Cheetah is present.
  • Many of the useful tags from Django's template system are included.
  • Instead of Cheetah's compilation system Blocks uses in-memory partial compilation.
  • Each page and defined block within it each specify their own caching properties.
  • Cache parameters can include aging and dependencies on Python objects.
  • Caching works with inheritance and is fully hierarchical.
Okay, time for a simple example:
<% def blogEntry(entry) %>
<% depends entry.lastModified %>
<%? entry.contents %>
<% end def %>

<% for entry in entries %>
<div class="entry">
<span class="entry_title"><%? entry.title %></span>
<span class="entry_content"><% block blogEntry(entry) %></span>
<% end for %>

As you can see, pretty similar to Cheetah. The syntax is better in many ways - particularly as many HTML editors will happily ignore it as PHP code. The distinction between a tag and an evaluation has been made a'la Cheetah, although slightly more verbosely.

The cacheing system is the most important part of Blocks. The output of each page and 'def' block is stored by default and re-used for the next render. This can be controlled by the use of 4 tags within the block itself. No-cache speaks for itself, as does MaxAge. The age parameter for MaxAge however, is evaulated dynamically as so could change per render if necessary. The Depends tag allows cache invalidation based on either the output an evaluated expression or its lastModified property. Multiple caches may be present using the Varies tag, for instance to cache stats per user by varying on user ID.

I haven't implemented Django's filter system yet, mainly because I believe that most of it it just horrible syntax for calling a function. However, I can see a use for filtering the contents of a block - so that will be implemented pretty soon. It fits easily within the current design of Blocks.

My only disadvantage now is that I can't think of any reason to still be using Subway...

If anyone wants a copy or more info, let me know. I'll open if up if there's any interest.

Friday, July 22, 2005

London Sticks Up For Itself

Today terrorists attempted to copy their success in disrupting London, exactly two weeks after the original event. Fortunately, none of the 4 bombs seem to have detonated correctly, leaving some shattered windows but only one person injured.

Listening to the radio this evening I can help but smile at the determined attitude of the people of London today. From the DJ who just opened her show on Virgin Radio by saying "The bastards tried it again," to the many news reports of the public attempting to chase and pin down suspects running from at least two of the bomb scenes.

You have to realise, we've been through this before, and for a long, long time. The IRA terrorised London for years. It seems the more terrorists try to disrupt us, the more determined we get.

I should say I don't personally live in London, but not far from it. My brother lives and works there though, and I felt the traffic chaos two weeks ago. I also felt the wave of passion that swelled out from London over the days following the original event.

Let's hope that the positive attitude continues and the real people responsible are caught soon.

Thursday, July 21, 2005

Python Web Application Frameworks : Django and Subway

I've been looking around for a long time now for an application framework I can use to speed up my web development. At the beginning I was reimplementing all six wheels on my wagon but eventually realised that if things were to get any better, I'd have to build on what others have done.

After much searching and investigating I've found two interesting projects:

Django looks to be Python's nearest challenger to the over-hyped (IMHO) Ruby On Rails. Despite many nice features and a wonderful automatic database admin system, it also suffers many of the problems I see with Rails. The very features that make it look great in tutorials (or fancy videos) are the ones that make it infeasible for complex site development. In the beginning it's lovely to be told where to put your source files, or how to add simple authentication to your site. When things get tougher this these frameworks seems to become heavy weights getting in the way of what you need to do.

On the plus side, Django's template system includes many features that I had not seen before. Simple little things like a "cycle" tag that easily allows changing classes for alternating row colours are a great idea!

Subway is an effort to merge some powerful low-level tools (most notably CherryPy, Cheetah and SQLObject) into an easy to use high-level framework.

I had already looked at CherryPy quite a lot, and based my current development on it (a sports team organisation site). It's a great low-level framework that stays out of your way well. Coupled with my own integration of Cheetah, SQLObject and a home-grown forms library it was going well. Problem was, it wasn't very scalable and there were many things I felt I was lacking (especially in the template departement).

Subway makes the Cheetah integration as perfect as it can be. It ties in FormEncode very nicely and makes the whole lot just work.

Unfortunately, my application wants more. I've long been thinking about a template system that knows about the cachability of each part that makes up a page. Cheetah's compilation system is nice, but seem out of place after using them a while. I don't really need the timesaving that pre-compiling gives me, I need to be sure most of the webpage that will be served a thousand times isn't re-rendered at all, but just thrown out from a buffer.

So, regrettably, I've written my own template system. Fortunately to get to a working solution only took a couple of days part-time, and now I have a framework in which I can all all the caching cleverness that I need, plus all the lovely tags that I found so appealing in Django.

I'm now left with the dilema - am I using Subway at all now or should I go back to CherryPy raw?

Wednesday, June 15, 2005

Stuffers stuffing up the internet, one blog at a time

For a bit of randomness after a hard day's work I tried that there "Next Blog" link in the toolbar at the top of the page. Okay - some Hendricks site. I hit "Next" again, and I'm staring at a blog stuffer at work. Why oh why oh why! It's stuffed full of entries containing repeated text with almost identical links... Worst part is, because the links are in the entries instead of the comments there is probably no way that blogspot can (easily) cull them with the anti-stuffing tags offered by Google. Perhaps I'd better look elsewhere to put a smile on my face this evening.

Tuesday, June 14, 2005

Let the mindspew commence!

Finally, I've taken the plunge and got myself a blog -- be prepared to completely ignore all my drivel. So what am I interested in? Pah, allsorts. I'm a geek at heart with a job designing embedded software for military comms systems, but my interests stretch far and wide (but still geeky!). What sort of things will I write about? No clue yet, but they'll probably including but not limited to:
  • Software: All manor of topics - probably Python or .Net related:
    • Web dev frameworks, CMSs and that stupid super-hyped AJAX
    • Game dev frameworks, physics simulation
    • AI, neural nets, genetic programming, artificial life
    • General M$ bashing
  • Hardware: Anything that catches my eye
    • Robotics, ickle processing modules, generally cool stuff
    • New processor tech, cool cases, silent systems
  • Crap: Erm, yeah, I talk crap too...
    • Open source - news, cool projects, my contributions
    • Politics - European software patents is a far as my political views go, besides the odd comment on the stupidity of our politicians.
  • Me? Maybe, you never know.