Wednesday, March 14, 2018

JavaScrypt Updated

I have just posted a new version of JavaScrypt, the first major update in thirteen years.

JavaScrypt is a collection of Web pages which implement a complete symmetrical encryption facility that runs entirely within your browser, using JavaScript for all computation. When you encrypt or decrypt with JavaScrypt, nothing is sent over the Internet; you can run JavaScrypt from a local copy on a machine not connected to the Internet. JavaScrypt encrypts with the Advanced Encryption Standard (AES) using 256 bit keys: this is the standard accepted by the U.S. government for encryption of Top Secret data. (While JavaScrypt is completely compatible with AES, it has not been certified by the U.S. National Security Agency as an approved cryptographic module and should not be used in applications where this is a requirement.) Companion modules provide a text-based steganography facility and generation of pass phrases and encryption keys.

This update is 100% compatible with earlier releases of JavaScrypt: encrypted files can be exchanged by the old and new versions with no difficulties. The updates bring JavaScrypt in line with contemporary Web standards.

  • All HTML files are now XHTML 1.0 Strict and verified for compliance.
  • There is a uniform CSS style sheet for all pages and the style is more pleasing to the eye.
  • Unicode typography is used for characters such as quotes, ellipses, and dashes.
  • All JavaScript files now specify “use strict” and are compliant with that mode.
  • <label> containers are used on check boxes and radio buttons so you can click the labels as well as the boxes.
  • Added the option to generate signature for pass phrases using the SHA-224 and SHA-256 hash algorithms in addition to MD5.
  • Citations to books on Amazon have been updated to reference the latest editions and links changed to the current recommended format.

For complete details of the changes in this version, see the development log.

If you've been using the previous version of JavaScrypt and start to use the update, you may encounter some JavaScript errors due to incompatibility between JavaScript files stored in your browser's cache and the new HTML documents. Flushing your browser's cache and reloading the page should remedy these problems. (This shouldn't be necessary if browsers were competently implemented, but after more than twenty years seeing this done wrong, I despair of its ever being fixed.)

Posted at 23:01 Permalink

Thursday, February 15, 2018

Reading List: The Ministry of Ungentlemanly Warfare

Lewis, Damien. The Ministry of Ungentlemanly Warfare. New York: Quercus, 2015. ISBN 978-1-68144-392-8.
After becoming prime minister in May 1940, one of Winston Churchill's first acts was to establish the Special Operations Executive (SOE), which was intended to conduct raids, sabotage, reconnaissance, and support resistance movements in Axis-occupied countries. The SOE was not part of the military: it was a branch of the Ministry of Economic Warfare and its very existence was a state secret, camouflaged under the name “Inter-Service Research Bureau”. Its charter was, as Churchill described it, to “set Europe ablaze”.

The SOE consisted, from its chief, Brigadier Colin McVean Gubbins, who went by the designation “M”, to its recruits, of people who did not fit well with the regimentation, hierarchy, and constraints of life in the conventional military branches. They could, in many cases, be easily mistaken for blackguards, desperadoes, and pirates, and that's precisely what they were in the eyes of the enemy—unconstrained by the rules of warfare, striking by stealth, and sowing chaos, mayhem, and terror among occupation troops who thought they were far from the front.

Leading some of the SOE's early exploits was Gustavus “Gus” March-Phillipps, founder of the British Army's Small Scale Raiding Force, and given the SOE designation “Agent W.01”, meaning the first agent assigned to the west Africa territory with the leading zero identifying him as “trained and licensed to use all means to liquidate the enemy”—a license to kill. The SOE's liaison with the British Navy, tasked with obtaining support for its operations and providing cover stories for them, was a fellow named Ian Fleming.

One of the SOE's first and most daring exploits was Operation Postmaster, with the goal of seizing German and Italian ships anchored in the port of Santa Isabel on the Spanish island colony of Fernando Po off the coast of west Africa. Given the green light by Churchill over the strenuous objections of the Foreign Office and Admiralty, who were concerned about the repercussions if British involvement in what amounted to an act of piracy in a neutral country were to be disclosed, the operation was mounted under the strictest secrecy and deniability, with a cover story prepared by Ian Fleming. Despite harrowing misadventures along the way, the plan was a brilliant success, capturing three ships and their crews and delivering them to the British-controlled port of Lagos without any casualties. Vindicated by the success, Churchill gave the SOE the green light to raid Nazi occupation forces on the Channel Islands and the coast of France.

On his first mission in Operation Postmaster was Anders Lassen, an aristocratic Dane who enlisted as a private in the British Commandos after his country was occupied by the Nazis. With his silver-blond hair, blue eyes, and accent easily mistaken for German, Lassen was apprehended by the Home Guard on several occasions while on training missions in Britain and held as a suspected German spy until his commanders intervened. Lassen was given a field commission, direct from private to second lieutenant, immediately after Operation Postmaster, and went on to become one of the most successful leaders of special operations raids in the war. As long as Nazis occupied his Danish homeland, he was possessed with a desire to kill as many Nazis as possible, wherever and however he could, and when in combat was animated by a berserker drive and ability to improvise that caused those who served with him to call him the “Danish Viking”.

This book provides a look into the operations of the SOE and its successor organisations, the Special Air Service and Special Boat Service, seen through the career of Anders Lassen. So numerous were special operations, conducted in many theatres around the world, that this kind of focus is necessary. Also, attrition in these high-risk raids, often far behind enemy lines, was so high there are few individuals one can follow throughout the war. As the war approached its conclusion, Lassen was the only surviving participant in Operation Postmaster, the SOE's first raid.

Lassen went on to lead raids against Nazi occupation troops in the Channel Islands, leading Churchill to remark, “There comes from the sea from time to time a hand of steel which plucks the German sentries from their posts with growing efficiency.” While these “butcher-and-bolt” raids could not liberate territory, they yielded prisoners, code books, and radio contact information valuable to military intelligence and, more importantly, forced the Germans to strengthen their garrisons in these previously thought secure posts, tying down forces which could otherwise be sent to active combat fronts. Churchill believed that the enemy should be attacked wherever possible, and SOE was a precision weapon which could be deployed where conventional military forces could not be used.

