The everyday ramblings of an everyday geek.

Wednesday, November 30, 2005

Because I could

Slashdot heralded the release of the first fully working version of Jake2. This is a port of the Quake2 Engine for Java. Let me just say that again. This a Java port of Quake2!!!

I had to try it to see if it worked... and it does! Quake2 runs FAST on my iMac G5, really fast. According to their benchmarks they have got 95% of the speed of a pure C compilation, and my impirical tests show that to be correct. This is the same language that can't even get a user interface to run efficiently and here it is running Quake at breakneck speeds.

There are of course a few problems - garbage collection and JIT. The game has a tendancy to stutter, and this only happens when a new model is being used or when there are explosions, but as this is still a 0.9 release I guess there are still teething problems.

Quake2 sends me back to 1997, when my powerhorse was a PII 333MHz with 32MB RAM and Voodoo2. Which lead me to an obvious question... does it work on the beast?

Yes! I took exactly the same code, sftpd it to The Beast and started it from an SSH session on the iMac G5 and it bloody worked! It automagically scalled back the graphics to allow for the poor processor and memory, but it was a fully 3D rendered scene over SSH. I was gobsmacked.

This is a truely amazing peice of software and I think it could really open a few eyes in the gameing world. If you can run Quake2 in Java, why not Quake4? The advantages are obvious. Exceptionally easy multicore support, most memory issues can be forgotten, but most significantly write-once-run-anywhere. One coding effort can make your game available on everything from a PS1 through to a XBox 360. Porting would move from a coding exercise to a configuration tweeking exercise.

The barrier before was that performace was percieved as lousy. The Jake2 team have stood this on its head. Well done.

One thing its also got me thinking is... where is the Swing implemetation that uses 3D hardware?

Tuesday, November 29, 2005

Thanks for the memory

I've just contributed to a Slashdot discussion that diverged into a discussion about what is a sensible setup for web browsing, email and a little bit of office work. As a reminder to myself, I thought I'd go over it again.

There was a lot of waxing lyrical about how we used to do all the basic tasks on a 486 and a bit of string, but my recent experience with The Beast definitely makes me see the holes in that theory. Back in the day, the best way to improve performance of a 486 system, was to get the hell off the 486 and get yourself a Pentium, that or over clock the hell out of it. Remember, these were systems that operated at 66Mhz! Sure they felt fast, but that was because you'd just upgraded from 8088 at 8Mhz. It's not just that either, the 640k barrier was a force to be reckoned with. Few programs used more than that, and even if they did they rarely expected you to have more than 4 or 8MB RAM. Yes, you could load and run Netscape, and Eudora mail, put they were tasks that involved a lot of patience (not least because you were working at 28kbs (if you were lucky)). You upgraded every year or so, not because you wanted too, but because if you didn't you would throw the system out of the window as you feared you'd waste the rest of life waiting for the hour glass to disappear or a progress bar to move. With slow processors, floppy disks and no RAM IT moved at a different pace in the 80s and 90s.

It's a different story today. Unless you are doing something processor intensive like compressing a movie, playing a game, compiling some code etc., your processor will rarely get fully utilised. The only time you are likely to notice a real slow down is when your system starts to use virtual memory. This happens when your OS realises that it's about to run out of RAM, and moves the least accessed data back onto the hard drive. Hard drives, at least compared to memory, are slow and the whole computer slows down whilst the contents are moved over to HDD (and back again to RAM). In the good 'ol days we were used to it. The reason Windows 98 used to crash when you had too many programs open was because it was lousy at virtual memory (and any process could access another's data, but that's a different issue) and you instinctively kept the open programs to a minimum. Also, the OS was designed to assume that there was very little RAM available, as such they had a very small RAM footprint. This assumption is definitely not carried through to modern OSs. I checked the RAM use on the G5 and was shocked to see that even with no user applications open, I only had 256MB free from 1GB!

So what's my point? If you have a PII or higher, max out the RAM before thinking about an upgrade. Yes, new computers are a lot more powerful, but you are not going to stretch the processor with basic office apps, but you will max out the RAM with just two or three browser sessions open. The Beast is an excellent case in point. If I open Firefox on it from my Mac it works more than adequately. In fact, you wouldn't know it wasn't native, until you open one too many tabs, or windows and you start to hear the hard drive thrashing. The other way of looking at the problem is if your not planning on using a new PC for games etc., don't waste time thinking about weather its worth getting a P4 2.6GHz, or a P4 3.2GHz, go for the 2.6 and spend the difference on RAM. Also, 256MB of isn't enough, if you plan on using any modern OS, i.e.. something that will actually use the full power of your new computer, you need 512MB minimum, and really you ought to buy 1GB.

