Wednesday, September 26, 2007

Telepods of Doom

On BeContrary is a discussion about Telepods of Doom. The question goes like this:

It is the year 2112. Telepods have been in use for a decade to instantly transport matter from one part of the universe to another. You are waiting in line with your family at a telepod station to go to Tau Ceti. In front of you in the queue you meet the inventor of the telepods. He tells you that the telepods only appear to move matter, what they actualy do is create an exact duplicate at the destination and destroy the original in the process.

Do you get in the telepod?

As my math teacher would say: You're mixing up two frames of reference. In quantum physics, objects exist only once. There can be similar objects but these can never be exactly the same (they must differ in at least one attribute, for example in spin). Don't use that argument when the MPAA comes after you. ("That music isn't what was on CD! It must be different! Quantum theory says so!")

One way to make exact copies is to destroy the original and transfer all attributes onto another object (thus destroying the other object and creating a new "original"). In the real (macro) world, this can lead to all kinds of problems: If the destroy happens before the "apply attributes", you lose the object. If the destroy doesn't happen at all, you suddenly have two copies. If only a part of the attributes are copied, you have an imperfect copy.

In the quantum world, none of these effects can happen. It's either all or nothing because there is no state in between. Quantum particles can move through "solid" walls because they never spend any time inside the wall. In one moment, they are on one side, the next, they are on the other. The theory doesn't ask for continuous movement. It just says "when you look several times, there is a certain chance that you'll see the particle." There is no explanation how it gets from one place to the other and how it spends the time when you don't see it.

Since no one has found a flaw in the theory so far, it seems to be an accurate description of reality. That it contradicts our view of reality means that our view of reality is imperfect, not that quantum theory is wrong. Or as Douglas Adams put it:

"There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable. There is another theory which states that this has already happened."
-- Douglas Adams

Tuesday, September 25, 2007

Undo for Webapps

While AJAX webapps grow more and more functionality, a very important one was missing so far: Undo. Imagine Word without Undo. 'Nuff said.

Aza Raskin has a solution. Well done!

Downloading Sources for Maven2 Projects

If you ever needed to download the source artifacts for a Maven2 project, there were several options: If you use the Eclipse plugin (either the Eclipse plugin for Maven2 or the Maven Plugin for Eclipse, also called "Maven Integration for Eclipse"), you can use the option -DdownloadSources=true from the command line or enable the "Download sources" preferences option.

Both have some drawbacks. When you use the Maven Plugin in the Eclipse IDE, it will try to download the sources all the time which blocks the workflow. If you just want to do it once, you have to enable and disable the option all the time plus you have to force the plugin to start the download (with 0.12, you can add and delete a space in the POM and save it). But it will only download the sources for a single project.

If you use the command line version to download the sources, it will overwrite the .project file and modify your preferences, etc. Also not something you will want.

There are two solutions. One would be the "-Declipse.skip=true" option of the command line plugin. Unfortunately, this option doesn't work. It will prevent the plugin from doing anything, not only from writing the project files.

So if you have a master POM which includes all other projects as modules and all your projects are checked into CVS, you can run:

mvn eclipse:eclipse -DdownloadSources=true

to download all sources and then restore the modified files from CVS. I've opened a bug which contains a patch for the skip option. After applying it, -Declipse.skip=true will just skip writing the new project files but still download the source artifacts.

Monday, September 10, 2007

Spammers "Cracking" Accounts on Blogger

There seems to be a recent increase in spammers "cracking" blogger accounts and replacing the blogs with spam/porn/etc.

If you want to save yourself from some hazzle (like your boss asking why you advertise porn on your blog), here are a few tips:

  • Don't blog while connected via WLAN.
  • Always log out after blogging.

If you have to blog via WLAN, always assume that everyone on this planet watches what you do. In our case here, the spammers don't actually "crack" your account; they just copy the cookie which your browser uses to identify itself against the server.

Anyone who can present that cookie is "you". So they listen for it when you talk to the server on a WLAN and, after you're gone, they run a little script which deletes your blog and replaces it with spam. Takes a few seconds and is almost impossible to track down afterwards.

If you want to be safe, don't use hotspots to connect to the internet. If you have to, you must set up a VPN, otherwise it's just a matter of time until your blog will be "cracked".

Sunday, September 09, 2007

How To Write, Part 1