As the SOE was absorbed into the military Special Air Service, Lassen would go on to fight in North Africa, Crete, the Aegean islands, then occupied by Italian and German troops, and mainland Greece. His raid on a German airbase on occupied Crete took out fighters and bombers which could have opposed the Allied landings in Sicily. Later, his small group of raiders, unsupported by any other force, liberated the Greek city of Salonika, bluffing the German commander into believing Lassen's forty raiders and two fishing boats were actually a British corps of thirty thousand men, with armour, artillery, and naval support.

After years of raiding in peripheral theatres, Lassen hungered to get into the “big war”, and ended up in Italy, where his irregular form of warfare and disdain for military discipline created friction with his superiors. But he got results, and his unit was tasked with reconnaissance and pathfinding for an Allied crossing of Lake Comacchio (actually, more of a swamp) in Operation Roast in the final days of the war. It was there he was to meet his end, in a fierce engagement against Nazi troops defending the north shore. For this, he posthumously received the Victoria Cross, becoming the only non-Commonwealth citizen so honoured in World War II.

It is a cliché to say that a work of history “reads like a thriller”, but in this case it is completely accurate. The description of the raid on the Kastelli airbase on Crete would, if made into a movie, probably cause many viewers to suspect it to be fictionalised, but that's what really happened, based upon after action reports by multiple participants and aerial reconnaissance after the fact.

World War II was a global conflict, and while histories often focus on grand battles such as D-day, Stalingrad, Iwo Jima, and the fall of Berlin, there was heroism in obscure places such as the Greek islands which also contributed to the victory, and combatants operating in the shadows behind enemy lines who did their part and often paid the price for the risks they willingly undertook. This is a stirring story of this shadow war, told through the short life of one of its heroes.

Posted at 00:06 Permalink

Saturday, February 10, 2018

Gnome-o-gram: Experts

Ever since the 19th century, the largest industry in Zambia has been copper mining, which today accounts for 85% of the country's exports. The economy of the nation and the prosperity of its people rise and fall with the price of copper on the world market, so nothing is so important to industry and government planners as the expectation for the price of this commodity in the future. Since the 1970s, the World Bank has issued regular forecasts for the price of copper and other important commodities, and the government of Zambia and other resource-based economies often base their economic policy upon these pronouncements by high-powered experts with masses of data at their fingertips. Let's see how they've done.

World Bank forecasts of copper price vs. actual price, 1970-1995

The above chart, from a paper [PDF] by Angus Deaton in the Summer 1999 issue of the Journal of Economic Perspectives shows, for the years 1970 through 1995, the actual price of copper (solid heavy line) and successive forecasts (light dashed lines) by the august seers of the World Bank. Each forecast departs from the actual price line on the date at which it was issued.

Over a period of a quarter of a century, every forecast by the World Bank has been totally wrong. Further, unlike predictions made by throwing darts while blindfolded, where you'd expect half to be too high and half too low, every single prediction from the 1970s until 1987 erred wildly on the high side, while every one after that date was absurdly pessimistic. You'd have made a much better forecast for the period simply by plotting a random walk between 50 and 100.

And yet people based decisions upon these forecasts, and those in the industry or who depended upon it for their livelihood suffered as a result. Did any of the “experts” who cranked out these predictions suffer or lose their cushy jobs? I doubt it.

In the investment world, firms and forecasters are required to warn potential customers that “past performance is no guarantee of future results”. But in a case like this, past performance is a pretty strong clue that the idiots who turned it in are no more likely to produce usable numbers in the future than a blind monkey firing a shotgun at the chart.

Now, bear in mind what Michael Crichton named the “Murray Gell-Mann Amnesia Effect”:

You open the newspaper to an article on some subject you know well. In Murray's case, physics. In mine, show business. You read the article and see the journalist has absolutely no understanding of either the facts or the issues. Often, the article is so wrong it actually presents the story backward—reversing cause and effect. I call these the “wet streets cause rain” stories. Paper's full of them.

In any case, you read with exasperation or amusement the multiple errors in a story, and then turn the page to national or international affairs, and read as if the rest of the newspaper was somehow more accurate about Palestine than the baloney you just read. You turn the page, and forget what you know.

The next time you hear a politician, economist, or other wonk confidently forecast things five or ten years in the future, remember the World Bank and copper prices. Odds are the numbers they're quoting are just as bogus, and they'll pay no price when they're found to be fantasy. Who pays the price? You do.

Posted at 16:05 Permalink

Sunday, February 4, 2018

Reading List: Life 3.0

Tegmark, Max. Life 3.0. New York: Alfred A. Knopf, 2017. ISBN 978-1-101-94659-6.
The Earth formed from the protoplanetary disc surrounding the young Sun around 4.6 billion years ago. Around one hundred million years later, the nascent planet, beginning to solidify, was clobbered by a giant impactor which ejected the mass that made the Moon. This impact completely re-liquefied the Earth and Moon. Around 4.4 billion years ago, liquid water appeared on the Earth's surface (evidence for this comes from Hadean zircons which date from this era). And, some time thereafter, just about as soon as the Earth became environmentally hospitable to life (lack of disruption due to bombardment by comets and asteroids, and a temperature range in which the chemical reactions of life can proceed), life appeared. In speaking of the origin of life, the evidence is subtle and it's hard to be precise. There is completely unambiguous evidence of life on Earth 3.8 billion years ago, and more subtle clues that life may have existed as early as 4.28 billion years before the present. In any case, the Earth has been home to life for most of its existence as a planet.

This was what the author calls “Life 1.0”. Initially composed of single-celled organisms (which, nonetheless, dwarf in complexity of internal structure and chemistry anything produced by other natural processes or human technology to this day), life slowly diversified and organised into colonies of identical cells, evidence for which can be seen in rocks today.

About half a billion years ago, taking advantage of the far more efficient metabolism permitted by the oxygen-rich atmosphere produced by the simple organisms which preceded them, complex multi-cellular creatures sprang into existence in the “Cambrian explosion”. These critters manifested all the body forms found today, and every living being traces its lineage back to them. But they were still Life 1.0.