This isn't vanity, or bad programming, this is people who are sick of waiting for their computers. You can have a hard disk that's too big (most people will struggle to fill 2/3GB of hard disk with office and web downloads). You can buy a processor that's too fast, unless you actually know that what your doing is processor intensive the chances are that it isn't. But you simply cannot have too much RAM. Most motherboards can only support 4GB of RAM anyway, and unless you have a research or development budget to burn you probably can't afford that much anyway, so get as much as you can!

Thursday, November 24, 2005

The Beast is here to stay

I've officially fallen for Debian in a big way. My initial issues with The Beast were cantered around not being able to complete the various web projects I had in mind, because I couldn't get JBoss to run. Pah! I've been doing more and more research into Enterprise Java, and really, EJBs aren't worth the resources they require. Instead I'm using Hibernate, PostgreSQL and Tomcat. I can do every thing I needed to do in EJBs without the container overheads. Sweet!

The other reasons are all packages. They are the most enabling technology I've seen for some time and I wish Mac OS X had it built in as standard. I was having trouble with LaTeX. I really wanted to use vector fonts rather than the default bitmap. I simply sshed into The Beast did a apt-cache search for times.sty and had the whole package installed and ready to go in under 5 minutes.

My only real issue with Debian from a server/developer point of view is Java. Now, I understand it's not everyone's cup of tea, but it fills a gap. I'm pretty fluent in Java and C++ and there is simply no arguing that it's easier to write safe, multithreaded programs in Java than C++. Sure, it has minor performance issues, and they really are minor nowadays, but in terms of an enabling technology it really is fantastic. I mean, if I wanted to teach somebody a new language, it would be Java. It's powerful enough to get what you need done, incredibly well supported and prevents you from doing any real damage to your development computer. It's also easier to pick up. I know people have issues with the having to write System.out.println instead of printf, or the hoops you have to jump through to get input from the CLI, but really, that's a minor penalty, especially when you consider that writing a GUI  in Java is probably easier than a CLI app and that impresses the bejesus out of noobs when they see the window they created spring up on the monitor - way more than HelloWorld.

So why then isn't Java installed by default on Linux systems, and more importantly why isn't it part of the standard deb packages? It appears entirely political / religious. Java isn't a free platform, in that the source code isn't freely distributed and that all the JVMs are either written by Sun or under licence from Sun. This great for Java developers, up to a point, because it means that you can guarantee that your code will run anywhere, at least anywhere that Sun supports - and really that's just Linux, SunOS, Windows and Mac OS X (under licence). But it's lousy for BSD, who have to run it through the Linux emulation layer (although there is an effort to port it to BSD natively) and it also means that Debian et al. refuse to distribute it with the OS because its not completely open. The process gets even more ridiculous when you think what Linux is: a server OS. You have a few options when writing server software: PHP/MySQL, Tomcat/Java, Mono/Apache. The only one of those which is easy to install on Debian is PHP/MySQL. This is a pretty good solution, but my experience with it has always been that it's a bit fast and dirty. I like Mono (or at least I like .Net) but it doesn't have the same support as Java - although it is getting better. If you want to write serious Web Apps for Linux the real money is still on Java.

So here is what I want. I can understand that Debian shouldn't be installed with Java as default. I can even understand that it shouldn't be installed pointing to a Java repository by default, but why isn't installing Java a case of un-commenting the package repository, then running apt-get update? Why can't I then install tomcat, hibernate, tiger et el, just by running apt-get? If anything this motivates me to join the Debian developers group and get this up and running, although I can't believe that I'm the first to suggest it.

Monday, November 21, 2005

So thats how it works

Just by accident I was dangling my iBuds over my PowerBook and I noticed that they were attracted to a spot about half way down the screen on the right hand side. Being an inquistative sort, it tried on the other otherside, and then tried on the corrensponding point on teh keyboard. The thing went to sleep!

I'd always assumed that the Hall field detector was near the latch, but its actually under the keyboard! Cool!

Stupid friggin word

