Skip to content

The Shortest Path

Tue, 10 Dec 2013, 11:09 PM (-06:00) Creative Commons License

I ran behind the pack. Their red lights blinked reassuringly in the darkness as they pulled away. I’d be certain to see where they turned, even if I fell way behind.

Which I did.

They pulled way ahead. But when they came to a cross street, I could see them stop where our route turned into the neighborhood. Problem is … they kept pulling away, and before long they were gone. No pack in the distance. No shadows of runners. No blinking lights. Nothing.

Whatever.

We’d run here before, so I couldn’t get lost. And we were running timed fartleks, anyway, so the official route didn’t really matter. As it happened, I had turned right where everyone else turned left. So I was on my own.

Whatever.

I ran the fartleks: two minutes fast, two minutes slow, six times. And I started a slow warm down on a made-up route, because there wasn’t enough distance between me and my car for a 1.5 mile warm down run. So I crossed a street and decided to jog another slow loop to make up the distance. 

“Did I turn wrong somewhere?” a woman asked. She was wearing a white running jacket and had a red light somehow attached. She was standing in the shadows on the other side of the street.

“Oh, you’re really asking the wrong person!” I said, not elaborating further on my wrong turns and improvised loops.

She took out the slip of paper with the running map on it. “I don’t even know where we are.”

“Here,” I said. “We can go this way and rejoin the warm down route, or we can go back that way.” I pointed in the other direction. 

“I just want to take the shortest path,” she said.

“Well that would be back that way. Let’s go.”

Here I Am

Sun, 8 Dec 2013, 10:54 AM (-06:00) Creative Commons License

I can’t believe that it’s real
The way that you make me feel
A burning deep down inside
A love that I cannot hide

Our love is you and me baby
That makes the world go ’round
And if you’ve been doin’ lovin’ with me
Layin’ all my troubles down

Here I am, baby
Come and take me
Here I am, baby
Come and take me
Take me by the hand
Show me
Here I am, baby

— Al Green

Three Strikes

Sun, 1 Dec 2013, 10:04 PM (-06:00) Creative Commons License

One. She thought the man was a grackle on a window sill.

Two. Did you notice the waves on the right, I asked her. What waves, she said, I don’t see any waves.

Three. Did you use your non-dominant hand to draw that one, she asked me.

Oh, what a Sunday it was.

On The Other Hand

Sun, 1 Dec 2013, 03:37 PM (-06:00) Creative Commons License

Leaving

Tree

Sun, 1 Dec 2013, 11:12 AM (-06:00) Creative Commons License

Tree wave lava

Man

Sat, 30 Nov 2013, 09:49 PM (-06:00) Creative Commons License

Man

Unit and Nothingness

Sat, 23 Nov 2013, 03:15 PM (-06:00) Creative Commons License

On a different note…

1. On Procedures and Functions

In FORTRAN and Pascal and Ada, programming languages that I revelled in long ago, there is a distinction drawn between so-called procedures on the one hand and functions on the other. Both are software constructs for doing some work, but whereas a function calculates a tangible result and gives it back to the caller, a procedure does no such thing, performing instead some background operation on behalf of the caller (for instance printing some text to the screen or saving some data in a database). 

So in Ada you might write

function Translate( english_word : String ) return String is
begin
	...translation algorithm here...
	return swahili_word;
end

and

procedure Display( sentence : String ) is
begin
	...output algorithm here...
end

In a sense, functions produce stuff that you can take with you whereas procedures just do stuff.

2. Unifying Them Both

In contrast to this, the languages C, C++, C# and Java have no such distinction. They only have functions.

Well, that’s not quite right, because of course there’s still a need for algorithms that do stuff. And so in place of procedures, these languages define so-called void functions. They produce nothing whence void.

In a hypothetical language might this could take the following form.

function Display( sentence : String ) return void is
begin
	...output algorithm here...
end

To an engineer encountering this stuff for the first time, this notion of void functions is entertaining. It’s novel to reflect on the notion that the void has entered into an otherwise dry world of physics and equations of motion and all that.

But it’s not a confusing concept, so after a few minutes the novelty fades, and you proceed as you always have, writing some functions that produce something and other procedures functions that don’t.

3. void Isn’t a Type

Now, the languages mentioned above are examples of so-called statically typed languages. That is to say, every algorithm expressed in these languages manipulates things that have a so-called type (String, Integer, Character, …), and these types are explicitly specified by the programmer. So you might wonder, What is this type called void?

Well, I am not a programming expert, but my understanding is that in fact in these cases, void isn’t really a type per se. It’s just a hint to the computer that this particular function actually doesn’t return anything.