What is Life 1.0? Its key characteristics are that it can metabolise and reproduce, but that it can learn only through evolution. Life 1.0, from bacteria through insects, exhibits behaviour which can be quite complex, but that behaviour can be altered only by the random variation of mutations in the genetic code and natural selection of those variants which survive best in their environment. This process is necessarily slow, but given the vast expanses of geological time, has sufficed to produce myriad species, all exquisitely adapted to their ecological niches.

To put this in present-day computer jargon, Life 1.0 is “hard-wired”: its hardware (body plan and metabolic pathways) and software (behaviour in response to stimuli) are completely determined by its genetic code, and can be altered only through the process of evolution. Nothing an organism experiences or does can change its genetic programming: the programming of its descendants depends solely upon its success or lack thereof in producing viable offspring and the luck of mutation and recombination in altering the genome they inherit.

Much more recently, Life 2.0 developed. When? If you want to set a bunch of paleontologists squabbling, simply ask them when learned behaviour first appeared, but some time between the appearance of the first mammals and the ancestors of humans, beings developed the ability to learn from experience and alter their behaviour accordingly. Although some would argue simpler creatures (particularly birds) may do this, the fundamental hardware which seems to enable learning is the neocortex, which only mammalian brains possess. Modern humans are the quintessential exemplars of Life 2.0; they not only learn from experience, they've figured out how to pass what they've learned to other humans via speech, writing, and more recently, YouTube comments.

While Life 1.0 has hard-wired hardware and software, Life 2.0 is able to alter its own software. This is done by training the brain to respond in novel ways to stimuli. For example, you're born knowing no human language. In childhood, your brain automatically acquires the language(s) you hear from those around you. In adulthood you may, for example, choose to learn a new language by (tediously) training your brain to understand, speak, read, and write that language. You have deliberately altered your own software by reprogramming your brain, just as you can cause your mobile phone to behave in new ways by downloading a new application. But your ability to change yourself is limited to software. You have to work with the neurons and structure of your brain. You might wish to have more or better memory, the ability to see more colours (as some insects do), or run a sprint as fast as the current Olympic champion, but there is nothing you can do to alter those biological (hardware) constraints other than hope, over many generations, that your descendants might evolve those capabilities. Life 2.0 can design (within limits) its software, but not its hardware.

The emergence of a new major revision of life is a big thing. In 4.5 billion years, it has only happened twice, and each time it has remade the Earth. Many technologists believe that some time in the next century (and possibly within the lives of many reading this review) we may see the emergence of Life 3.0. Life 3.0, or Artificial General Intelligence (AGI), is machine intelligence, on whatever technological substrate, which can perform as well as or better than human beings, all of the intellectual tasks which they can do. A Life 3.0 AGI will be better at driving cars, doing scientific research, composing and performing music, painting pictures, writing fiction, persuading humans and other AGIs to adopt its opinions, and every other task including, most importantly, designing and building ever more capable AGIs. Life 1.0 was hard-wired; Life 2.0 could alter its software, but not its hardware; Life 3.0 can alter both its software and hardware. This may set off an “intelligence explosion” of recursive improvement, since each successive generation of AGIs will be even better at designing more capable successors, and this cycle of refinement will not be limited to the glacial timescale of random evolutionary change, but rather an engineering cycle which will run at electronic speed. Once the AGI train pulls out of the station, it may develop from the level of human intelligence to something as far beyond human cognition as humans are compared to ants in one human sleep cycle. Here is a summary of Life 1.0, 2.0, and 3.0.

Life 1.0, 2.0, and 3.0

The emergence of Life 3.0 is something about which we, exemplars of Life 2.0, should be concerned. After all, when we build a skyscraper or hydroelectric dam, we don't worry about, or rarely even consider, the multitude of Life 1.0 organisms, from bacteria through ants, which may perish as the result of our actions. Might mature Life 3.0, our descendants just as much as we are descended from Life 1.0, be similarly oblivious to our fate and concerns as it unfolds its incomprehensible plans? As artificial intelligence researcher Eliezer Yudkowsky puts it, “The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.” Or, as Max Tegmark observes here, “[t]he real worry isn't malevolence, but competence”. It's unlikely a super-intelligent AGI would care enough about humans to actively exterminate them, but if its goals don't align with those of humans, it may incidentally wipe them out as it, for example, disassembles the Earth to use its core for other purposes.

But isn't this all just science fiction—scary fairy tales by nerds ungrounded in reality? Well, maybe. What is beyond dispute is that for the last century the computing power available at constant cost has doubled about every two years, and this trend shows no evidence of abating in the near future. Well, that's interesting, because depending upon how you estimate the computational capacity of the human brain (a contentious question), most researchers expect digital computers to achieve that capacity within this century, with most estimates falling within the years from 2030 to 2070, assuming the exponential growth in computing power continues (and there is no physical law which appears to prevent it from doing so).

My own view of the development of machine intelligence is that of the author in this “intelligence landscape”.

The Intelligence Landscape

Altitude on the map represents the difficulty of a cognitive task. Some tasks, for example management, may be relatively simple in and of themselves, but founded on prerequisites which are difficult. When I wrote my first computer program half a century ago, this map was almost entirely dry, with the water just beginning to lap into rote memorisation and arithmetic. Now many of the lowlands which people confidently said (often not long ago), “a computer will never…”, are submerged, and the ever-rising waters are reaching the foothills of cognitive tasks which employ many “knowledge workers” who considered themselves safe from the peril of “automation”. On the slope of Mount Science is the base camp of AI Design, which is shown in red since when the water surges into it, it's game over: machines will now be better than humans at improving themselves and designing their more intelligent and capable successors. Will this be game over for humans and, for that matter, biological life on Earth? That depends, and it depends upon decisions we may be making today.

Assuming we can create these super-intelligent machines, what will be their goals, and how can we ensure that our machines embody them? Will the machines discard our goals for their own as they become more intelligent and capable? How would bacteria have solved this problem contemplating their distant human descendants?

First of all, let's assume we can somehow design our future and constrain the AGIs to implement it. What kind of future will we choose? That's complicated. Here are the alternatives discussed by the author. I've deliberately given just the titles without summaries to stimulate your imagination about their consequences.

  • Libertarian utopia
  • Benevolent dictator
  • Egalitarian utopia
  • Gatekeeper
  • Protector god
  • Enslaved god
  • Conquerors
  • Descendants
  • Zookeeper
  • 1984
  • Reversion
  • Self-destruction