My darling Zoë has been reduced to a nervous wreck this weekend because of Word 2004 for Mac. She used to work as an administrator for her fathers company and nearly all her work was done on Word, on a Windows computer. She moved to the Mac about 3 months ago, although she had a pretty high exposure to Macs as that all I use, but it wasn't until this weekend that she really started to use Office in anger - and boy was it angry.

Her biggest issue was the change from using toolbars to the side panel. This change never really affected me as I use keyboard shortcuts almost exclusively, but she was constantly look for the button to make it bold, central etc. Also, I tend to use headings and document mark-up whilst I'm working, where she prefers to do all the formatting herself. The problem is that nowadays Word really, really doesn't like you doing that and tries to 'help' you by marking up the headings itself so when she changed one section heading, all the others changed, and to be honest it really did look like random changes.

The result is that she is, to some degree, regretting buying a Mac - because she associates the bad office application with the computer itself, which is fair. You can't expect people who aren't into computers to judge a platform by anything other than its applications. But I fear that the real issue here is that Word is so similar as to actually generate this frustration. Its so close to working exactly like Word on Windows that when something is done differently it completely knocks the confidence out of a new user. I have no doubt the changes are to make the Office feel more native and to fit into the metaphors that Apple decrees, but really, for switchers, its enough to drive them insane. The same thing has happened with my Mum. She uses her Mac, almost exclusively for Office and was so put off by the experience, because it wasn't quite the same as her system at work that she is going to sell her PowerBook.

I've never been a fan of Office, either on Windows or Mac. It's a horrible application suite that has some glaring holes that have made some simple projects come to a stand still. The biggest offender is the the most important app: Word. Images, tables, autocorrect, metadata are all handled abysmally, and they are features that are essential in all but the most rudimentary document. The most ridiculous thing is that Word is still the best GUI office suite on the market. I've tried Pages, and it looks promising, but it's not quite there yet, it needs a little more snappiness' and OOo is trying so hard to MS Office that its feels like it's beginning to adopt some of its design flaws. But what about non GUI?

I decided to try and use Zoë's science project as a test bed for LATEX - the UNIX page setting software. Wow.

The document it produced was beautiful. The typesetting was exquisite, and the print out looked extremely professional - but then that's what LATEX is for. What shocked me more was how easy it was to use: you just type. OK its not that simple, there are characters you need to escape, and a few command that you need to get you head around, but to be honest its really not that complicated. I guess it's just what your used to. WYSIWYG has many great advantages, but Word, more than any other application, proves when something goes wrong, if you can't see how the document is formatted you can't fix it.

My only criticism of Latex is that tables are still a sticking point. The actual mark-up itself is pretty easy to understand, but it's also very easy to make mistakes. Most of my compilation errors were due to missing, or adding ampersands in the wrong place in the table mark-up, that and forgetting to escape & and %. But the advantages are many, auto title page creation, auto content page creation, you don't have to think about layout AT ALL and the presentation of your work is without rival.

Writing Apps

It started as a 5 minute exercise just to test my JavaFu. 2 weeks in and I'm gob smacked at how complicated this exercise has become. That exercise is ButtyMaster.

The Problem:

One of the guys I work with makes a butty order every Friday morning. It started as just a few people, but has grown to over 60. Each of these people ring him either on Thursday afternoon or Friday morning to request a butty. Most people have a 'usual' other people like to change their butty from week to week to week, the whole thing is stored in an excel spreadsheet that is printed off and faxed to Butty Shop. Not only is it taking over his Friday mornings, it's also costing him a lot of money, as the whole order comes in at over £100 which he then has to ring around to get back. He needs a system.

The analysis:

So what is the best way of dealing with this problem? Well, I'm a Java programmer, so my immediate reaction was to write a Java program, but what sort?

Do I write:

  • Distributed Swing program that talks to a central database?
  • A centralised web app with a database backend?
Lets face it, Swing is terrible. Its slow, convoluted to write, is difficult to upgrade once its out in the field and relies on people being able to run Java programs locally - definitely not a guaranteed. In fact, the only time I've seen any compelling reason to use Swing was Eclipse, but even then your left thinking - I wish this was written in something a little 'snappier'. So a web app it was, and that was when the work started:

What login system do you use?
Should I use a portal tool?
Should I use struts / JSF?
Should I use EJBs / Hibernate / DAO
Should I go for Weblogic / JBoss / Tomcat?
Which database should I use?
Should I use a database?
Where should I base it?
Should I design for easy maintainability or speed of development?
Should I use AJAX?
Should I use HTML / XML / XHTML?