In this ongoing series, I'll talk about how I develop and write stories. If you're interested in writing stories, getting tips and improving your style, etc., here are two great places to start.

First, browse the OWW, the Online Writing Workshop. It's mostly for SciFi, Fantasy and Horror writers but it contains lots of good advice and background references in the mailing list (ever needed to get some ideas on time travel stories? Who had already done what and how it worked out? Here is a good place to ask.

Next, have a look at the live journal of Joshua Palmatier. I have to admit that I haven't read any of his books but I greatly enjoyed his explanations, for example how scene, character and plot work together to build the complex immersion readers want to enjoy (and therefore, are willing to spend money and/or time on). I've rarely seen an explanation of these topics which was so easy to understand, so much fun to read and so helpful at the same time.

Tools

Next, you'll need a set of tools. Since I want to be able to write anywhere, I travel lightweight: jEdit, TreeLine and, since English isn't my native language, Office-Bibliothek. Being a seasoned software developer, I keep my stories in a Subversion repository. I do this for backup purposes and to be able to access them with a simple web browser for anywhere on the globe.

jEdit

jEdit is a text editor written in Java. This means several things: It will run on Windows, Mac and Linux. If there is a computer where I am, chances are, I can use it. The keyboard mappings are the same. The menu structure is the same. It can do all I need and it can do it well.

Furthermore, since I write my stories in an XML dialect, I don't need a more complex text editor. Later, I'll convert the text to TeX from which I can generate PDF or DVI. Or I can use another small tool to convert the XML into HTML.

Why not use a more complex editor like Office or Frame Maker? Because it gets in the way. I want to write, I don't need a complex UI, software that crashes on me or gets in the way (do I have to say "paperclip"?).

The only drawback of jEdit is that the spell checker sucks. But if I cared, I could fix that. It's open source software.

TreeLine

If you write anything that goes beyond 30 pages, you'll eventually strangle yourself in the strands of information. What happened when? What was the name of this character? How old was she? Where was she born? Did I mention that place already?

An outliner is like a file explorer for information. To the left, you have a tree-like outline (hence the name) with characters, the time-line, places and other knowledge. On the right side, you can see the details.

There are more complex tools, suited better for writers, which allow to move around events on the time-line, which help to organize relations between characters, which contain name generators and such. For some reason, they are all Windows-only. For me, that means, I can't work at home because there, I have Linux.

I can waste as much time as my employer likes as long as they pay me by the hour. At home, I need to get work done.

TreeLine is the outliner of my choice since it runs on any OS and because it's written in Python which makes it simple to extend. For my purposes, I've added a "quicklink" extension which allows me to define keyword fields and then creates links to those entries in other texts automatically (for example, I get a link to the character description when I use its name in the time-line).

I'm using version 1.1.9. Don't mind the warning about "development version" on the download page, it's rock solid.

Office-Bibliothek

If you start to write, you'll find that you often repeat yourself. "He said, he said, he said." Don't worry too much about that, this will go away as you learn to use them words better. On the other hand, you don't have to make your life unnecessarily difficult. Get a thesaurus, a dictionary and a good spell checker.

My choice was Office-Bibliothek, again because it runs on Linux. The prices for the data files are in the same range what you would have to pay for the books and you get a much better user experience (less hefting a big tome around, searching is faster than you can type and you can search for words which are not in the index; try that with a paper book).

Subversion

Subversion is a version control system, which will remember any change you ever made on your text. Not strictly necessary but it makes it much more simple to keep several versions (one at home, one at work, one on my palm and one on an usb stick) in sync, it automatically creates backups just in case I make a mistake and delete something I shouldn't have.

TeX

For many people, TeX is an anachronism. Why use a tool that expects you to write "this is a chapter" in your story when you can simply select the text in Word and chose "Chapter 1" in the toolbar? Well, because "simply" isn't so simple after all.

With tools like Word, OpenOffice and FrameMaker come a couple of price-tags which many people just have got used to and they don't question their motives anymore. First, we have the very real price tag. If you're not working with a pirate copy or one, for which you don't really have a license anymore, then you know, Word is not exactly cheap, even if you buy it alone. OpenOffice is free (as in freedom) and you just have to pay for the download but it's not available everywhere. Just imagine to try to talk the owner of a cyber cafe into installing OpenOffice for you so you can work an hour on your story.

