The Bible, The Bard and The Beatles

Since today is the anniversary of the release of Sgt. Pepper’s Lonely Hearts Club Band, it’s a good day to talk about a conversation I had with my brother recently. We are both Beatles fans, and I recently purchased a book, on his recommendation, which dives into detail about the music theory underlying the Beatles’ songs.

He and I agreed that if all hell broke loose in the world, that book, together with the complete Shakespeare and the Bible, would be good ones to grab from the bookshelves. Which of course hearkens back to H.G. Wells’ famous riddle.

At the end of The Time Machine, George grabs three books to bring forward with him in time for the benefit of the Eloi. His colleagues are left wondering which books he chose, and we never find out.

1895 was a bit too early for the Beatles of course. But if the story were taking place today, that book could very well be in the main character’s personal library.

So there you have it. If you want to kick-start a civilization, one option is to choose the three B’s: The Bible, The Bard and The Beatles.

Widget Wednesdays #21

Continuing the theme from yesterday of “simple is good”, today I’m going to talk about the concept of “hello world”. As most programmers know, one of the first programs you ever implement when you learn to program is one that just prints out the phrase “hello world”.

The idea is that you want to start programming something very simple, and then — once you’ve gotten your first program working — build from there. The nice thing about a “hello world” program is that it is very short and easy to write.

For example, in Javascript (the native language of the Web) a “hello world” program looks like this:

      console.log(‘hello world’);

It doesn’t get much simpler than that. Which got me wondering, what is a “hello world” program for interactive computer graphics on the Web?

So today I implemented one, which you can run here. All it does is let you move around a black square against a white background.

It works whether you are on a computer or a SmartPhone. The entire program file consists of 13 lines:

<center><canvas id=C width=1280 height=800></canvas>
<script>
let c = C.getContext('2d'), r = C.getBoundingClientRect(),
    w = C.width, h = C.height, p = [w/2, h/2],
    s = (u,v) => p = [u - r.left, v - r.top];
C.addEventListener('mousemove', e => s(e.x, e.y));
C.addEventListener('touchmove', e => s(e.changedTouches[0].pageX,
                                       e.changedTouches[0].pageY));
setInterval(() => {
   c.fillStyle = 'white'; c.fillRect(0, 0, w, h);
   c.fillStyle = 'black'; c.fillRect(p[0]-50, p[1]-50, 100, 100);
}, 30);
</script>

If you want to program interactive computer graphics for the Web, you can start with something this simple. From there you can keep building and building, and eventually create worlds of your own.

Simple is good

I spent quite a bit of time today trying to fix a bug in my computer program. I systematically broke everything down to cases, treated each case differently, tried to make sure that this one was parallel to that one, yada yada yada.

Nothing worked quite right.

Then, all at once, I realized that I could replace the entire elaborate structure by a single short line of code. And that one line of code worked like a charm.

I was now a happy man. I’m sure there is a lesson in here somewhere.

Future public transport

One of the problems with taking planes or buses or trains is that they are very unpleasant, on a purely sensory level. You are basically packed into a can with a bunch of strangers, and forced to just sit tight while you are collectively shipped off from point A to point B.

I wonder whether VR will at some point become mature to the point where it can have a transformative effect on such experiences. We get on board, put on our glasses, and spend time in the idyllic experience of our choice.

One person may opt for a day at the beach, watching the waves lap upon the shore. Another my choose to hop a ride on Harry Potter’s broom for a rousing game of Quidditch. Everybody follows their bliss.

There may come a point when people will decide to go somewhere on public transportation just for the entertainment value. Wouldn’t that be nice?

The utility of pets

If you have a dog, you know that a dog is pretty useless for anything practical. Basically it eats drinks, pees and defecates, and then spends most of the rest of the time just sort of napping.

Which means that from a certain perspective a dog is useless. It doesn’t do the dishes, take out the trash, help the kids with their homework, or anything else really.

Yet all across the world, many millions of people have dogs. From this we can conclude the following with certainty: Whatever it is that dogs do, it is clearly incredibly important.

Ironically, the clearer the evidence that dogs are useless, the more obvious it becomes that they are vitally useful.

Grateful

Sometimes a concert is simply too good to wrap your head around right away. Tonight I attended such a concert.

I know that it had a profound effect on me, but I need more time to digest the experience. For now I will just ponder in silence, and be grateful.

Stranger than Stranger than Fiction

I am happily reading L. Ron Hubbard’s 1940 novel Typewriter in the Sky. I purchased a used hardcover copy on-line a while back, and am finally getting around to it.

If you’ve seen the 2006 film Stranger than Fiction you know the basic idea. Except that Hubbard invented the idea more than eighty years ago in Typewriter in the Sky.

Without giving too many spoilers, there are resonances here for anyone who has ever pondered issues of personal destiny or the limits of free will. As sentient beings in a contingent universe, what are the limits on our powers of self-determination?

To what extent are you an individual with freedom to decide your fate, and to what extent are you actually defined by whatever deity or celestial clockwork sent you hurtling into motion at the start of your life? And in the end, how much does it matter?

In any case, Typewriter in the Sky is a great read. It’s fun, wild, fast paced and completely original.

And it’s actually worthy of that often terribly misused word “Meta”.

Interactive-lite

The program that I posted yesterday was an example of something that might be called “interactive-lite”. It’s interactive, but in a sort of minimal way.

Normally when you write an interactive computer graphics program, you keep track of everything that the user does. When do they click their mouse down? When do they release it?

I started out writing the MapTime program that way. But then I realized that there was no need for all that.

There is just no reason to keep track of whether the mouse is pressed or not. So in the final version of the program, I don’t even check for that.

All the MapTime program cares about is where your cursor happens to be. To me there is something very pure and simple about this way of doing things.

It seems to me that this is an interesting category. I wonder how many different interactive computer graphics programs could be written as “interactive-lite”?

Widget Wednesdays #20

This afternoon I wrote a program that I always wanted to have. Just a really simple way to move a clock around on a world map to find out what time it is anywhere in the world, without need to to do a Google search.

You can also use it the other way: If you already know what your local time is, you can use this to find out your exact longitude in the world.

It was surprisingly easy to implement, mostly because I tried to make it as simple as possible. The one little extra design flourish was that I change what the clock looks like depending on whether the local time is day or night.

Also, I decided to make time change continuously as you change your longitude, rather than using discrete time zones. Mostly because this way it’s more fun and dramatic. 🙂

I call it MapTime. You can check it out here.

Ideas in dreams

Every once in a while I get a really great idea in a dream. Or at least I think I do. I suspect you have had similar experiences.

Invariably when I wake up from such an experience, I say to myself “Wow, that was a really great idea!” And then my next thought is “If only I could remember what it was.”

Which leads to the obvious question: Do we actually have great ideas in our dreams, or do we merely experience the illusion of having great ideas?

Maybe the emotion associated with having a great idea is a specific thing in itself. It’s possible that this particular emotion is what is getting triggered, and what we are remembering when we awake.

Come to think of it, that’s a much more plausible explanation. Although a lot less fun.