Choose wisely: whichever you choose may be the one your descendants (if any exist) may be stuck with for eternity. Interestingly, when these alternatives are discussed in chapter 5, none appears to be without serious downsides, and that's assuming we'll have the power to guide our future toward one of these outcomes. Or maybe we should just hope the AGIs come up with something better than we could think of. Hey, it worked for the bacteria and ants, both of which are prospering despite the occasional setback due to medical interventions or kids with magnifying glasses.

Let's assume progress toward AGI continues over the next few decades. I believe that what I've been calling the “Roaring Twenties” will be a phase transition in the structure of human societies and economies. Continued exponential growth in computing power will, without any fundamental breakthroughs in our understanding of problems and how to solve them, allow us to “brute force” previously intractable problems such as driving and flying in unprepared environments, understanding and speaking natural languages, language translation, much of general practice medical diagnosis and routine legal work, interaction with customers in retail environments, and many jobs in service industries, allowing them to be automated. The cost to replace a human worker will be comparable to a year's wages, and the automated replacement will work around the clock with only routine maintenance and never vote for a union.

This is nothing new: automation has been replacing manual labour since the 1950s, but as the intelligence landscape continues to flood, not just blue collar jobs, which have already been replaced by robots in automobile plants and electronics assembly lines, but white collar clerical and professional jobs people went into thinking them immune from automation. How will the economy cope with this? In societies with consensual government, those displaced vote; the computers who replace them don't (at least for the moment). Will there be a “robot tax” which funds a basic income for those made redundant? What are the consequences for a society where a majority of people have no job? Will voters at some point say “enough” and put an end to development of artificial intelligence (but note that this would have to be global and enforced by an intrusive and draconian regime; otherwise it would confer a huge first mover advantage on an actor who achieved AGI in a covert program)?

The following chart is presented to illustrate stagnation of income of lower-income households since around 1970.

Income per U.S. Household: 1920–2015

I'm not sure this chart supports the argument that technology has been the principal cause for the stagnation of income among the bottom 90% of households since around 1970. There wasn't any major technological innovation which affected employment that occurred around that time: widespread use of microprocessors and personal computers did not happen until the 1980s when the flattening of the trend was already well underway. However, two public policy innovations in the United States which occurred in the years immediately before 1970 (1, 2) come to mind. You don't have to be an MIT cosmologist to figure out how they torpedoed the rising trend of prosperity for those aspiring to better themselves which had characterised the U.S. since 1940.

Nonetheless, what is coming down the track is something far more disruptive than the transition from an agricultural society to industrial production, and it may happen far more rapidly, allowing less time to adapt. We need to really get this right, because everything depends on it.

Observation and our understanding of the chemistry underlying the origin of life is compatible with Earth being the only host to life in our galaxy and, possibly, the visible universe. We have no idea whatsoever how our form of life emerged from non-living matter, and it's entirely possible it may have been an event so improbable we'll never understand it and which occurred only once. If this be the case, then what we do in the next few decades matters even more, because everything depends upon us, and what we choose. Will the universe remain dead, or will life burst forth from this most improbable seed to carry the spark born here to ignite life and intelligence throughout the universe? It could go either way. If we do nothing, life on Earth will surely be extinguished: the death of the Sun is certain, and long before that the Earth will be uninhabitable. We may be wiped out by an asteroid or comet strike, by a dictator with his fat finger on a button, or by accident (as Nathaniel Borenstein said, “The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.”).

But if we survive these near-term risks, the future is essentially unbounded. Life will spread outward from this spark on Earth, from star to star, galaxy to galaxy, and eventually bring all the visible universe to life. It will be an explosion which dwarfs both its predecessors, the Cambrian and technological. Those who create it will not be like us, but they will be our descendants, and what they achieve will be our destiny. Perhaps they will remember us, and think kindly of those who imagined such things while confined to one little world. It doesn't matter; like the bacteria and ants, we will have done our part.

The author is co-founder of the Future of Life Institute which promotes and funds research into artificial intelligence safeguards. He guided the development of the Asilomar AI Principles, which have been endorsed to date by 1273 artificial intelligence and robotics researchers. In the last few years, discussion of the advent of AGI and the existential risks it may pose and potential ways to mitigate them has moved from a fringe topic into the mainstream of those engaged in developing the technologies moving toward that goal. This book is an excellent introduction to the risks and benefits of this possible future for a general audience, and encourages readers to ask themselves the difficult questions about what future they want and how to get there.

In the Kindle edition, everything is properly linked. Citations of documents on the Web are live links which may be clicked to display them. There is no index.

Posted at 13:54 Permalink

Thursday, February 1, 2018

Reading List: Starship Grifters

Kroese, Robert. Starship Grifters. Seattle: 47North, 2014. ISBN 978-1-4778-1848-0.
This is the funniest science fiction novel I have read in quite a while. Set in the year 3013, not long after galactic civilisation barely escaped an artificial intelligence apocalypse and banned fully self-aware robots, the story is related by Sasha, one of a small number of Self-Arresting near Sentient Heuristic Androids built to be useful without running the risk of their taking over. SASHA robots are equipped with an impossible-to-defeat watchdog module which causes a hard reboot whenever they are on the verge of having an original thought. The limitation of the design proved a serious handicap, and all of their manufacturers went bankrupt. Our narrator, Sasha, was bought at an auction by the protagonist, Rex Nihilo, for thirty-five credits in a lot of “ASSORTED MACHINE PARTS”. Sasha is Rex's assistant and sidekick.

Rex is an adventurer. Sasha says he “never had much of an interest in anything but self-preservation and the accumulation of wealth, the latter taking clear precedence over the former.” Sasha's built in limitations (in addition to the new idea watchdog, she is unable to tell a lie, but if humans should draw incorrect conclusions from incomplete information she provides them, well…) pose problems in Rex's assorted lines of work, most of which seem to involve scams, gambling, and contraband of various kinds. In fact, Rex seems to fit in very well with the universe he inhabits, which appears to be firmly grounded in Walker's Law: “Absent evidence to the contrary, assume everything is a scam”. Evidence appears almost totally absent, and the oppressive tyranny called the Galactic Malarchy, those who supply it, the rebels who oppose it, entrepreneurs like Rex working in the cracks, organised religions and cults, and just about everybody else, appear to be on the make or on the take, looking to grift everybody else for their own account. Cosmologists attribute this to the “Strong Misanthropic Principle, which asserts that the universe exists in order to screw with us.” Rex does his part, although he usually seems to veer between broke and dangerously in debt.

