Showing posts with label coding. Show all posts
Showing posts with label coding. 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, 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!

Sunday, December 30, 2007

Esoteric Programming Languages

Many thanks to New Scientist magazine’s Feedback for mentioning DangerMouse's collection of esoteric languages and algorithms. They were particularly impressed by the Intelligent Design Sort, though personally I find the Drop Sort more intellectually satisfying.

I now realise that all that time at University writing QuickSorts in Pascal was wasted - I could have been writing Hanoi sorts in Ook!

Incidentally I’m sure that somebody once proposed an extended BASIC that replaced the GOTO with a much more useful COME FROM statement…