In the scheme of things this is a very simple application. All people need to do is login, add/ change / request a butty and then logout. The average use case should take less than 5 minutes to complete, and yet its turning into a monster. I guess that's the problem with Java web apps. Java forces you to ask these questions as it makes no assumptions for you. The whole language is designed to make you think about the security and concurrency issues associated with an application, that even on this low level, requires the coordination of some many interacting parts.

And in that respect I'm probably using a sledgehammer to crack a walnut. PHP would stop me from being able to make any of these decisions as I'd put all the code in the page. Of course, this is at the expense of ease if change later on in the process.

Perhaps I could create an Access front end to a PostgreSQL database and make that available on the company intranet. Certainly a strong contender, but that means that everyone needs to have Access and as I learnt on the Forklift project, Access makes a lot of things very easy, but other really important things almost impossible (it's also as reliable as a chocolate teapot).

So here I am with ButtyMaster the Java web app. I've designed the database, and now I'm looking to connect it to the app. Even this involves a lot of choices, the current one being do I use a pure JDBC 2.0 solution, or use SQL and JDBC 1.0, should I be building stored procedures, do I need to use DAO, if so should I use an interface? I keep telling myself that this is just a butty app, that really I don't need to worry about any of this, that premature optimization is the root of all evil: perhaps, the reality is, the problem is more complicated that I thought.

Sunday, November 13, 2005


I've been working on a silly little project to et me up to speed with
Java 5. Its the largest project I've tried to write in my spare time
and its pretty much a full J2EE application. I've got to say I'm
incredibly impressed with the additions for Java 5. The new foreach,
enums and type collections are absoutely invaluable. They have a few
nuances, but I was up and running with them in under an hour. The
daft thing is that there is nothing here that hasn't been in .Net for
years - next they'll be adding delegates!

The other thing that I've been really impressed with is CVS. I
installed it on The Beast just to see what all the fuss was about.
Wow. It has completely changed the way I store my source code. Using
CVS in Eclipse is so simple and effective as to make you wonder why
you would ever store your source conventional file again. If you do
any coding from HTML to assembler you have to check out CVS. Sayin g
that, I'm probably the last coder on the planet to figure this out ;)

Wednesday, November 09, 2005

I've got mail!

This blog is becoming more about Linux than Macs, I assure you its
just new toy syndrome. I'm pretty enraptured with Debian. What I like
about it more than anything is that I have as much power over The
Beast from the middle of a park with my mobile phone as I do from the
office with a keyboard and mouse. In fact, I'm getting so confident
with it that I'm seriously considering taking the keyboard and mouse
back to Kay's.

Only this afternoon, I managed to install and configure a mail server
from work, where the only internet access I've got is my mobile. A
mail server! I can now send and receive mail for free via The Beast
from anywhere in the world. Now this isn't unique to Debian, or
Linux. I could probably have done the same thing using terminal
services and a windows box, but there was an art to the ease of doing
it with apt-get over a ssh connection and on such meagre hardware.

Thursday, November 03, 2005

1 Week With 3G

Wow! This is a good technology. It's not the fastest connection in the world, there is a certain amount of lag, especially when you've left the connection alone for a bit, but unlike GPRS it's actually usable. Web pages and email both work amazingly well. The handshaking is bearable (much, much faster than GPRS) the battery drain is tolerable, but what makes it really useful for me is SSH and being able to connect to the G5 and The Beast from anywhere in the country (well Telford Town Centre).

The last few entries where I've been talking about installing and configuring my OS, 70% of that has been done over SSH with 3G and my PowerBook. It's like the Holy Trinity of mobile computing. The one problem is price. At the moment I'm getting 1GB of data free a month. In three months time that gets reduced to 4MB. Seriously WTF are you supposed to do with 4MB?

I can understand why it so expensive. Checking you mail on the move is a luxury that many can do without, and early adopters always get screwed. What I don't understand is why they price it the way they do. 4MB is nothing. Seriously, I've downloaded 700k in the last 30 minutes, over a compressed ssh connection. Why not band it 10MB, 100MB, 200MB, 500MB, 1000MB? £10 pcm for 100MB is a fair price. £5 for 10MB is a fair price. £15 for 4MB is a rip-off. 4MB might have meant something back in the old days of GPRS, but at 3G speeds and with all the graphics and crud that comes with web sites these days its an insult.

Our e-mail domain has now changed from to Please update your address books.


OK, OK. I know I said that I'd finished with this project. But I couldn't just stand by and see a perfectly good system go to waste, 64MB RAM or not, it has more than enough resources for the a few tasks, after 640k should be enough for anyone...right?

I set my sights on Gentoo. The way I figured it, I needed every ounce of performance to get The Beast to run adequately. Gentoo offers this by compiling every single line of code specifically for your machine, making it the tailored suit of distributions, but this comes at a price. You have to make every single choice yourself and compiling takes time: source takes longer to download than binaries, and compilation is itself a complicated task. This leads to an install time measured in days... no seriously.

To make a long story short,
after two days my installation was slower than Ubuntu, but I learnt more in those two days about Linux than I have done in the last 5 years. Configuring a kernel? Pah, child's play. Resizing partitions, gcc optimization, where everything lives, how the kernel is pulled together, installing and configuring GRUB and LILO, how cron works, an easy way to get things started as services... the list is endless.

So where am I now? Well I had a think about it and decided that I didn't like Gentoo. As much as it had taught me, and as powerful and well supported as it is, the fact of the matter is I'm simply not man enough. I'm a bit too much of a Mac wuss to really want to spend all my time tinkering with the inner working of my computer. If I kept Gentoo, I would never be satisfied with The Beast. I would constantly try to fine tune the myriad of options, in a vain attempt to get a more responsive system - when what I really need is more RAM (a fact that is impossible to escape). So I'm going with Debian: the install was painless; I'm used to apt-get because of Ubuntu; its as stable as a rock and its pretty nippy. OK, so the kernel may be a bit behind the times, but I'm running on a legacy system, so I don't need all the bells and whistles that are required to eek the last cycle out of an AMD 64X2 - and anyway I'm a dab hand at kernel configuration now ;)

