james mckay dot net
because there are few things that are less logical than business logic

Power-only micro USB leads are a thing

So I took delivery of a new Arduino Micro at the weekend. Since this is my first foray into Arduino development, naturally I had to download and install the Arduino IDE and then plug the thing in. So I got out a micro USB lead and plugged it into the computer.

The LEDs on the board came on as they’re supposed to. All well and good so far. But when you connect an Arduino to your computer and load up the Arduino IDE, it’s supposed to show up in the “Select Board” dropdown menu at the top:

Mine didn’t:

I tried adding it manually through the “Select other board and port…” option:

No ports detected. The “Ports” option in the “Tools” menu was greyed out.

I tried unplugging and replugging it. The computer didn’t beep as it normally does when you plug something in. I tried looking in the Windows device manager … not a trace of it. I tried updating and installing drivers … again, nothing. I tried a second micro-USB lead … yet again, nothing. I tried resetting it. I tried updating all my Windows device drivers. Again, nothing. As far as I could tell, I had just spent twenty pounds on a brick.

It was later in the evening that I tried it with a third lead … to find that this time it worked.

It turns out that power-only micro USB leads are a thing. Most USB cables have four conductors inside them — two for power and two for data — but both of the ones that I had originally tried were power-only ones. In fact out of the seven spare micro USB cables that I have accumulated over the years, both of the first two that I had tried had only two. Cutting one of them in two and stripping back the insulation showed that this indeed was the case:

To add insult to injury, this one has the USB trident logo on it. If it doesn’t support data transfer, it’s not supposed to. Thanks to cheap-and-nasty knock-offs such as this, there’s no reliable way to tell at a glance which micro USB cables support data transfer and which ones do not. Cutting the second failed cable in two confirmed that it, too, had only two conductors.

Fortunately all my other micro USB leads were fine, so I’m now ready to get my teeth into some proper Arduino hacking in my spare time. But as for the two power-only ones, to avoid any further confusion, I’ve thrown them away.

“Seven plus nine is not six”

I can’t remember what the exact question was, but I do remember that it involved adding two three-digit numbers together. Let’s just say it was 247 + 389. Which, as any reasonably intelligent seven year old should be able to work out, comes to 636.

Seven year old yours truly had worked this out, only to have it marked wrong.

Say what?!!?

I went over my working carefully. Seven plus nine is sixteen. Six in the ones column, carry one, add one to four plus eight gives thirteen. Three in the tens column, carry one again, add one to two plus three gives six. Six hundred and thirty six.

I wrote out the sum again, handed my work in again, and yet again it came back marked wrong.

I got hold of a pocket calculator when I got home. Much as it may be hard for some of my younger readers to believe, those were actually a thing when I was seven years old, though of course we weren’t allowed to use them in class.

247 + 389 = 636.

I did the sum a third time, handed my work in again, and a third time it came back marked wrong. With the dreaded words “See me” in red pen next to it.

I duly went up to the teacher’s desk.

“Seven plus nine is not six,” she said.

I didn’t know how to respond to that. I knew that seven plus nine is not six. But seven plus nine is sixteen. It still has a six at the end, you still write six in the ones column, you just have to carry one over into the tens column, and I had even written a little “1” there, as I had been taught to do, to show that that was what I’d done. But Mrs Lester was a rather stern kind of teacher and I was too shy to answer back to her, so I quietly returned to my seat feeling confused, not sure what to do next, and if truth be told, rather offended.

It’s only recently, however, that I wondered if maybe she was actually trying to teach me something important. Something that every good teacher should be teaching their students.

Your teacher isn’t always right, and when they aren’t, you should challenge them.

One of the most important things that every teacher should be instilling into their students is critical thinking. Asking questions, fact-checking, and not swallowing everything you’re being told hook, line and sinker are important skills.

