The everyday ramblings of an everyday geek.

Sunday, April 23, 2006

NATD Hogging CPU

I've been plague for a couple of months now by my iMac G5 suddenly just slowing down and the fans powering up. Today I made the connection: internet sharing. Turning it off made my G5 Snappy(TM) again. Yay!

Tuesday, March 07, 2006

Blogger Dashboard Widget

This is pretty cool! I can now post from Dashboard!

Not sure if thats better or worse that using Mail, but its definately more convienient than using the web app.

Wednesday, January 04, 2006

Well that was a stupid idea

I'm not sure why, but for a few hours, just before Christmas, I was determined to get Ubuntu running off my iPod. I had gotten it into my head that running Ubuntu off a 40GB 1.8" drive was significantly superior than running it off a 10GB 3.5" driver spinning 3 times as fast, that and the thought of being able to umount the iPod, and bring my home desktop to work was pretty appealing.

There were of course several flaws to this plan. Firstly, Ubuntu doesn't boot very well from Firewire. Secondly, my 3rd gen iPod doesn't charge when connected via USB, and finally, my work computer is a dual Xeon and my home x86 is a PIII, but the academic challenge was pretty enticing, and I'd read some success stories of people building custom, generic kernels that could load from firewire. The initial install went pretty well. The install script found and identified the firewire iPod and let me create a couple of reiser partitions on it. In fact, it was all going so well that I was pretty sure I'd get the whole process completed in under an hour. That was right up until the first reboot. Then my iPod died - they are clearly allergic to Reiser.

The remainder of this post is an account of how to fix your 3rd Gen iPod when all it freezes on the Apple at reboot.

  1. Charge your dead iPod.
  2. Unplug it
  3. Flick from hold button to on (red) then off (white)
  4. Immediately press and hold Play and Menu buttons (This should restart your iPod)
  5. When the Apple reappears press and hold the Prev and Next buttons (This will put your iPod into disk mode)
  6. Reconnect your iPod
  7. Run the apple restore software
This simple plan took several hours of research to find, so I figured I'd replicate it and post it here. Of course now I know about this secret "Disk Mode" I'm back onto the idea of booting Ubuntu from it... when will I learn?


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

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.