Hm… It’s a hint that this function isn’t producing anything; that it’s only doing something. In other words, void is just an annotation that says, Hah! Fooled you. This isn’t really a function at all; it’s a procedure.

4. Introducing Unit

This state of affairs changes a bit in the Scala programming language, a language built on the conceptual foundations of C and Java but one that goes in some fundamentally different directions.

Scala generalizes the notion of void to a full-fledged type called Unit. So in Scala you might write something like this.

def Display( sentence : String ) : Unit = 
{
	...output algorithm here...
}

Or using the Ada-like pseudocode we’ve used above,

function Display( sentence : String ) return Unit is
begin
	...output algorithm here...
end

The only real difference here is the presence of Unit instead of void. But in Scala, this is no minor detail. Whereas the void of C is a kind of hint, Scala’s Unit is a bonafide type.

5. A Tangent on the Notion of Unit

Unit made me do a double-take when I first saw it. After all, using Unit to represent “nothing” sounds perilously close to the heresy of claiming that 1=0. It turns out that I’ve run into this heresy before. 

Once upon a time I was working with a bunch of rocket scientists. We were building a new space transportation system that was going to take us to orbit, take us to the moon and eventually take us to Mars. One of the projects I was working on involved designing a schema for representing complex datasets in a way that future engineers and software developers could understand long after the original authors were gone. (This system was being designed for the long-haul, an irony given that the project was eventually cancelled.)

I worked with a couple computer science-y, math-y guys from California. They were bright, and they were determined to apply their dreams of ontologies to the problem I was working on. One day we were discussing how to specify … nothing — how to formally indicate that there was nothing there there.

“Can we call this Unit?” Oliver asked.

I was puzzled. Why would we call nothing one?

See the connection, here?

6. Another Tangent

I’m not a computer scientist. Indeed, in an interview question long ago, I was asked some computer science-y, algorithm-theoretical question to which said, “I confess I’m not strong in …” to which the questioner responded, “Aren’t all computer scientists strong in …?” to which I reminded him that my background was in engineering.

Neither am I a mathematician. But let me point out something about Monoids. In abstract algebra, a monoid is a pair (S,op) where S is some set and op is a binary operation (function) on that set that returns elements of the set. There are some axioms surrounding S and op, namely the axioms of closure, associativity and identity.

It’s the notion of identity that is relevant, here. The identity axiom simply stipulates that there is some element in the set S, let’s call it I, for which (I op x) = x for all elements x in S.

Hmm… This is a bit abstract. But wait, don’t leave. 

Let’s consider the case where op is the binary operation of adding two numbers together. In this case, I is 0 (zero), since any number plus zero gives you the original number.

Now let’s consider the case where op is the binary operation of multiplying two numbers together. Here, I is 1 (one), since any number times one gives you the original number.

And are you seeing my point, here? When those ontology guys asked me if it was ok to use the term “unit” to refer to “nothing,” it must have had something to do with monoids. Unit must be related to some theoretical notion of identity, and in the context of multiplication, the notion of identity is indeed… one. Hence the term unit?

Anyway, let’s return to Scala’s type system…

7. Unit and Nothing

So Scala has this thing called Unit. It’s a type in the language used in situations where a function actually returns nothing.

In some sense Unit means nothing. Personally, I would have chosen Nothing rather than Unit as way to say …you know… “nothing”. But it turns out that the type Nothing is used in Scala for something else.

Nothing is one of the so-called bottom types in the language. It is a subtype of every other type in the language. And rather than denoting “nothing” as the term suggests, Nothing actually denotes “never”. When a function is intentionally designed never to return you specify its return type as Nothing. Personally, I would have chosen …you know… Never to capture this. But remember, I am not a computer scientist.

Using the same pseudocode as above, you might write such a function as follows.

function Event_Loop() returns Nothing is
begin
	while(true) begin
		...event processing here...
	end
end

You can see from that never-terminating loop that the function never returns, it just loops around again and again, processing events ad infinitum. (You have to admit, return Never would have fit this situation really well.)

Admittedly, all this one is nothing and nothing is never is… well, confusing. But frankly, once you get passed this minor hurdle, the details of the Scala type system are frankly stunning.

But that, dear reader, is a topic for another day.

Mercury Rising

Sun, 17 Nov 2013, 09:36 AM (-06:00) Creative Commons License

…and in the National Gallery of Art, we saw Mercury rising:

Mercury rising

White House Garden Tour

Sun, 17 Nov 2013, 08:14 AM (-06:00) Creative Commons License

Did I tell you about the garden tour?

What garden tour?

I guess I didn’t tell you. Do you want to know about it?

Actually, I…

