flightwish.com update

First off, a big thanks to for his post that led us to some really excellent Web 2.0 graphic design tutorials and such. It was timed perfectly since we had just begun the exercise of mocking up the new site design. I’ve climbed into JavaScript and have added several new scripts that will make the site much easier to use. Our web designer is hard at work producing the graphics we will be using in the site, so far it’s looking really good. I’m really looking forward to climbing into the HTML, but there’s a scheduled power-outage in the are for the whole of tomorrow while they work on long distance power lines. So tomorrow will probably be a picnic in the forest sort of day. Here’s part of the new flightwish.com logo, just for fun 🙂 :

Sometimes something blindingly obvious strikes me

A while back I made EoD SQL Query objects pool friendly if you construct them with a DataSource (which is the preferred way of doing things). This has a very interesting side effect, since now instead of:

UserQuery myQuery = QueryTool.createQueryImplementation(UserQuery.class);
User myUser = myQuery.getUser();

You can do something really cool:

public interface UserQuery extends BaseQuery {
    public static UserQuery QUERY = QueryTool.getQuery(UserQuery.class);

Since the Query automatically closes any Connection when it’s finished being used, and they are totally thread safe, this is a much much better way of doing things. The “getQuery” method was added this morning as a shorthand for “createQueryImplementation”. In other news, there is a new version of the software.

More Flightwish.com (Our secret project)

I’ve just started some rather major surgery on the flightwish.com code base. For the launch at the end of the month we will be completely redoing all of the web look & feel. The current one still feels a lot like a “demo”, so we’re redesigning it into something that looks as great as it feels to use. I’m also in the process of overhauling the entire database layer, since the current one chews through far to much memory for my liking. It’s moving onto EoD SQL, with a very simple caching system I’ve been working on.

Keep a look out to see what comes up at the end of the month 😉

Embedded Database in the OS?

I used to hate databases. I really did. You’d never guess it today would you? 😛

The basic reason was: I didn’t actually understand them, and I couldn’t really code SQL. Over the past few years my use of databases has escalated dramatically, and with it: my understanding of relationships, sets and SQL. With my gain in understanding, I’ve formulated the idea that it would be really cool if the OS came with an embedded database. Each application can reference it from the same “location” (whether it be on the disk, an API, socket, pipe or whatever). Each application auto-magically gets it’s own database, and can check if it’s a “new” (unpopulated) database.

For games it would be great for stats gathering; for music software it would be great for collection management (Amarok uses SQLite); you get the idea. Once the application is uninstalled, it’s database is dumped and compressed. Archived databases are stored for say 6 months and then deleted (in case you re-install the software). Lets face it, storage on disk is cheap in most instances.

Part of these thoughts revolve around my ideas for the ideal OS, based mostly on Java (though probably native compiled for performance). Where the database could be a simple JNDI lookup for applications.

My new project launches soon!

A while back I was involved in a really revolutionary project. We were creating a pilot to demo to several major Venture Capital companies, but just as we finished the code, our intermediary screwed something up, and we wound up stranded with no money to continue the project. All involved were really depressed about it, and the project sort of faded from our minds.

A few days ago however, I checked out the pilot project and began work to take it from this “demo” phase, through to something that we will be launching in the next week or so. We own no less than 4 domains names for the project (all pretty much the same), and for the readers of my blog, I’ve got a few clues as to what we’re up to:

  • It’s sort of social networking
  • It’s very different
  • I get excited thinking about it (O.o)

I’ll give you one of the domain names, but it’s only got an “under construction” page (though we’ll be changing that as launch day get closer). Keep an eye out for this one, it’s gonna be really awsom: www.flightwish.com.

Extending @Annotations

I’ve been thinking for years (as I’m sure many programmers do): “If I designed a language, what would it be like”. As time goes on, I’ve come up with many ideas, but I find it interesting that several aspects have stayed the same:

  • C/C++/Java style syntax
  • Light weight
  • VM driven
  • Possibly even Java byte codes
  • Network friendly (move objects round a’la RMI / Serialization)

Last night I was thinking about it again, and particularly about Java annotations. I know many who hate annotation because they have been baddly abused already. I personally love them, but not everywhere, and not for everything. My main problem with annotations is that the actual meta-data, and the code that drives them are completely separate. What I want are: compile time annotations. Something more like:

public @class CachedResult {
    public void run(Node target) {
        if(target instanceof MethodNode) {
            MethodNode method = (MethodNode)target;
            if(method.getParameterTypes().length > 0) {
                throw new IllegalArgumentException("Bla!!!");
            ClassNode clazz = method.getDeclaringClass();
            String name = method.getName();
            String fieldName = generateFieldName(name);
            FieldNode node = clazz.createField(method.getReturnType(), fieldName);
            method.setName("_cached_" + name);
            MethodNode cacher = clazz.createMethod(method.getReturnType(), name);
            StringBuilder code = new StringBuilder();
            code.append("if(").append(fieldName).append(" == null) {");
            code.append(fieldName).append(" = _cached_").append(name).append("();");
            code.append("return ").append(fieldName).append(";");
        } else {
            throw new IllegalArgumentException("Bla!!!");

The above “annotation” would cause the compiler to rename the annotated method to “_cached_<methodname>”. The method would be invoked once and the result would be put in a field, which would be returned from then on. It’s a simple enough trick which would make life just that little bit easier. It’s also not terribly complex to put in a compiler. It’s simply a DOM style API for accessing the classes, fields and methods, and then being able to “eval” code into a method (also not challenging). The result: you can add new tricks to the compiler really easily.

Objects in SQL Databases

As a very long-time Java developer, and someone who has worked with many different databases (from embedded SmallSQL, to >600 table legacy Informix database, to a brand spanking new Oracle DB), I’ve also worked with lots of ways to get data in and out of the database. I’ve used JDO (in various forms), Hibernate, TopLink, my own home-grown mapping layer, direct SQL through JDBC.

I feel I can now say I’m fluent in SQL, since I’ve recently been writing SQL statements that span 20 or more lines. What i’ve come to realize is that when you put a major Object/Relational mapping layer between you and your database, you may as well be storing your data in XML files on the filesystem (having played around with both, I find that the performance is much the same). Rather use a true Object database where possible (for actually storing objects, the performance is much better than a SQL database).

The problem is that you are loosing all the power that sits in SQL. SQL is an incredibly powerful language, designed entirely for fetching and manipulating data. It’s not the performance of the mapping layer I’m concerned with, but the fact that you can no longer craft efficient SQL.

Summary: Use the right tools in the right places!

Vista is a Linux Clone (Screenshots)

I’ve come to the conclusion that Vista is nothing more than a Linux clone. I run Gentoo linux along side Win XP on my desktop machine; and Suse 10.1 on my Lenovo laptop. After trawling through the many lists of features that Vista has, and playing with the Beta editions myself, almost all of it’s new “user” features are clones of features that have existed in Linux for months, and in most cases years! I find this rather funny, since people will be paying for features they could have for free. Linux costs nothing! Absolutely nothing! In my experience of using mostly Linux for over 7 years, it’s an all-round better system than Windows. To begin, many people will be familiar with tabbed browsing, thanks to Firefox or Opera. I find most of my tabbed browsing these days in when copying files between two folders in Konqueror (click the image for a larger version).
Multi-Tabbed Konqueror
After using Linux exclusively for more that 4 years, and having to go back to running Windows (for work reasons), the first thing I did after opening Windows Explorer was hit the ‘CTRL-SHIFT-N’ keys (the shortcut to open a new tab in Konqueror). As you can imagine, I was rather frustrated when nothing happened. It’s one of those things: when you’ve used something for to long, you get used to it.

One of the biggest features of Vista (besides Direct X 10, which I will get to later on) is the Aero interface, and how wonderful it looks. I’m running KDE 3.5 at the moment (looking forward to KDE 4), and one of the wonderful things about KDE is that you can completely change the way it looks. Suse, Kubuntu and all other KDE based Linux’s come with any number of “Styles” (the look of the buttons, text boxes and so on) and “Window Decorations” (the title-bar; minimize, maximize and close buttons; and border of each window) for you to choose from (my personal favorites are the “Plastik” style with the “Crystal” window-decoration).

This morning, I finally got around to enabling the Composite extension on my laptop (just been to busy with work to do that). This enables hardware-acceleration for your windows, lets you fade them in-and-out they grow shadows, etc. etc. etc. All the lovely things that people will be paying for in Vista. Another cute note: Crystal has the Vista as one of it’s options (click the image for a larger preview). So if you wanted your Linux machine to look like a Vista machine… No problem!Crystal Button Options

So Direct X 10… The “big” question. Linux doesn’t support Direct X directly (hehehe). Wine and Cedega do a surprisingly good job of it though (having run many games under normal Wine, and often at better frame-rates than my friends get under Windows). To my knowledge, the 3D drivers for Direct X 10 are still in their infancy, where the Open GL drivers for Linux from Nvidia, Intel and ATI are very fast, and very stable (though my old ATI drivers don’t cope so well with my 64bit machine). Open GL has one massive advantage over Direct X. Where new feature to Direct X require a new release, Open GL supports extensions. This means that graphics card manufacturers can develop simpler drivers, and simpler drivers means better performance, and more stability. Simple as that (note: I have developed software mode, Open GL and Direct X 7, and 9 applications).

Now for some fun tricks that Linux has up it’s sleeve. Suse 10.1 (and many other versions of Linux) come with Beagle out the box. Beagle does to your hard driver, what Google does with web pages. Indexes them, and lets you search them very very fast. On my machine I just need to press ‘F12’ or ‘ALT-SPACE’ to get Beagles friendly search window pop-open. From there, I type something of what I’m looking for, and in generally less than a second I’m looking at the results. What I was looking for is almost always within the first 5 results.

Splits and Tabs in Konqueror
Konqueror has both tabs, and split-windows, to give you an idea of what this allows, check out this image (click it for the big version). In case you havn’t figured it out by now, Konqueror is like windows explorer, or the “My Computer” icon in Windows. What you’re looking at here is my “Work” folder in one tab, and the tab you’re looking at is my “Images” folder, along side Google. Konqueror is also a Web Browser, FTP client, and many other wonderful things.

Now, in not one of the screen-shots I’ve given so far, can you see just how cool Linux can be when you add all these cool bits together. Bare in mind, all the software can be found on the Suse 10.1 DVD, no extra installing or downloading required. Also note the little square icons next to my custom made (took me about 3 minutes) “Launch” button, those 4 little boxes are four virtual screens. A bit like “Tabbed Screens” if you like.

I don’t aim to convert everyone with this blog entry, but I do hope to raise the awareness of just how far Linux has come since the days of a white-on-black console based system. Linux is a high speed, highly stable, user friendly and easy to use operating system, and I han’t even scratched the surface of the features it has. If you havn’t tried it in the past 6 months, go grab a copy of Kubuntu or Knoppix and try it out off the CD. You don’t even have to install it to try it out, just put in the CD and reboot, when you shutdown Linux, your computer will reboot in Windows again.

Full Screenshot Full Screenshot

The wonders of Java 5 + Servlets

I love servlets. I love not having to use query strings. Servlets (done right) make web programming a dream. The problem is: Almost every servlet I write is mapped to a directory. I recently started working on a forum system (for fun), and with it, I’ve wound up writing a rather interesting piece of code. It maps the path info of your servlet to a specific method. Here’s the first bit of code from the “list forums” servlet:

public class ForumListServlet extends BaseServlet {
    private static final Integer
        NO_PAGE_FOUND = new Integer(1);

    public void init() throws ServletException {

    public void list(HttpServletRequest req,
        HttpServletResponse resp)
        throws ServletException, IOException
        String pageIndex = req.getParameter("pageIndex");
        int pageNumber = -1;

        try {
            pageNumber = Integer.parseInt(pageIndex);
        } catch(NumberFormatException ex) {
            forward(NO_PAGE_FOUND, req, resp);


So what this code shows is that if the path-info part of the URL (the part after the servlet path) doesn’t match the regex “/page.*\.html”(in Java notation), then send the browser a redirect to “/page1.html”. So if I mapped this servlet to “/forum/list/*” (which is where it lives in my forum app), and then entered the URL “/forum/list/index.html” I would get a redirect to “/forum/list/page1.html”. The “pageIndex” parameter in my HttpServletRequest (which normally reflects the parameters of the Query string (it still does… but also includes your extra path bits)) will reflect the part that is “${pageIndex} in my “@PatternHandler” annotation. If I don’t use the “ensureMatch=true” in my “@EnsureIndex” annotation, then the default “service” (and in tern doGet, doPost, etc.) will be invoked if a method with “@PatternHandler” cannot be found to handle a request.

The whole thing about “page-mapping” is just a convenient way to forward to the JSP’s that do the actual HTML rendering work. I make extensive use of JSTL, JSP EL and my own custom JSP tags, I don’t think I’ve had even one line of Java code in my JSP’s in ages. I love custom tags to much.

AJAX Ideas for Web 3.0

So I’ve spend the past few days coding a lot of JavaScript. Most of it does XMLHttpRequest’s back to a Java Servlet to fetch data, and update our database. I’ve run up against one major problem, and amazingly, it’s not getting the HTML and DOM side of things right. It’s got to do with debugging the JavaScript. I have been using a very good JavaScript debugger, but it’s really not enough. The main reason: different browsers treat their JavaScript differently, that and, the amount of performance variation between JavaScript interpreters.

Effects that look really cool of Firefox look terrible on IE. Maybe it’s the performance of the HTML rendering. Anyway, my solution:

Async Java And Dom

Basically, allow me to write:

<script language=”Java” src=”code.jar”></script>

and use a stripped down Java VM. Java already includes the W3C DOM API’s, and we can then (wow) make a real connection back to the server. This would allow for a more constant performance, and generally easier development. I just wonder how much of a mission it would be to embed a VM that deeply into the three major browsers.