The Door

April 20, 2011

My friend disagrees with me when I say that programming can be  just as creative as writing.  She questions the fact that code is poetry.

After much argument, she sent the following poem, and challenged me to write a program just like it.  I went one better and wrote a Java implementation of the original.

I must admit, the original poem is a lot shorter than my implementation, but the Java version has the advantage of scalability. You can add as many items as you like to my program, rather than restricting yourself to the (rather paltry) eight the poet allows.  (I note, for example, he included “Magic City” but neglected to check for a normal City, or even a village or town.)
I would also add that it would take a good 10 or 15 seconds to read the poem, whereas my implementation will run in in under a second.  Score one to science, I think.

The Poem

The Door
Go and open the door.
Maybe outside there's
A tree, or a wood,
A garden,
Or a magic city.

Go and open the door.
Maybe a dog's rummaging.
Maybe you'll see a face,
Or an eye,
Or the picture
Of a picture.
Go and open the door.
If there's a fog
It will clear.

Go and open the door.
even if there's only
the darkness ticking,
even if there's only
the hollow wind,
even if
nothing
is there,
go and open the door.
At least
There'll be
A draught.
By Miroslav Holub
Translated by Ian Milner and George Theiner

Java Implementation

import org.sensibility;
import com.darkness;
import com.wind;
import com.external.door;

class doorChecker
{
    Door door = new Door();

    String [] itemsVerse1 = {"tree","wood","garden","magic city"};
    String [] itemsVerse2 = {"dog rummaging","face","eye","picture of picture"};

    boolean isDarknessTicking = false;
    boolean isWindHollow = false;

    doorChecker()
    {

	Darkness darkness = new Darkness();
	Wind wind = new Wind();

	isDarknessTicking = darkness.isTicking();
	isWindHollow = wind.isHollow();

	for(String s:itemsVerse1)
        {
	    if(openDoor(s))
	    {
		    System.out.println(s + "exists outside the door");
	    }
	}

	for(String s:itemsVerse2)
        {
	    if(openDoor(s))
	    {
		    System.out.println(s + "exists outside the door");
	    }

	    System.out.println("Also, the fog will clear");
	}

	if(isDarknessTicking || isWindHollow || door.getOutside().isNull())
	{
	    System.out.println("There is a draught");

	}

    }

    public boolean openDoor(String item)
    {
	boolean itemExists = false;

	if(item.equalsIgnoreCase(door.getOutside()))
        {
	    itemExists= true;
	}

	return itemExists;
    }

    public static void main(String args[])
    {
	new doorChecker();
    }

}

Diana Wynne Jones

April 1, 2011

I just read that Diana Wynne Jones died this week.  I feel genuinely sad at her loss.  She was one of my favourite authors.

It was one of her books that first inspired me to write.  I mean to really write, not just mess around thinking about it and scrawling out the occasional 100 words.  Up until reading her I had thought of writing, as most beginners do of any activity, as rather straightforward.  I imagined that anyone could do it. When I began Howl’s Moving Castle, the first book of hers I ever read, I was immediately struck by just how clear her writing was.  How imaginative, witty, wise and beautiful that good writing could be, whilst always remaining entertaining and, in this case, suitable for children.  This was before Children’s writing was enjoying its current renaissance.

I also became aware that I couldn’t write that well – anywhere near that well – and this opened my eyes to the realisation that writing was something that you had to work at.  That’s what made me become a writer – I wanted to write as well as Diana Wynne Jones.  I haven’t managed it yet, I don’t know if I ever will, but I keep trying.

I never met her, I was bitterly disappointed when I found out we once stood near to each other at a convention.  I would have loved to have said hello and tell her how much she inspired me, but that’s life: missed opportunities.  At least I got to read her books.

I was going to put a link here to Amazon and my favourite book of hers: Fire and Hemlock.  I was going to, but the cheapest second hand copy was £15.

Instead, here’s a link to Charmed Life.  It’s also good, but, to be honest, I’d recommend just about anything by her.