# Quality assurance fail

Some fun for Friday. I just opened up a box containing a brand-new bit of telecommunications equipment, and the power supply arrived looking like this, fresh out of the box. (Click for a larger version.)

How bad does your quality assurance have to be to ship to customers a power supply that cannot possibly fit into a power socket?

# Rerun: I have a mysterious fifth sense

Today, another of my ongoing series of reruns of my fun-for-Friday non-computer posts. Here's one from the dot-com recovery of 2004.

The economy must be picking up -- I'm getting cold calls from recruiters again for the first time in about four years.  Today was the second - and third - this month.

However, apparently some of them are just a wee bit disorganized. I just had the following conversations:

[Ring ring]

Me: Hi, this is Eric.

Her: Hi, this is Barbara1 at XYZ Recruiters. How are you today?

1. I learned later from some of my fellow Microsoftie bloggers that it appeared that Barbara was calling everyone at Microsoft with an MSDN blog. She must have been repeatedly calling the switchboard and asking to speak with each.

# That's a big transistor

As promised last time, a fun-for-Friday rerun from the early days of FAIC. But before we get started, a quick physics refresher.

Force is the ability to change the velocity of an object by a certain amount in a given amount of time. One newton (N) of force is the ability to change the velocity of a one kilogram object by one meter per second, in one second. The earth applies a force of gravity of 9.8N on every 1kg mass near it.

Work is the application of a force to an object as it moves a certain distance. Energy is the ability to do work. One joule (J) of energy is the ability to apply a force of one newton to an object as it moves one meter. 1

Power is the rate at which energy is consumed in time. One watt (W) of power is the consumption of one joule of energy per second.

Charge is, like mass, a fundamental property of matter. The easiest way to manipulate charge is by manipulating electrons. Charge is measured in coulombs (C). Current is the movement of charge and is measured in amperes (A); one ampere is one coulomb of charge moving past a given point in one second.

Electric potential, better known as voltage, is to charge as gravity is to mass, and is measured in volts. Applying a potential of one volt to one coulomb of moving charge consumes one joule of energy. A better way to think about it though is to divide both sides of that equation by time and get that one volt times one amp is one watt.2

Resistance is the tendancy of an electric conductor to resist the movement of charge, and is measured in ohms (Ω). If there is a conductor where the difference in voltage between the two ends is one volt, and the resistance is one ohm, then there will be a one amp current in the conductor.

A few years back a bunch of my coworkers and I got to discussing the space program over lunch. Someone asked why it is that we continue to launch devices into orbit by strapping a big old tank full of liquid oxygen to the device and then set it on fire. Why haven't we developed better technology using magnets or something?

1. Note that the force has to be applied in the direction of the motion for it to count as work; the earth's gravitational force does no work on a sideways-moving object. This should jibe with your intuitive understanding of work; it is a lot harder to raise an object by 1 meter than it is to slide it 1 meter, where the work is done by the force overcoming friction.
2. volts times amps equals watts is one of the funamental equations you have to know in order to wire a house safely. If your house power is providing a potential of 120V and your light bulb is consuming 120W of power then the current on the wire supplying the bulb is 1A. Since lighting circuits typically use wires that are safe for up to 15A, this puts a limitation on how many bulbs you can have on one circuit.

# Building a tabletop coilgun

As you probably know, I've been re-running some of my fun non-computer posts from the last decade. This Friday I'm going to rerun my post on the impracticalities of large-scale coilguns, and I thought that as a precursor to that I might talk a bit about tabletop coilguns. So, no programming language design this week.

A couple years ago my friend Morgan expressed an interest in learning about electronics so I thought that a homemade coilgun would of course be a perfect gift for a ten year old.1 This is a great project to teach kids about circuits because it has all of the basic parts except transistors, and each part has a clear purpose.2

1. Yes, I am that awesome avuncular figure who gets kids pocket knives and drum sets and coilguns for their birthdays. Parents, you're welcome!
2. I've deliberately left the voltages, capacitances, resistances and inductances I chose off the circuit diagram above. Better to work them out for yourselves on the basis of what kinds of voltages sources and what capacitors you've got available, and what your appetite for destruction is.

# Thumbs up

Roger Ebert was -- is -- a hero of mine. I've often thought that if I could be one tenth as clear, witty, insightful and kind, I'd consider myself a good writer.

I remember getting a copy of Microsoft Cinemania in the early 1990s, casually browsing the archive of Ebert reviews and realizing that here was someone who really, really knew how to write -- and from that point on I was hooked. In the decades since then I don't think I've rented a movie or gone to the theater without checking to see what Ebert had to say about it first. On the few occasions when he wrote something that moved me to respond directly he always answered my emails thoughtfully and kindly. That he took the time at all out of his incredibly busy life to answer fan emails is just one small example of his generosity.