Now from time to time I hear people claiming that they’re “encouraging critical thinking” when in reality they are doing nothing of the sort. Pseudoscientists and conspiracy theorists are especially bad at this: they will proudly tell you that they are doing so because they are “questioning mainstream narratives.” But in reality, all they are doing is swapping out “mainstream narratives” for their own particular brand of pseudoscience or conspiracy theories. If you start applying critical thinking to their own claims, their enthusiasm for the aforementioned critical thinking quickly evaporates.

If your aim in teaching “critical thinking” is simply to get your students to think like you, or to repeat exactly what you are teaching them, then you aren’t teaching critical thinking at all; you’re spoon feeding them. On the other hand, one way that you can tell that you are getting it right is that your students start challenging you.

Introducing the occasional mistake into your teaching material can be a good way to do this, but it needs to be done carefully. The mistakes need to be ones that you should reasonably expect your students to spot, otherwise you will be teaching them misinformation. You should also make sure that you are giving your students the confidence that they need to challenge you. Stern, strict, no-nonsense or authoritarian teachers probably won’t be able to pull this off, especially with children who don’t have a great deal of confidence to begin with. But the lesson is one that every good teacher should be teaching their students. Make sure that you’re teaching them to think critically about what you yourself are teaching them—and that you’re giving them the space and the confidence to challenge you when you get it wrong.

Featured image credit: Wikimedia Commons

Accurate and honest metric weights and measurements

My height is 1 metre and 78 centimetres. I refuse point-blank to quote that in feet and inches.

My weight, as of 12:30 on Saturday 19 August, is 79.8 kilograms. One again, I don’t care what that is in stones and pounds, so working it out is left as an exercise for the reader.

Over the past three months I have made it my goal to take a five kilometre walk every day that I can. Once again, converting that into miles is left as an exercise for the reader.

Those who have engaged in discussions with me in (sometimes lively) debates about science and faith will be aware that one particular passage from the Bible that I am always quoting, over and over again, is Deuteronomy 25:13-16, which says this:

13Do not have two differing weights in your bag — one heavy, one light. 14Do not have two differing measures in your house — one large, one small. 15You must have accurate and honest weights and measures, so that you may live long in the land the Lord your God is giving you. 16For the Lord your God detests anyone who does these things, anyone who deals dishonestly.

It should come as no surprise, therefore, to learn that I am an ardent proponent of metrication, frustrated at the lack of progress that the UK has made in this area since the initial push in the 1960s and 1970s, and totally opposed to any attempt to head in the opposite direction.

This one should be a no-brainer. With the exception of the UK, the USA, Myanmar and Liberia, almost every other nation on Earth uses metric units exclusively. It’s not hard to see why either. Metric units of measurement make sense. Different measurements of the same units are related to each other by multiples of ten, with a consistent set of prefixes denoting their relationships. So getting from metres to kilometres, grams to kilograms, bytes to kilobytes and so on, you just notice the word “kilo” at the start and multiply by one thousand.

On top of that, metric units, or SI units, are the foundation for measurement in science, engineering, commerce, finance, law, education and just about every other context where measurement is used. They are based on well defined, easily measurable, high-precision quantities. They are consistent, unambiguous, precise, easy to understand, easy to work with, internationally recognised, and exactly the same everywhere you go. They are the lingua franca of accurate and honest weights and measurements worldwide.

Imperial measurements, by contrast, are a mess. There are sixteen ounces in a pound and fourteen pounds in a stone—or is it the other way around? Up until the nineteenth century, the number of pounds in a stone varied depending on where you were and on what was being measured. There are eight furlongs in a mile, ten chains in a furlong, 22 yards in a chain, three feet in a yard, twelve inches in a foot … how on earth are you supposed to remember all the details? British and American gallons are different. British and American tons are different. I have no idea how much a fluid ounce is supposed to be. Repeat after me: an acre is the area of a rectangle whose length is one furlong and whose width is one tenth. None of it offers you a shred of sense or coherence whatsoever.