Perhaps that's due to his somewhat threadbare talent stack. As Shasha describes him, Rex doesn't have a head for numbers. Nor does he have much of a head for letters, and “Newtonian physics isn't really his strong suit either”. He is, however, occasionally lucky, or so it seems at first. In an absurdly high-stakes card game with weapons merchant Gavin Larviton, reputed to be one of the wealthiest men in the galaxy, Rex manages to win, almost honestly, not only Larviton's personal starship, but an entire planet, Schnufnaasik Six. After barely escaping a raid by Malarchian marines led by the dread and squeaky-voiced Lord Heinous Vlaak, Rex and Sasha set off in the ship Rex has won, the Flagrante Delicto, to survey the planetary prize.

It doesn't take Rex long to discover, not surprisingly, that he's been had, and that his financial situation is now far more dire than he'd previously been able to imagine. If any of the bounty hunters now on his trail should collar him, he could spend a near-eternity on the prison planet of Gulagatraz (the names are a delight in themselves). So, it's off the rebel base on the forest moon (which is actually a swamp; the swamp moon is all desert) to try to con the Frente Repugnante (all the other names were taken by rival splinter factions, so they ended up with “Revolting Front”, which was translated to Spanish to appear to Latino planets) into paying for a secret weapon which exists only in Rex's imagination.

Thus we embark upon a romp which has a laugh-out-loud line about every other page. This is comic science fiction in the vein of Keith Laumer's Retief stories. As with Laumer, Kroese achieves the perfect balance of laugh lines, plot development, interesting ideas, and recurring gags (there's a planet-destroying weapon called the “plasmatic entropy cannon” which the oft-inebriated Rex refers to variously as the “positronic endoscopy cannon”, “pulmonary embolism cannon”, “ponderosa alopecia cannon”, “propitious elderberry cannon”, and many other ways). There is a huge and satisfying reveal at the end—I kind of expected one was coming, but I'd have never guessed the details.

If reading this leaves you with an appetite for more Rex Nihilo, there is a prequel novella, The Chicolini Incident, and a sequel, Aye, Robot.

The Kindle edition is free for Kindle Unlimited subscribers.

Posted at 22:32 Permalink

Thursday, January 25, 2018

Reading List: Artemis

Weir, Andy. Artemis. New York: Crown, 2017. ISBN 978-0-553-44812-2.
Seldom has a first-time novelist burst onto the scene so spectacularly as Andy Weir with The Martian (November 2014). Originally written for his own amusement and circulated chapter by chapter to a small but enthusiastic group of fans who provided feedback and suggestions as the story developed, he posted the completed novel as a free download on his Web site. Some people who had heard of it by word of mouth but lacked the technical savvy to download documents and transfer them to E-readers inquired whether he could make a Kindle version available. Since you can't give away Kindle books, he published it at the minimum possible price. Before long, the book was rising into the Amazon bestseller list in science fiction, and he was contacted by a major publisher about doing a print edition. These publishers only accept manuscripts through agents, and he didn't have one (nor do agents usually work with first-time authors, which creates a chicken-and-egg problem for the legacy publishing industry), so the publisher put him in touch with a major agent and recommended the manuscript. This led to a 2014 hardcover edition and then a Hollywood movie in 2016 which was nominated for 7 Oscars and won two Golden Globes including Best Motion Picture and Best Performance by an Actor in its category.

The question fans immediately asked themselves was, “Is this a one shot, or can he repeat?” Well, I think we have the answer: with Artemis, Andy Weir has delivered another story of grand master calibre and shown himself on track to join the ranks of the legends of the genre.

In the latter part of the 21st century commerce is expanding into space, and the Moon is home to Artemis, a small settlement of around 2000 permanent residents, situated in the southern part of the Sea of Tranquility, around 40 km from the Apollo 11 landing site. A substantial part of the economy of Artemis is based upon wealthy tourists who take the train from Artemis to the Apollo 11 Visitor Center (where they can look, but not touch or interfere with the historical relics) and enjoy the luxuries and recreations which cater to them back in the pleasure domes.

Artemis is the creation of the Kenya Space Corporation (KSC), which officially designates it “Kenya Offshore Platform Artemis” and operates under international maritime law. As space commerce burgeoned in the 21st century, Kenya's visionary finance minister, Fidelis Ngugi, leveraged Kenya's equatorial latitude (it's little appreciated that once reliable fully-reusable launch vehicles are developed, there's no need to launch over water) and hands-off regulatory regime provided a golden opportunity for space entrepreneurs to escape the nanny state regulation and crushing tax burden of “developed” countries. With tax breaks and an African approach to regulation, entrepreneurs and money flowed in from around the world, making Kenya into a space superpower and enriching its economy and opportunities for its people. Twenty years later Ngugi was Administrator of Artemis; she was, in effect, ruler of the Moon.

While Artemis was a five star experience for the tourists which kept its economy humming, those who supported the settlement and its industries lived in something more like a frontier boom town of the 19th century. Like many such settlements, Artemis attracted opportunity-seekers and those looking to put their pasts behind them from many countries and cultures. Those established tend to attract more like them, and clannish communities developed around occupations: most people in Life Support were Vietnamese, while metal-working was predominantly Hungarian. For whatever reason, welding was dominated by Saudis, including Ammar Bashara, who emigrated to Artemis with his six-year old daughter Jasmine. Twenty years later, Ammar runs a prosperous welding business and Jasmine (“Jazz”) is, shall we say, more irregularly employed.

