« December 2017 | Main | February 2018 »

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 www.fourmilab.ch 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