Tonight I'm going to take AV Club reviewer Zack Handlen's advice and watch Citizen Kane again with Roger's commentary track. It'll be good to hear his voice.

# Whidbey Island and bagel mathematics (rerun)

Today another in my fun-for-a-Friday series of reruns from the classic days of FAIC. This one was originally published in December of 2004. Enjoy!

I was highly amused to read on Raymond Chen's blog the other day that mathematicians are hard at work solving the problem of how to most evenly distribute poppyseeds over a bagel. The reason I was highly amused was not just the whimsical description of what is actually a quite practical and difficult problem.

And yes, believe it or not, it is a practical problem; if you can figure out how to distribute points evenly around an arbitrary shape then you can use that information to develop more efficient computer algorithms to solve complex calculus problems that come up in physics all the time. There are also applications in computer graphics, I'd imagine; 3-D modeling frequently requires generating well-behaved finite approximations of a surface.

But I digress. The other reason I was highly amused is that Whidbey Island is the longest island in the United States.

# Free beer!

Most of the Coverity C# analysis team is going to be in Seattle celebrating the opening of our new office on Wednesday February 20th. We'll be at the Tap House Grill on 6th Avenue in Seattle, starting about 6:15. If you're in Seattle at that time, over 21 years old, and want to hang out with me and the team then please stop by!1

There are a very small number of free drink tickets available; if you want one, email me (Eric@Lippert.com) and I'll send you instructions on how to sign up. Supplies are limited, so serious enquiries only please.

1. Note that this is the Tap House Grill in Seattle, not the one in Bellevue.

# Digital pain (rerun)

Today, another fun-for-your-Friday rerun from the past decade of FAIC.

When you bang your finger with a hammer or burn it on the stove, somehow the pain has to get from your finger to your brain via a nerve. That's an immense distance on the cellular level. What possible mechanisms are there for that?

A nerve carries the pain signal from your finger to your brain like a wire carries electrical current. Perhaps zero "voltage" on that nerve would represent "no pain", and then the "voltage" would vary smoothly up to some maximum that represented "extreme pain". That's a plausible mechanism.

Or, you could have a system where zero "voltage" meant "no pain", 100% meant "severe pain", and any lesser amount of pain is measured by the average power delivered over a period of time, say, a millisecond. If the nerve was on 100% for 250 microseconds, then off for 750 microseconds, that indicates a 25% level of pain. If it was then on for 220 microseconds, off for 780, then on for 200, off for 800, that would indicate that pain was decreasing from 25% to 22% to 20%. The granularity of a millisecond might not be quite right, but in principle this would work. 1

Both of those are analog systems: in an analog system the possible signals smoothly vary from 0% to 100%. But neither of them are how nervous systems actually work. If you measure the "signal strength" on pain nerves you see that they actually send groups of extremely short bursts, where the number of bursts per unit time indicates the level of pain. That is, the nervous system communicates pain by sending an integer from the source of the pain to the brain! It's discrete, not analog.

Why is that?

You know what my favourite scene in the movie version of The Return of the King
is? It's the one where Gandalf needs to send a message to Rohan in a hurry, so he has Pippin climb up the side of a mountain to light a signal beacon. We then see this great sequence as the beacon wardens set off the seven signal fires on Amon Din, Eilenach, Nardol, Erelas, Min-Rimmon, Calenhad and Halifirien, one after the other.

Listen carefully to the soundtrack at this point. It echoes Gandalf's "White Rider" theme, which was established earlier in a visually parallel set of shots, as Gandalf and Pippin ride up the seven levels of Minas Tirith. But to give it some additional fire, they add these kick-ass violin arpeggios on top of the basso continuo. The whole thing works perfectly; it's a triumph of cinematography!

But I digress.

The Gondorian war beacon system sends a single binary bit at extremely high speed over the huge distance from the White Tower in Gondor to Meduseld in Rohan. Suppose the Gondorians wanted to send more information than just "we need help!" -- like, say, how big the opposing army was. They could come up with an analog convention. Perhaps a really big signal fire indicates a really big army, a small signal fire indicates a small army, a medium sized signal fire indicates a medium-sized army.

Obviously that doesn't work. There are seven beacon fires. The beacon keepers would have to figure out how big the previous fire was and then set their fire accordingly. Error would accumulate along each part of the process, and the final result might bear little relation to the original input.

To send information accurately over long distances without error you need some kind of discrete system. You need signals that are clearly either ON or OFF. Once you've got ON and OFF, you can use them to transmit integers, letters, morse code, whatever you want.

That is why nerves are digital, not analog. Nerves need to transmit huge amounts of complex data over the vast distance from your toes to your brain without accruing any error along the way as the signal is picked up by new nerves and forwarded on. All the sensory nerves work this way: smell, touch, taste and so on, are digital. We are digital machines, we're just digital machines made out of meat instead of silicon.