Artemis is an “energy intense” Moon settlement of the kind described in Steven D. Howe's Honor Bound Honor Born (May 2014). The community is powered by twin 27 megawatt nuclear reactors located behind a berm one kilometre from the main settlement. The reactors not only provide constant electricity and heat through the two week nights and days of the Moon, they power a smelter which processes the lunar regolith into raw materials. The Moon's crust is about 40% oxygen, 20% silicon, 12% iron, and 8% aluminium. With abundant power, these elements can be separated and used to manufacture aluminium and iron for structures, glass from silicon and oxygen, and all with abundant left-over oxygen to breathe. There is no need for elaborate recycling of oxygen: there's always plenty more coming out of the smelter. Many denizens of Artemis subsist largely on “gunk”, an algae-based food grown locally in vats which is nutritious but unpalatable and monotonous. There are a variety of flavours, all of which are worse than the straight stuff.

Jazz works as a porter. She picks up things somewhere in the settlement and delivers them to their destinations using her personally-owned electric-powered cart. Despite the indigenous production of raw materials, many manufactured goods and substances are imported from Earth or factories in Earth orbit, and every time a cargo ship arrives, business is brisk for Jasmine and her fellow porters. Jazz is enterprising and creative, and has a lucrative business on the side: smuggling. Knowing the right people in the spaceport and how much to cut them in, she has a select clientele to which she provides luxury goods from Earth which aren't on the approved customs manifests.

For this, she is paid in “slugs”. No, not slimy molluscs, but “soft-landed grams”, credits which can be exchanged to pay KSC to deliver payload from Earth to Artemis. Slugs act as a currency, and can be privately exchanged among individuals' handheld computers much as Bitcoin today. Jazz makes around 12,000 slugs a month as a porter, and more, although variable, from her more entrepreneurial sideline.

One of her ultra-wealthy clients approaches her with a highly illegal, almost certainly unethical, and very likely perilous proposal. Surviving for as long as she has in her risky business has given Jazz a sense for where the edge is and the good sense not to step over it.

“I'm sorry but this isn't my thing. You'll have to find someone else.”

“I'll offer you a million slugs.”


Thus begins an adventure in which Jazz has to summon all of her formidable intellect, cunning, and resources, form expedient alliances with unlikely parties, solve a technological mystery, balance honour with being a outlaw, and discover the economic foundation of Artemis, which is nothing like it appears from the surface. All of this is set in a richly textured and believable world which we learn about as the story unfolds: Weir is a master of “show, don't tell”. And it isn't just a page-turning thriller (although that it most certainly is); it's also funny, and in the right places and amount.

This is where I'd usually mention technical goofs and quibbles. I'll not do that because I didn't find any. The only thing I'm not sure about is Artemis' using a pure oxygen atmosphere at 20% of Earth sea-level pressure. This works for short- and moderate-duration space missions, and was used in the U.S. Mercury, Gemini, and Apollo missions. For exposure to pure oxygen longer than two weeks, a phenomenon called absorption atelectasis can develop, which is the collapse of the alveoli in the lungs due to complete absorption of the oxygen gas (see this NASA report [PDF]). The presence of a biologically inert gas such as nitrogen, helium, argon, or neon will keep the alveoli inflated and prevent this phenomenon. The U.S. Skylab missions used an atmosphere of 72% oxygen and 28% nitrogen to avoid this risk, and the Soviet Salyut and Mir space stations used a mix of nitrogen and oxygen with between 21% and 40% oxygen. The Space Shuttle and International Space Station use sea-level atmospheric pressure with 21% oxygen and the balance nitrogen. The effects of reduced pressure on the boiling point of water and the fire hazard of pure oxygen even at reduced pressure are accurately described, but I'm not sure the physiological effects of a pure oxygen atmosphere for long-term habitation have been worked through.

Nitpicking aside, this is a techno-thriller which is also an engaging human story, set in a perfectly plausible and believable future where not only the technology but the economics and social dynamics work. We may just be welcoming another grand master to the pantheon.

Posted at 22:55 Permalink

Monday, January 22, 2018

Floating Point Benchmark: PHP Language Added

I have posted an update to my trigonometry-intense floating point benchmark which adds PHP to the list of languages in which the benchmark is implemented. A new release of the benchmark collection including PHP is now available for downloading.

PHP is a brutal hack of a language created by bashing together HTML and a bastardised flavour of Perl which is just enough like Perl to trick you into thinking you know it, only to pull the rug out from under you whenever you become complacent. PHP is the foundation of vast snowdrifts of incomprehensible spaghetti code which adorns many Web sites, and has been the wellspring of innumerable security holes in those sites. PHP was originally created in 1994 and to this day has no formal specification: the language is defined by the implementation of the interpreter.

I wouldn't let PHP anywhere near my own Web site, but I have to deal with it in mantaining a WordPress-based site I help to administer. Having been forced to wallow with the pig, I decided to add PHP to the list of FBENCH languages.

The implementation is a relatively straightforward port of the Perl version of the program, modified to be embedded within a Web page and adapted to the differences between Perl and PHP in handling things such as variable scope in functions, declaration (or non-declaration) of variables, and the structure of arrays.

As the reference, I started with the C version, compiled with GCC 5.4.0, and run for 166,051,660 iterations. Run times in seconds were (296.89, 296.37, 296.29, 296.76, 296.37) for a mean time of 296.536, or 1.7858 microseconds per iteration.

I then made five timing runs on the same machine, using the PHP command line interpreter version 7.0.22. I ran the benchmark for 32,952,075 iterations, having calculated that number from a previous timing run to yield a run time of around five minutes. The timings in seconds were (295.320, 295.135, 297.174, 296.037, 297.098) for a mean of 296.153 seconds or 8.9874 microseconds per iteration.

Comparing the two measurements of time per iteration, PHP is thus 5.033 times slower than C. Interestingly, this is much faster than Perl, which usually benchmarks more than twenty times slower than C.

I then verified that the same Web page can be run on a Web server with PHP. Since the machine on which I ran the test had a different type of CPU than the development machine on which I made the timing tests above, I did not compare execution time.

Notes on Running the Benchmark

The benchmark is supplied as the fbench.php file. This is a Web page, compliant with the XHTML 1.0 Strict standard, with PHP embedded to implement the benchmark. It can be run either from the command line using the PHP interpreter, or by installing it on a Web site which supports PHP. The iteration count defaults to 100000. You can specify the iteration count when running from the command line as the first argument, for example:

php fbench.php 250000 >fbench.html

