# Friday, 02 November 2018

Sometimes, you want to store quotation marks within a string, as in the following example

"Alive", she cried!

In C#, there are at least 4 ways to embed a quote within a string:

  1. Escape quote with a backslash
  2. Precede string with @ and use double quotes
  3. Use the corresponding ASCII character
  4. Use the Hexadecimal Unicode character

Escape with backslash

You can precede any escaped character with a backslash ("\") to preserve that character.

For example:

var lyrics = "\"Alive\", she cried!"

Precede with @ and use double quotes

If you precede the string with the "@" character, you can use a double set of quotation marks to indicate a single set of quotation marks within a string.

For example:

var lyrics = @"""Alive"", she cried!"

Use the ASCII character

A double quote is the ASCII value 34, so you can append this to your string.

For example:

quote = (char)34 + "Alive" + (char)34 + ", she cried!";

Use the Hexadecimal Unicode character

You can escape Unicode characters by preceding the hexadecimal value with "\u". The hexadecimal value of a double quote is 0022, so you can include this in your string.

For example:

quote = "\u0022Alive\u0022, she cried!";

These techniques work for many other characters that are difficult to represent within quotation marks, such as line feeds, non-English characters, and non-printing characters.

There are other ways to include quotation marks within a C# string, but these should be enough to get you started.
Friday, 02 November 2018 07:08:00 (GMT Standard Time, UTC+00:00)
# Thursday, 01 November 2018
Thursday, 01 November 2018 09:02:00 (GMT Standard Time, UTC+00:00)
# Monday, 29 October 2018

Episode 535

Rajasa Savant on Serverless Azure

Microsoft Engineer Rajasa Savant describes the "Serverless" technologies available in Microsoft Azure

Monday, 29 October 2018 08:56:00 (GMT Standard Time, UTC+00:00)
# Sunday, 28 October 2018

SecondFoundationSecond Foundation concludes Isaac Asimov's classic Foundation Trilogy

The Mule has taken over much of the galaxy defeating The Foundation and establishing his own empire through the use of his powerful mutant mental powers. He has spent years searching for the hidden Second Foundation established by the psychohistorian Hari Seldon centuries earlier, correctly assuming it is the only viable threat to his reign. But the Second Foundation finds him before he can find it and they have similar - if less powerful mental powers.

The Mule cannot last forever, and he leaves no heir (which is why he is "The Mule"), but he did leave Seldon's plan in shambles by so drastically altering the history of the universe in an unpredictable way.

The second half of this book chronicles the Second Foundation's efforts to rebuild Seldon's plan and set the galaxy back on a path toward a second galactic empire. It features a war between The Mule's successors and the remnants of The Foundation and The Foundation's quest to locate the Second Foundation.

Asimov uses his talent for misdirection multiple times in this book, guiding the reader toward one conclusion and then another, before revealing the true answer. He does this most when identifying who is with the Second Foundation and where it is located.

This volume brings to the fore a theme that lurked under the surface of the first two books: The people of the Foundation know that Seldon's plan almost guarantees their success. They have almost a religious faith in their eventual victory. This helps boost morale during the war, but hinders them as they work to overcome other obstacles. They know that the actions of individuals are insignificant in Seldon's plan and that Seldon's plan predicts their ultimate triumph. So how much effort need they put forth in accomplishing the inevitable? They hold these beliefs even after the disruption of the plan by the actions of the Mule.

One thing that appealed to me about this series is that the principles of using large amounts of data to do predictive analysis has become a huge field of study today. Machine Learning and Big Data are fields that existed since the days of Asimov, but now that cloud computing provides massive compute power at affordable prices, these sciences have gained both power and interest.  Asimov foresaw this 50 years ago.

Later in his life, Asimov returned to writing about the Foundation; but this trilogy began the ideas and remains one of his strongest work. It is well worth reading.

Sunday, 28 October 2018 09:29:00 (GMT Standard Time, UTC+00:00)
# Saturday, 27 October 2018

WarOfTheWorldsIt is impossible to overstate the impact The War of the Worlds by H.G. Wells had on science fiction. First published in 1897, this book broke new ground in science fiction - a genre still very much undefined at that time.

An alien invasion; monstrous creatures driving giant machines with long tentacles; weapons that blast an incinerating heat ray. These are now science fiction clichés. But they were original in the nineteenth century.

The War of the Worlds tells the story of a Martian invasion of Earth. Giant cylinders crash into England and strange creatures emerge. They climb into giant armored machines and begin to terrorize London and the surrounding area, killing people and destroying the cities. Although England was a world power at that time, it was no match for the weapons of the Martians. It isn't long before England's existing civilization is wiped out and humans are in hiding from their new overlords.

War of the Worlds is an adventure story, told by an unnamed narrator as he flees the invading monsters. The narrator does not save humanity. He simply observes and reports.

Wells was himself a scientist and he injects a great deal of science into his story - from how evolution affected the appearance of the Martians to how natural selection controls which alien plants survive on Earth and for how long to how gravity would affect the aliens. Even the final fate of the Martians is based in science.

This book is also a morality story. Wells repeatedly uses the analogy that the relationship of Martians to Earth Men is similar to our relationship with the animals of our planet, which we slaughter for food without thinking twice. He refers to us as ants to the Martians, thanks to their enormous head start in evolution, civilization, and technology. More poignantly, Wells compares the Martians' treatment of the British subjects to Britain's treatment of other people in its quest to expand its empire.

Read The War of the Worlds if you want to understand where much of today's science fiction originated.

Saturday, 27 October 2018 09:00:00 (GMT Daylight Time, UTC+01:00)
# Thursday, 25 October 2018
Thursday, 25 October 2018 09:37:00 (GMT Daylight Time, UTC+01:00)
# Monday, 22 October 2018
# Sunday, 21 October 2018

MartianChroniclesThe Martian Chronicles - Bradbury's first science fiction novel - is less a novel than a collection of short stories. Each story has a different tone and very few characters appear in more than one story; but, they are tied together by presenting a chronological history of man's attempted colonization and terraforming of Mars in the near future.

Bradbury's stories have endured because he humanizes the astronauts and the Martians - showing us their hopes and their flaws. Early explorers discover that Mars is populated by a race not dissimilar to their own: They are humanoid in shape and they live in cities and houses and they marry and have children. They even possess some of the flaws of their Terran counterparts. The first astronauts are killed by jealous husbands or by those who think them delusional for claiming to come from another planet; or by those looking to protect their home world.

But the Martians are not like the Earth men. They are telepathic, and they are far less excited about contact with their sister world.

Earth people came to Mars for adventure, for love, for land, for freedom. One came to exact revenge on those who had burned books on Earth - a precursor to Bradbury's second novel - Fahrenheit 451.

Eventually, rockets from Earth swarm toward Mars, and the invaders try to re-shape the red planet into the world they left behind. The Martians are all but wiped out by the diseases brought by the intruders.

But, just as the encroachers begin to take hold of Mars, a worldwide nuclear war erupts on Earth, halting the immigration, and drawing most of the settlers back home.

It's not hard to see the parallels between earth's colonization of Mars and European colonization or America conquering the western frontier.  The Martian civilization lasted for thousands of years before it was wiped out by us. Earth's replacement civilization lasted about a quarter century. Bradbury has a talent for building into his stories allegories about race and imperialism and the Cold War and Nuclear War and Family values and cultural clashes and the dangers of rapid technological advancement.

Despite an optimistic final story, The Martian Chronicles is a warning of man's callous, careless, reckless, and self-destructive nature.

As one disillusioned astronaut puts it:

"We Earth Men have a talent for ruining big, beautiful things. The only reason we didn't set up hot-dog stands in the midst of the Egyptian temple of Karnak is because it was out of the way and served no large commercial purpose."

Sunday, 21 October 2018 09:24:00 (GMT Daylight Time, UTC+01:00)
# Saturday, 20 October 2018

FoundationAndEmpireFoundation and Empire is the second book in Isaac Asimov's classic Foundation Trilogy, advancing the story of The Foundation - the civilization founded by Psychohistorian Hari Seldon in order to mitigate the collapse of the galactic empire and shorten the thousands of years of anarchy he foresaw following.

The book is divided into 2 stories: "The General" and "The Mule". Story 1 is interesting but unremarkable.

"The General" details a power struggle between the galactic emperor and Bel Riose - one of his generals. It is hundreds of years after Seldon's death and the  empire has all but collapsed, as he predicted. Riose believes he can thwart Seldon's plan by attacking the Foundation. But he is only one man and Seldon's plan relies on the collective actions of the quintillions of people in the galaxy being more influential than anything that one man can accomplish. In the context of history, it does not matter what individuals do. The universe will move forward regardless. This is a basic assumption of psychohistory.

However, the that assumption falls apart in the second half of the book.

In the second story, we are introduced to The Mule, a powerful mutant born with the ability to control minds. His powers are so strong that he can affect galactic history by himself. This disrupts Seldon's master plan and allows The Mule to begin conquering the galaxy for himself.

The Foundation falls to The Mule; but, when the Mule learns that Seldon established a Second Foundation at the other end of the galaxy, he sets out to find and destroy it. Meanwhile, Foundation loyalists also seek the location of the Second Foundation, so they can warn it about the Mule.

I like how the two stories conflicted with one another. On the surface, they are only slightly related and separated by hundreds of years, but they show both the strength and weakness of math, science, and statistics. The first demonstrates how meaningless a single person, no matter how powerful or how ambitious, can affect a galaxy with quadrillions of people. The second shows exactly the opposite. The Mule's power is strong enough that he disrupts Seldon's entire plan. Further, The Mule's plans are thwarted by a single person.

It is this contradiction that makes Asimov's story so compelling. He takes us in one direction and makes us feel comfortable; then destroys all our assumptions.

Saturday, 20 October 2018 09:13:00 (GMT Daylight Time, UTC+01:00)
# Thursday, 18 October 2018
Thursday, 18 October 2018 21:54:00 (GMT Daylight Time, UTC+01:00)