Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Sunday, November 30, 2008

Java without the Caffeine

I'm writing this sitting by a river in darkest Essex, mid-way through a winter's afternoon. The river is running slow, brown and deep; further down it has overflowed the banks and submerged the footpath.

To my right the water runs through a weir, adding a pleasant background chatter to the silence otherwise only broken by the odd crow and a group of Explorer scouts mucking about in kayaks further upstream. On the opposite bank a lone fisherman freezes over his rod - he doesn't appear to be having a very successful afternoon.



It's about five degrees above freezing and I've been sitting here on a bench for nearly two hours writing some Java to traverse and manipulate an XML DOM tree. There's no Wi-fi or cellular connectivity here, no e-mail, IM or Twitter - the only tweets are coming from a blackbird in the hedge behind me and a Jay in a tree across the way.

Fingers and toes are beginning to feel a bit cold now, but it feels good to coding productively without the constant need for caffeine!

Saturday, February 2, 2008

Emulating the PDP-8

Mentioning the PDP-8 yesterday set me thinking about building a PDP-8 replica using modern day TTL. The PDP-8 had a particularly simple architecture with only a few registers and eight basic op-codes. The early machines in the family, like the ancient one I used at University, was build from individual transistors and core memory. Later on DEC switched to TTL chips and RAM, so to build a replica would certainly be possible.

There was also a PDP-8 on a chip - the Intersil 6100. We used to have some prototyping boards for this low-power chip. The memory was backed by a single AA battery - at the end of the day you could just pull the memory board out. Next morning you could plug it back in and carry on working. It was used for ultra-low power application like satellite on-board systems.

A wander around the Web turned up Henk Gooijen's great looking 6809-based hardware emulation, and links to a number of software emulations, most of which ended in an HTTP 404 page. However there were some gems - for example Tim Gorton's Java Applet PDP-8 emulator that interactively runs a PDP-8 Lisp.

There was also Brian Shelburne's MS-DOS PDP-8 emulator which comes with a built in assembler and a lot of fascinating documentation. Apparently it used as part of a course on computer architectures - which is a little surprising because, although its a simple, elegant architecture, it doesn't use a stack which is a little unusual these days...

After spending an evening reading those sites and playing with some of the emulators I had a very restless night - I kept waking up with bits of Java code for emulating PDP-8 instructions running through my head. I had been looking for a little Java programming project to try out Swing (its all Web development at work) and this seems to have chosen itself.

So my next few commutes are going to be with the PDP-8 Programmer's Reference and a big pad of paper.

Saturday, January 12, 2008

Traps, Pitfalls and Corner Cases

That Joshua Bloch and Neal Gafter have a lot to answer for! They have caused me much embarrassment and inconvenience this evening. After a long day's interviewing Java developers I thought I'd wind down on the train by reading a few sections of the aforementioned Bloch and Gafter's "Java Puzzlers".



This book is an absolute joy. At the bottom of each right hand page is a short piece of Java code and a simple question. For example the first puzzle is a one line method, and the question "Does the method work?" Of course the answer is no... but why? After each puzzle the next page gives a detailed explanation, which is always informative, lively, entertaining and often surprising.

Even if you think you know the JLS well you might be surprised by how often Bloch and Gafter manage to fool you. On the train I looked at one line of code for about ten minutes. I knew that there was a trick there, but just couldn't see it. When I turned the page and saw how completely I'd be fooled I burst into laughter. My fellow passengers gave me some very strange looks; not all of them entirely friendly. Apparently it is not the done thing to laugh at computer text books on the tube.

And the inconvenience? Well I was so engrossed in one problem that I missed my station - the first time in decades of commuting. Oh, those crazy Google engineers!