Then, we have to issue of usability. I can work with Word and OpenOffice which means I can enter text and format it. Unfortunately, it will look like crap when it's printed. Both tools just have no idea what "beautiful" means and I frankly don't have the time or skill to teach them.

TeX, on the other hand, knows exactly how good (or bad) a text looks and it will even tell you so:

Underfull \hbox (badness 1789) in paragraph at lines 1041--1041
[]\T1/ptm/m/n/10 ^^PLook,^^Q the gen-eral started but she in-ter-rupted her:
[7] [8] [9] [10] [11] [12] [13] [14]
Underfull \hbox (badness 2073) in paragraph at lines 2165--2165
[]\T1/ptm/m/n/10 A smile split Forne's face. ^^PThank you, Ad-viser
[15] [16] [17] [18] [19] [20] [21] [22] [23] [24]
Underfull \hbox (badness 3148) in paragraph at lines 3705--3705
[]\T1/ptm/m/n/10 ^^PCertainly,^^Q an-swered the po-lite voice from above.
[25] (./haul05en.aux) )

Notice the "badness XYZ" warnings. They are just warnings. You can still print your text. It just won't look as good as it could. And in my humble opinion, a reader should not only get something that reads well but it should also look great. If you don't understand what I mean, print a page of text formatted with TeX and one page of text from any word processor and place them next to each other. Even if you don't know anything about font design and layout, the TeX version will make the other version want to roll up in its paper in shame.

Furthermore, since all markup (that's the information for the computer how it should treat a part of my text, i.e. if it's a heading, something someone says, a thought or whatever) is visible in the text, I never have to fight with the mouse to select just that part of my story that I want to select right now.

It's no accident that TeX is also the most stable software on this planet that I know of and that I use. The first version is from 1969 and the last update was December 2002. It's not dead, there is just nothing to improve anymore.

XML

XML is both the greatest idea since ASCII and the worst nightmare. It is a great concept, it finally allows to store data in a format that anyone can read (Ever tried to open a document you wrote ten years ago?). Unfortunately, some things had to be added so even computers from the stone ages can still read it and some definitions make perfect sense but are hard to understand.

For my SciFi stories, I use a special XML dialect that I call "story". It won't validate but it's simple to transform into valid XML. Here is an example:

<content>
    * Surprise, Surprise

<<T I'll show them,>> he thought and jumped out of his hiding
place, waving his rifle like a madman. <<Y Back off or I'll
shoot!>>

The muarhar<fn>Marauders of the south</fn> stopped dead, unsure
how big a threat he might be.

...
</content>

The part inside the content element is the meat of the story. It's a wiki-like format which allows me to write quickly (since I haven't found a single XML editor which would let me do that). The stuff between double pointed brackets encloses text that someone says or thinks. After that follows a single option character for thoughts (T), yelling (Y) or foreign language (F). In addition, I'm using a few XML elements like fn for footnotes, em for emphasis and q for quotes.

Note that I don't enclose paragraphs in p elements. In the beginning, I had a special key-mapping in jEdit to insert the empty element but I got rid of it. By adding a few simple rules to my "story-to-XML" converter, I made it add these by itself, freeing my fingers and eyes from such superfluous markup.

That's it. Now you just need a great story.

Myself - My Self - Who?

All my life, I've been fascinated by the mystery we call "self". Who is that person within my body who sits now in front of this computer and formulates this text? And why does this "me" feel so helpless in my own life? Why do I often feel that my life is in control of me instead of the other way around?

Of course, I'm not the first person to ask these questions. Psychologists and, in the recent years, neuro-scientists did the same and on a much more professional level. Freud explained this paradox with the Ego, super-ego and the id. Today, we can watch ourselves think and Benjamin Libet did. In very compact form, he found that the decision to do something is already made the time we (our "self") makes the decision (If you strongly object to this because it feels obscene, please read up on this elsewhere. It's true and it makes sense, however disturbing this may sound when you hear this for the first time).

So there is no free will? I can go around and kill anyone and say: "Oh, that wasn't me, that was my unconscious!"? Not at all! All I'm saying is that there is no free will right now. Let me give you some examples. Yesterday, I played with my cat. He was on the carpet and I was dangling the toy on the fringe of the carpet. He desperately wanted the toy and wriggled his muscles into the perfect position for the pounce but there was a threat: Beyond the carpet is a slippery floor on which he can't maintain his grip.