Next time on FAIC: We'll resume the current series on uses and abuses of the static constructor.

1. Lighting circuit dimmer switches work using these two mechanisms. Old-style dimmer switches work by adding a resistance to the line that decreases the voltage overall, and modern dimmer switches work by cutting out a certain percentage of the power signal.

# Hummingbird PSA

We interrupt our adventures in lifted arithmetic optimization for a brief public service announcement on behalf of my little friend to the left there. (Click on the image for a larger version.) I took this photo1 at my home in Seattle this past Sunday, before I flew down to San Francisco for training at Coverity's head office. Amazingly enough, male Anna's Hummingbirds like my friend there will spend winters in Seattle. At the time this photo was taken it was well below freezing. Apparently more and more male hummingbirds are staying in Seattle over the winter, as climate change makes the winters here slightly more survivable; even Rufous and Allen's hummingbirds are being observed.

Hummingbirds are always within mere moments of starving to death and in the Seattle winter there are far fewer sources of food than other times of the year,2 so if you've got hummingbirds coming to a feeder,3 keep it stocked. Take it in at night; I found my feeder frozen solid and a very vexed hummingbird trying in vain to feed one morning.

You'll notice that in my feeder the liquid is clear and colourless. It is one part sugar to three or four parts water, and that's it. Stores will try to sell you hummingbird food at enormously inflated prices, but what they're selling is sugar mixed with red dye. The red dye does nothing to attract the birds, and it is bad for them. Their little kidneys have to remove the dye from their bloodstream.

I'm in California again next week, but I've queued up a couple of articles to go out while I'm away. Have a great weekend, and tune in Monday for the final episode in my excessively long series on lifted arithmetic optimization.

1. It took a number of attempts to freeze the wings, even at 1/640th of a second shutter speed with my Canon DSLR.
2. Anna's Hummingbirds are unusual in that they can eat bugs while in flight, which does help.
3. A number of people have asked me where they can get my feeder; you can find it here.

# The postmodern gumballs (rerun)

I've been writing this blog for almost ten years now and there are plenty of readers who have quite reasonably never gone back through that archive of over 750 posts. Maybe one Friday a month or so, I'm going to rerun one of my favourite "fun" posts from the last decade. Today, a story I posted on the first anniversary of my blog, in September of 2004. Enjoy!

It's hard to believe it but it's true: I've been at this for an entire year. How the time has flown. In honour of my first blogoversary, today I bring you a story that has absolutely nothing to do with anything. I promised a while back that I’d tell you all the story of the Postmodern Gumballs and today's the day. Names have been changed to silly code names to protect the innocent. All silly code names were approved by the people thus encoded.

One day, long ago, in the summer term of 1992 I bicycled in to school as usual. Except this time I stopped at the bulk food store in Highland Hills mall along the way and bought a big bag of sour gumballs. But these were not ordinary sour gumballs. They were incredibly awful-tasting sour gumballs. But these were not just incredibly awful-tasting sour gumballs. They were stale incredibly awful-tasting sour gumballs. Moreover, though they began excruciatingly sour, the flavour all drained out of them in about two minutes, leaving the chewer with a mouth full of bland, stale-tasting rubber and an intense craving for more.

I arrived way early for class. This was a small class, only eight students. I think it was 1B advanced algebra or calculus or some such thing. So I’m sitting there, popping awful gumball after awful gumball, when in walks Mr. Thingo1.

"Thingo!" says I, "Would you like some gum? These gumballs are not only bad-tasting and excruciatingly sour, but they’re stale to boot and highly addictive. Have a few."

A few minutes later, the Singular Orbifold showed up. Thingo and I pounced. "Orbifold! Have some gumballs! They’re bad-tasting and exceedingly stale, and you’ll end up with a wad of disgusting rubbery goo in your mouth that you don’t dare swallow yet cannot spit out. Want some?"

"Sure!" said Orbifold, though to be frank, he looked slightly dubious.

A few minutes later, the Essential Singularity walked in. We three cornered her, chewing furiously.

"Ingrid, I mean, Essential Singularity! Would you like some sour gumballs? They’re stale and bad tasting!"

"No!" said the Essential Singularity, "of course not!"

"But all your friends are doing it."

"Oh. Well, OK then."

And we all miserably chewed great grey gobs of disgusting gum for the next fifty minutes.

I’m salivating just thinking about it.

You see of course what the philosophical importance was. The four of us had discarded objectivity, rejected opinions of conventional authority and disdained those universally held ideological absolutes so incorrectly described as "truths". We broke down our hitherto established standards, categories, distinctions and boundaries. At least, we did all that insofar as gumball quality was concerned: we chewed the Postmodern Gumballs.

Next time on FAIC: A new beginning!

1. Who is now Professor Thingo in that very same faculty, interestingly enough.