to run 250000 iterations and write the resulting HTML in the file fbench.html, which may then be viewed with a Web browser using a "file:" URL.

If you install fbench.php on a Web server with PHP, you can run it and specify the iteration count with a URL like:

In this case your Web browser will directly display the results of the benchmark.

The benchmark program displays the result of the last iteration of the computation, reports any discrepancies from the reference results, and reports the timing, both in seconds elapsed and microseconds per iterations. Timing is done using the PHP microtime(true) function, which reports wall clock time in seconds and microseconds. Archival runs should be done on an idle system with the iteration count adjusted to produce a run time around five minutes. (When running from a Web server, you may have to reduce the run time to avoid having the request time out.)

The relative performance of the various language implementations (with C taken as 1) is as follows. All language implementations of the benchmark listed below produced identical results to the last (11th) decimal place.

Language Relative
C 1 GCC 3.2.3 -O3, Linux
JavaScript 0.372
Mozilla Firefox 55.0.2, Linux
Safari 11.0, MacOS X
Brave 0.18.36, Linux
Google Chrome 61.0.3163.91, Linux
Chromium 60.0.3112.113, Linux
Node.js v6.11.3, Linux
Chapel 0.528
Chapel 1.16.0, -fast, Linux
Parallel, 64 threads
Visual Basic .NET 0.866 All optimisations, Windows XP
C++ 0.939
G++ 5.4.0, -O3, Linux, double
long double (80 bit)
__float128 (128 bit)
MPFR (128 bit)
MPFR (512 bit)
Modula-2 0.941 GNU Modula-2 gm2-1.6.4 -O3, Linux
FORTRAN 1.008 GNU Fortran (g77) 3.2.3 -O3, Linux
Pascal 1.027
Free Pascal 2.2.0 -O3, Linux
GNU Pascal 2.1 (GCC 2.95.2) -O3, Linux
Swift 1.054 Swift 3.0.1, -O, Linux
Rust 1.077 Rust 0.13.0, --release, Linux
Java 1.121 Sun JDK 1.5.0_04-b05, Linux
Visual Basic 6 1.132 All optimisations, Windows XP
Haskell 1.223 GHC 7.4.1-O2 -funbox-strict-fields, Linux
Scala 1.263 Scala 2.12.3, OpenJDK 9, Linux
FreeBASIC 1.306 FreeBASIC 1.05.0, Linux
Ada 1.401 GNAT/GCC 3.4.4 -O3, Linux
Go 1.481 Go version go1.1.1 linux/amd64, Linux
Julia 1.501 Julia version 0.6.1 64-bit -O2 --check-bounds=no, Linux
Simula 2.099 GNU Cim 5.1, GCC 4.8.1 -O2, Linux
Lua 2.515
LuaJIT 2.0.3, Linux
Lua 5.2.3, Linux
Python 2.633
PyPy 2.2.1 (Python 2.7.3), Linux
Python 2.7.6, Linux
Erlang 3.663
Erlang/OTP 17, emulator 6.0, HiPE [native, {hipe, [o3]}]
Byte code (BEAM), Linux
ALGOL 60 3.951 MARST 2.7, GCC 4.8.1 -O3, Linux
PHP 5.033 PHP (cli) 7.0.22, Linux
PL/I 5.667 Iron Spring PL/I 0.9.9b beta, Linux
Lisp 7.41
GNU Common Lisp 2.6.7, Compiled, Linux
GNU Common Lisp 2.6.7, Interpreted
Smalltalk 7.59 GNU Smalltalk 2.3.5, Linux
Ruby 7.832 Ruby 2.4.2p198, Linux
Forth 9.92 Gforth 0.7.0, Linux
Prolog 11.72
SWI-Prolog 7.6.0-rc2, Linux
GNU Prolog 1.4.4, Linux, (limited iterations)
COBOL 12.5
Micro Focus Visual COBOL 2010, Windows 7
Fixed decimal instead of computational-2
Algol 68 15.2 Algol 68 Genie 2.4.1 -O3, Linux
Perl 23.6 Perl v5.8.0, Linux
BASICA/GW-BASIC 53.42 Bas 2.4, Linux
QBasic 148.3 MS-DOS QBasic 1.1, Windows XP Console
Mathematica 391.6 Mathematica, Raspberry Pi 3, Raspbian

Download floating point benchmark collection

Posted at 15:59 Permalink

Sunday, January 14, 2018

Univac Document Archive: 1107 COBOL Programmer's Guide Added

I have added the following document to the Univac 1107 section of the Univac Document Archive. This is a PDF of a scanned paper document in my collection. This document is more than fifty years old (published in 1963) and may appear wonky to contemporary eyes: the unjustified typescript text is sometimes misaligned on the page. This is not an artefact of scanning—it's how the document actually appears. Recall that only around 38 Univac 1107s were sold, so documents describing it were produced in small numbers and didn't, in the eyes of Univac, merit the expense of the high production values of contemporary IBM manuals.

When the Univac 1108 was released, the COBOL compiler was modified to exploit the 1108's new instructions, in particular native hardware support for 72-bit double precision floating point arithmetic (the 1107 compiler supported double precision with a different format implemented in software). This compiler, based upon the COBOL-60 standard as revised by COBOL-61, was updated over the years as the COBOL language evolved, and remained the standard Univac 1100 series COBOL until the release of ASCII/ANSI COBOL, which conformed to the ANSI X3.23-1974 COBOL 1974 standard and used the ASCII character set instead of the FIELDATA code employed by the original compiler.

I never used COBOL on the UNIVAC 1107; the machine I used was for research and education at an engineering school, where Algol, Fortran, or assembler were the programming languages of choice. COBOL, which was particularly costly in the drum storage it consumed for the compiler and libraries, was not installed. I did, however, obtain a copy of the COBOL Programmer's Guide, which was scanned to produce this on-line document. Having learned Algol and Fortran, my much younger self thought the idea of programming a computer by writing wordy English prose particularly stupid, although there were some innovative and interesting ideas about defining and manipulating data structures which would, in time, find their way into other programming languages such as PL/I, Pascal, and C.