What happened was that he pounced and then immediately braked with all four paws to stop on the fringe of the carpet even if that reduced his chances to catch the toy. Obviously, he had noticed the danger and made a decision how to avoid it.

On a more complex scale, there is an experiment with monkeys and an upside-down u-shape. In the middle of the upper horizontal part of that u-shape is an apple and the monkey wants it. There is a cut in the u-shape, so it can prod the apple with a stick and move it in either direction. Unfortunately for the ape, one of the openings of the u-shape is closed with a mesh.

When conducting the experiment, the scientists found three types of apes. One type would move the apple into the "right" direction, it would fall out on the ground and they would eat it. The second type would move the apple into the "wrong" direction where it would fall onto the mesh. After a lot of effort, they would bring it up again and out of the other end.

The really interesting type is the third. They would move the apple into the wrong direction at first and, just before it would fall down the tube onto the mesh, they would stop. Next, they would start to move the apple into the other direction. Why?

The explanation is that these monkeys probably have created an internal representation of what will happen if they move the apple further, decided that this might not be so cool and changed their strategy. Just like the cat, they thought ahead. My theory is that my "self" is this "thinking ahead" thingy. Obviously, this is a very important part. Is it safe to cross the street, now, or will that car hit me? Maybe it will stop in time? Or is it too fast? Has the driver seen me? How about the car behind it?

If that part is so important, why is the decision made elsewhere?

Because it takes too much time. Making a decision takes time. If your life is at risk (and even today, it is at risk all the time), you don't want to waste time pondering all the possibilities. So, from a safety standpoint, it makes sense to cut some corners to be able to move those physical muscles while Mr. Brain still wonders what might be going on.

Of course, Mr. Brain would be genuinely unhappy if it felt that someone else is making all the important decisions while it, obviously so much more smart and important, still is working to assess the situation. Therefore, the decision making part of ourselves cleverly pulls some strings to create the illusion "Oh, you and you alone made that decision. Don't worry, everything is alright. Oh, look at that ... is that dangerous?"

From an evolutionary point of view, it makes less and less sense to allow a big and complicated brain to make decisions at short notice. It will reduce your chances of survival, slow you down to a crawl. Just imagine how you would walk if you had to move every muscle consciously. Try it and you'll be even more disappointed. There are martial artists who can touch you before you notice that they even moved. That kind of speed is impossible with a human brain.

Things change considerably when we look at the long term. Looking at cats and monkeys, they don't seem to plan ahead at all. The cat doesn't think about the dangers outside when you leave a door open. All it will see is a new opening which it hasn't explored yet and it will dash for it. Monkeys don't build shelters. They do use tools but there is a distinct limit how far they can look ahead. Not so with us humans. We can look ahead as far as we want (or at least we believe we can). We can plan for days, weeks, months, years, decades, centuries. We can plan and build big cities and they don't fall apart with the first woodpecker.

For example, building the famous World Trade Center took seven years (1966-73) or even twelve years (1961-73) if you start with when the initial plans were made public. The dream of building it started even before that.

My favorite story is the roof of New College, Oxford. When the large oak beams of the roof in the New College in Oxford were yielding to the teeth of time, the owners of the place were at a loss how to replace them. Can you imagine the price of oak beams spanning a great hall? They considered replacing them with steel but that was also way beyond their budget. By chance, one of the foresters of the college heard about this and mentioned that, 500 years ago, the builders of the place had planted oak trees just for this occasion. So in the end, they got the new roof for free. Of course, this is just an urban myth but a nice one. The cynical version adds that they sold the forest for profit afterwards without regard for what will happen in 500 years from now.

So, while someone might not be responsible for killing a guy in that brawl last night, he is fully responsible for getting into that brawl in the first place. His self is fully capable of looking that far into the future and preparing to avoid such a situation, for example by not drowning his ability to plan ahead in alcohol, by looking for a nicer place to get drunk or by just walking away when that guy started to make trouble.

"The avalanche has already started. It is too late for the pebbles to vote." - Kosh, Babylon 5

That is why understanding how our own brain works is so important: In the heat of the moment, the conscious part (the "I") of ourselves has no chance to vote anymore, so it must make the decisions before that moment. This will influence the options our unconscious has when it must move in an instant.

Because it does listen to us but only when it can afford the time. That is why we can change our lives and why it always takes so long.