We had gone to Washington, D.C. to visit friends who had moved there. We went to see Melissa and Carlyle and Trudy’s friend Karen who was following her boss who had taken a cabinet secretary position. And it turned out that the White House liaison in the agency was giving out tickets to the fall Whitehouse garden tour.

…but I…

We felt so… connected. How many degrees of separation from the President would that have been. Certainly only a few. We were tickled to have tickets. To be in the know.

…I see.

So we met Karen and took the metro to the White House. And when we got there, we should have known something was not quite right.

…not quite right?

Well not not quite right. I mean, not wrong. But it wasn’t as we thought. You see we had these invitations and were feeling all smug, and then we got there, and there was a very, very long line. This was not exactly a small affair. In fact, there were two lines with Park Service rangers asking if we had 1:00 or 1:30 invitations and directing us to the 1:30 line.

…that’s a shame.

But not really a shame, because the line move quickly and the people were generally in a good mood and although it was chilly in the shade, the sky was blue and the sun was shining…

…of course, blue sky and shining sun.

…and the grass was green.

..right.

So we eventually got in and gazed in earnest admiration at the various trees planted by the various presidents over the years. And we filed by the south portico.

DSC 1470

…very nice.

And we peered into The Rose Garden and gawked at the empty podium there.

DSC 1485

I mean this is really six degrees of separation stuff, right? What, the day before he must have been out there talking to…

…to someone.

Precisely. So anyway, we walked past the White House and admired the west side of the south lawn. There were more trees there, …

DSC 1505

…more trees.

and we could see the Old Executive Office Building just nearby. (I’ve always been a pushover for that building.)

DSC 1502 DSC 1512

…of course. 

Did you know that from the South Lawn you look past a fountain across the Ellipse to the Washington Monument?

…I think I knew that.

And that from there you look out across the Tidal Basic at the Jefferson Memorial?

…I didn’t…

I didn’t either. And so I must confess that this is the reason I wanted to tell you this. I wanted to tell you what a spectacular view that was, standing there beside the lush green grass of the White House South Lawn on a sunny, cloudless fall day with the White House itself behind us

 

DSC 1508

gazing to the south at the Washington Monument wrapped in protective scaffolding ever since the earthquake, gazing at the Jefferson Memorial

DSC 1480

thru the Jefferson Memorial, because we could see daylight on the other side.

DSC 1478

As I said, it was a spectacular view.

…very nice.

And there was the Marine Corps band playing at the foot of the hill. And there was the vegetable garden. But here’s what I really wanted to tell you.

…oh.

When we left the South Lawn and began walking around the Ellipse to the Mall, we passed a couple people who were distributing some kind of flyers. They looked like students. They had badges hanging from their necks, and they had that youthful college intern look.

…ah.

And as we got up to them, they held out the flyers to us and asked us, “Do you need tickets to the garden tour?”

…um.

The three of us looked at each other. These two interns were holding thick stacks of Fall White House Garden Tour invitations. The same select invitations that got us in. All of the sudden, we didn’t feel quite so … connected.

But whatever. We had a good time, and it was a beautiful day. We left the White House behind us and headed toward the National Gallery of Art.

…which can be a story for some other time, right?

Sure.

Fairness

Sun, 17 Nov 2013, 12:03 AM (-06:00) Creative Commons License

Ok, so this isn’t fair.

We’re up at 5:45am. Before the rising of the sun. Before the rising of the dogs. We’re out of the house by 6:32. To go running. Six miles for the fair and industrious Trudy. Ten for me, although truth be told, the hills and progression miles took their toll and had me walking in spurts at the end so ten is not likely an accurate count. But you get the idea.

And then we’re out running errands. Acupuncture appointments. Baby gifts for Alex and Kim next door. Reflective running gear for those runs in the dark that will come next week and next and next. And although Trudy managed to sneak in a nap or two in the middle of the day, I didn’t. Concentrating as I was in front of the computer for a while on VirtualBox and Vagrant and Puppet and yum updates that are failing because nothing needs updating.

So at the end of the long day, I finally lay me down to sleep. But no. No sleep.

Wide eyes. Stevie Wonder bouncing thru my brain, because I had the temerity to actually play some music on the stereo yesterday (my brother would be proud) and Masterblaster was the last thing I played and my brain is evidently stuck in infinite replay mode.

No sleep. As Trudy breathes long in-and-out breaths, I’m thinking of SQL queries. And the hedge in the back that needs clipping. And the pergola that’s going to fall down any day now. And the irises that need to be dug up and clipped. And the two Bluebonnets that I saw sprouting next to the tomatoes that froze the other night before it got to be in the 80s today. And the compost piles that need to be consolidated. And wouldn’t it be nice to have different house numbers on the outside of the house under the light thrown down by our new sconces?

It isn’t fair.

© jumpingfish by David Hasan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License