Someone asked me the other day on Facebook, in response to my quoting of Deuteronomy 25 yet again, whether I thought that having a mixture of imperial and metric measurements was unbiblical. I replied that it quite possibly could be. Having two different systems of measurement makes it a whole lot harder for consumers to compare like for like when trying to figure out how much something costs. Supermarkets being supermarkets, they will take every opportunity they legally can to pull off shenanigans like that. This was a concern back in the 1970s when the push for metrication was in full swing, and it would be a concern if we were to try to turn the clock back to imperial ones again.

Unfortunately, there are certain politicians here in the UK who, in the wake of Brexit, want to do precisely that. One of the most prominent of these is, of course, the Right Honourable Member for the eighteenth century, Sir Jacob Rees Mogg, who instructs his staff, in no uncertain terms, that imperial measurements they must use. The only reason why anyone would want to do things such as this is some sort of misguided rose-tinted nostalgia for the good old days of the 1940s and 1950s or earlier. Why don’t we just bring back post-war rationing, outside loos, black and white TV, and horses and carriages while we’re at it?

The time I forgot about the speed of light


The Fallacies of Distributed Computing are a set of eight assumptions, originally noted by L Peter Deutsch and others at Sun Microsystems, that are commonly made by programmers and architects who are new to distributed computing and network architecture. They are:

  1. The network is reliable;
  2. Latency is zero;
  3. Bandwidth is infinite;
  4. The network is secure;
  5. Topology doesn’t change;
  6. There is one administrator;
  7. Transport cost is zero;
  8. The network is homogeneous.

All eight of these assumptions are wrong. In fact, these eight fallacies are the reason why Martin Fowler came up with his First Law of Distributed Object Design: don’t distribute your objects.

The first time I fell foul of these fallacies was particularly embarrassing, because it was in a situation where I should have known better.

I was working for a small web agency at the time. A lot of our work was graphic design, webmastering and SEO for local businesses, but we had a few larger clients on our books for whom we had to do some actual coding and server administration. One of them was an airport taxi reservations company who wanted a new front end for their online portal.

Their database was running on SQL Server Express Edition (the free but hopelessly under-powered version), on the same server as the web front end, hosted in a data centre in Germany. Because this was running at pretty much full capacity, they asked us to move it to a larger, beefier server. Since this meant moving up to one of the paid editions, my boss did a bit of shopping around and came to the conclusion that we could save several thousand euros by moving the database to a hosting provider in the USA. Due to the complexity of the code and the fact that it was running on a snowflake server, however, the web front end had to stay put in Germany.

He asked me what I thought about the idea. I may have raised an eyebrow at it, but I didn’t say anything. It sounded like a bit of an odd idea, but I didn’t see any reason why it shouldn’t work.

But I should have. There was one massive, glaring reason — one that I, in possession of a physics degree, should have spotted straight away.

The speed of light.

The ultimate speed limit of the universe.

It is 299,792,458 metres per second now and it was 299,792,458 metres per second then. It has been 299,792,458 metres per second everywhere in the visible universe for the past 13.8 billion years, and expecting it to change to something bigger in time for our launch date would have been, let’s just say, a tad optimistic.

Now that distance may sound like a lot, but it’s only 48 times the distance from Frankfurt to New York. It simply isn’t physically possible for a web page in Germany to make more than twenty or so consecutive requests a second to a database in America — and many web pages in data-driven applications, ours included, need a whole lot more requests than that.

Needless to say, when we flipped the switch, the site crashed.

To say this was an embarrassment to me is an understatement. I should have spotted it immediately. I have a university degree in physics, and the physics that I needed to spot this was stuff that I learned in school. What was I thinking?

Featured image by WikiImages from Pixabay

Light speed

As you will no doubt be aware, the speed of light in a vacuum is 299,792,458 metres per second exactly. It always has been, and it always will be. In fact, so confident are physicists that it has never changed that since 1983, it has been used as the definition of the metre in the SI system of units.

And now, here it is, in a sudoku.

Normal sudoku rules apply. Digits on thermometers increase from the bulb end. Cells separated by a knight’s move in chess can not contain the same digit.

Try it on f-puzzles.com.