Why Debian? I like apt-get, emerge is really good, but apt-get works for me. Why not *BSD? Java. I know you can get Java working on the various BSD but they all run through the Linux compatibility layer which sounds like a lousy solution, you can apt-get JBoss on Debian which makes it a clear winner in my eyes. 

Our e-mail domain has now changed from to Please update your address books.

Tuesday, November 01, 2005


OK, the hard drive problem was my fault. Don't mess with proprietary hardware and expect to win, or better, when somebody tells you to record the master password for a hard disk take them seriously. That's two days I'll never get back, and the only nugget of wisdom I acquired in the process is, no, you can't unlocked a HDD for free, which I read in the first few minutes of my investigation. Time to focus my energies on something easier, a RAM upgrade.

All I wanted to do was upgrade from 64MB to 312MB. I checked the pins, 168 of them, I checked the bus speed 133MHz, I even checked to see what the BIOS maximum memory size was, 512MB. So with all this information at my fingertips I went to PC World to make my frivolous purchase. The damn stuff didn't work.

Apparently there is PC133 SDRAM and then there is PC133 SDRAM. They look the same, the have the same number of pins, but they initialize slightly differently which means that only newer BIOSs work with it. I'm really loosing interest in this whole project.

In an effort to improve performance I've started using XFCE as my window manager, its gorgeous and very responsive, but the fact of the matter is that 64MB RAM just isn't even remotely enough. Firefox is enough to consume pretty much all of the user space memory and as soon as you get a complicated page it starts paging virtual memory like its going out of
fashion. Running Firefox and Evolution is an exercise of extreme patience, and JBoss takes hours to tell you that it doesn't have enough memory. Now I could increase the virtual memory, but that's not very wise, sure things will load but with a crappy 5400RPM 10GB hard disk getting anything done will be painful.

So what are the alternatives?

I could buy memory that I know will work from Crucial, for a premium: £51.69 + pp for a single 256MB DIMM, or £21.14 + pp for a single 128MB DIMM. To be honest I just don't think its worth it. 256MB will take the system from being ridiculously slow to quite slow. It will run JBoss, and I might be able to run Firefox and Evolution at the same time, but £50 is a lot of
money to invest in a system that isn't really mine. For ~£150 I can own a AMD Semperon system that makes The Beast look like the POS that it is, or I could just bite the bullet and do the development on G5. The original plan was to do the development on the Linux box because it would be easier, but that just hasn't been my experience. Java and Linux do work pretty well together, but on far more powerful machines, or maybe I'm just spoilt by the extreme power I have at my disposal in the G5. The Beast is going back to Kay's.