As usual, my instinct for mis-reading the technology market and the desires of customers was uncanny. By 1970, COBOL was the most widely used programming language in the world, with tens of millions of lines of word salad being spewed into mainframes around the world, some of it still in use today. Nobody writes new COBOL programs today (well, nobody saneI wrote one in 2012), but many people remain involved in maintenance of legacy COBOL programs, and trawling through vast snowdrifts of COBOL looking for two-digit year representations accounted for much of the billions spent in the Y2K panic of the late 1990s.

As with many systems programmers, I never managed to completely avoid COBOL during my career. I spent a summer working on a translator from Burroughs COBOL, which allowed Algol-type expressions everywhere, to Univac 1108 COBOL which was the descendant of that described in this manual. Years later, I resolved a crisis in a mission-critical COBOL program which was missing its deadlines, by changing one statement which made it run more than a hundred times faster (it was writing data to disc one tiny record at a time: I simply made it write buffers containing many records).

Posted at 14:21 Permalink

Friday, January 12, 2018

Reading List: An Inconvenient Presidency

Hamilton, Eric M. An Inconvenient Presidency. Seattle: CreateSpace, 2016. ISBN 978-1-5368-7363-4.
This novella (89 pages in the Kindle edition) is a delightful romp into alternative history and the multiverse. Al Gore was elected president in 2000 and immediately informed of a capability so secret he had never been told of it, even as Vice President. He was handed a gadget, the METTA, which allowed a limited kind of time travel. Should he, or the country, find itself in a catastrophic and seemingly unrecoverable situation, he could press its red button and be mentally transported back in time to a reset point, set just after his election, to give it another try. But, after the reset, he would retain all of his knowledge of the events which preceded it.

Haven't you imagined going back in time and explaining to your younger self all of the things you've learned by trial and error and attendant bruises throughout your life? The shadowy Government Apperception Liberation Authority—GALA—has endowed presidents with this capability. This seems so bizarre the new president Gore pays little attention to it. But when an unanticipated and almost unimaginable event occurs, he presses the button.


Well, we won't let that happen! And it doesn't, but something else does: reset. This job isn't as easy as it appeared: reset, reset, reset.

We've often joked about the “Gore Effect”: the correlation between unseasonably cold weather and Al Gore's appearance to promote his nostrums of “anthropogenic global warming”. Here, Al Gore begins to think there is a greater Gore Effect: that regardless of what he does and what he learns from previous experience and a myriad of disasters, something always goes wrong with catastrophic consequences.

Can he escape this loop? Who are the mysterious people behind GALA? He is determined to find out, and he has plenty of opportunities to try: ~KRRZKT~.

You will be amazed at how the author brings this tale to a conclusion. Throughout, everything was not as it seemed, but in the last few pages, well golly! Unusually for a self-published work, there are no typographical or grammatical errors which my compulsive copy-editor hindbrain detected. The author does not only spin a fine yarn, but respects his audience enough to perfect his work before presenting it to them: this is rare, and I respect and applaud that. Despite Al Gore and other U.S. political figures appearing in the story, there is no particular political tilt to the narrative: the goal is fun, and it is superbly achieved.

The Kindle edition is free for Kindle Unlimited subscribers.

Posted at 01:48 Permalink

Tuesday, January 9, 2018

Reading List: The Red Cliffs of Zerhoun

Bracken, Matthew. The Red Cliffs of Zerhoun. Orange Park, FL: Steelcutter Publishing, 2017. ISBN 978-0-9728310-5-5.
We first met Dan Kilmer in Castigo Cay (February 2014), where the retired U.S. Marine sniper (I tread cautiously on the terminology: some members of the Corps say there's no such thing as a “former Marine” and, perhaps, neither is there a “former sniper”) had to rescue his girlfriend from villains in the Caribbean. The novel is set in a world where the U.S. is deteriorating into chaos and the malevolent forces suppressed by civilisation have begun to assert their power on the high seas.

As this novel begins, things have progressed, and not for the better. The United States has fractured into warring provinces as described in the author's “Enemies” trilogy. Japan and China are in wreckage after the global economic crash. Much of Europe is embroiled in civil wars between the indigenous population and inbred medieval barbarian invaders imported by well-meaning politicians or allowed to land upon their shores or surge across their borders by the millions. The reaction to this varies widely depending upon the culture and history of the countries invaded. Only those wise enough to have said “no” in time have been spared.

But even they are not immune to predation. The plague of Islamic pirates on the high seas and slave raiders plundering the coasts of Europe was brought to an end only by the navies of Christendom putting down the corsairs' primitive fleets. But with Europe having collapsed economically, drawn down its defence capability to almost nothing, and daring not even to speak the word “Christendom” for fear of offending its savage invaders, the pirates are again in ascendence, this time flying the black flag of jihad instead of the Jolly Roger.

When seventy young girls are kidnapped into sex slavery from a girls' school in Ireland by Islamic pirates and offered for auction to the highest bidder among their co-religionists, a group of those kind of hard men who say things like “This will not stand”, including a retired British SAS colonel and a former Provisional IRA combatant (are either ever “retired” or “former”?) join forces, not to deploy a military-grade fully-automatic hashtag, but to get the girls back by whatever means are required.

Due to exigent circumstances, Dan Kilmer's 18 metre steel-hulled schooner, moored in a small port in western Ireland to peddle diesel fuel he's smuggled in from a cache in Greenland, becomes one of those means. Kilmer thinks the rescue plan to be folly, but agrees to transport the assault team to their rendezvous point in return for payment for him and his crew in gold.

It's said that no battle plan survives contact with the enemy. In this case, the plan doesn't even get close to that point. Improvisation, leaders emerging in the midst of crisis, and people rising to the occasion dominate the story. There are heroes, but not superheroes—instead people who do what is required in the circumstances in which they find themselves. It is an inspiring story.

This book has an average review rating of 4.9 on Amazon, but you're probably hearing of it here for the first time. Why? Because it presents an accurate view of the centuries-old history of Islamic slave raiding and trading, and the reality that the only way this predation upon civilisation can be suppressed is by civilised people putting it down in with violence commensurate to its assault upon what we hold most precious.

The author's command of weapons and tactics is encyclopedic, and the novel is consequently not just thrilling but authentic. And, dare I say, inspiring.

The Kindle edition is free for Kindle Unlimited subscribers.

Posted at 01:40 Permalink