Not-So-Smart Contracts

So-called “Smart Contracts” are a nightmare waiting to happen. Based on Bitcoin, Smart Contracts are essentially software-based legal contracts that programmatically execute financial transactions when certain conditions are met. For example, a smart contract could be written for a loan such that if borrower misses a payment, the lender could deduct the loan payment, as well as a hefty late fee, from the borrower’s account, automatically, with no recourse available. Interest rates could fluctuate literally with the weather (simply by tying the conditions of the Smart Contract to a weather API), or even be based on a random number. Connecting Smart Contracts to the even more dystopian “Internet of Things” means that if a person is thirty seconds late to work, they can be docked pay automatically, as soon as they walk in.

Smart Contracts have two major flaws. The first is that they couple personal finances, transactions, arbitration, and enforcement in one terrifying monolith. This means that instead of parties in dispute going to small claims court (arbitration), say, and seeking a judgment (enforcement) against the other, so that they can receive a payment (finances) from them, the Smart Contract combines all of these steps into one algorithm. The theory justifying this dangerous approach is that people are inherently untrustworthy, and presumably, that software is not. Ethereum, the most prominent organization developing Smart Contracts technology, brags that it “allows people to safely interact trustlessly”, and the original Bitcoin whitepaper talks about “the inherent weaknesses of the trust based model”, and calls for “cryptographic proof instead of trust”.

From this perspective, the second flaw is even worse. Ethereum uses an object-oriented language called Solidity to write Smart Contracts. From their documentation, “Solidity supports multiple inheritance by copying code including polymorphism.”.  Object-oriented programming has all sorts of complexity problems, but one of the worst is multiple inheritance.

Multiple inheritance is its own disaster waiting to happen: it introduces the possibility of something that Bob Martin calls the “deadly diamond of death” that creates ambiguities that are problematic in interface software, and potentially disastrous in financial applications.

Meanwhile, this is a “simple Smart Contract” from the Ethereum documentation (the word “simple” appears many times in this document):

pragma solidity ^0.4.0;

contract Coin {
    // The keyword "public" makes those variables
    // readable from outside.
    address public minter;
    mapping (address => uint) public balances;

    // Events allow light clients to react on
    // changes efficiently.
    event Sent(address from, address to, uint amount);

    // This is the constructor whose code is
    // run only when the contract is created.
    function Coin() {
        minter = msg.sender;

    function mint(address receiver, uint amount) {
        if (msg.sender != minter) return;
        balances[receiver] += amount;

    function send(address receiver, uint amount) {
        if (balances[msg.sender] < amount) return;
        balances[msg.sender] -= amount;
        balances[receiver] += amount;
        Sent(msg.sender, receiver, amount);

Got it? Will your technolawyer get it? This is “the simplest form of a cryptocurrency” (their words). Here is another contract that I wrote, using inheritance:

contract my_mortgage is a_great_mortgage {}
contract a_great_mortgage is a_subprime_variable_interest_rate_mortgage_that_is_enforced_automatically_and_will_ruin_your_life {}

(Hint: read it out loud)

Imagine the worst legalese you’ve ever seen, and now imagine it as computer code, obfuscated by multiple inheritance, connected directly to your bank account, with no possibility of appeal in court, based on protections afforded by law, as that would presume a “trusted third party” for arbitration. Software inevitably has bugs, and I am not encouraged that the primary language for Smart Contracts will reduce their number. In fact, it is painfully easy to see much bad software being written with Solidity.  Ethereum argues that “one of the many advantages of having a robot run your organization is that it is immune to any outside influence as it’s guaranteed to execute only what it was programmed to.”  We are supposed to trust these “neutral” systems over each other.

The companies and institutions promoting Smart Contracts are nothing if not ambitious.  CoinPrism encourages you to “store your house on the Bitcoin blockchain” (I do not). What will this mean if you agree (voluntarily or otherwise) to a buggy and/or malicious contract that happens to have access to ownership of your house?  I don’t doubt the intentions of the authors of Solidity et al, but the road to hell is paved with good intentions. Perhaps the “trust-based model” needs to be reconsidered.

Flea Market

“That’s $14.35.”

“Fourteen… thirty-five?” He felt stupid saying it so slowly, but it sounded wrong.

“Yep,” the woman sitting on the other side of the table said.  He thought he saw a slight leer.  “You want it?”

“Ummm, well, I, uh, hmmm…” He had an uncomfortable sense that she somehow understood his disfluencies better than he did.  “I’m not sure, hmmm.  What is it?”

“It’s a clock. Antique. It’s worth at least a hundred and fifty but I gotta get rid of it.”

“A deal,” he thought. “Maybe. This lady knows what she’s doing. Probably not $150, maybe less, but who knows? Maybe it’s worth even more.  I could get Sam to look at it… Besides, it would look good on the bookcase, next to the lamp.”

What he said was, “Huh,” but again he sensed that she was reading him more closely than he would have liked.

The vendor sat at the edge of a plastic folding chair, arms folded, with raven-black hair, wearing a dark purple dress made of what looked like velvet, the steward of a table covered with old dolls, old bottles, old mirrors, objects waiting for a place to go besides the dump.  The table’s faux oak veneer was peeling, revealing the damaged particleboard underneath.

“It’s nice,” she said.

It was, he agreed. But it also looked heavy, and he had a long train ride home.

“Yeah…” He started to pull back.

“You can have it for ten. I gotta get rid of it.”

He tried to remember what was in his wallet. Did he have a ten? He was pretty sure he had a twenty, but sometimes these flea market people didn’t have change, and they had to go to the next table, to their… friends? Probably more of a you-scratch-my-back kind of situation (now that was an old saying). Anyway, he definitely didn’t have… fourteen-thirty-five, and didn’t feel like spending more time with this transaction than necessary, and already regretted following his curiosity to this weird place, and this weird woman, with her weird table, but if he had a ten on him, what the hell, it was a nice… clock, or whatever it was.  It didn’t look like a clock to him, but it looked old and ornate and brassy, and they don’t make things like they used to, and it would give his apartment a slightly classier feel, and… She was staring at him, waiting, waiting for a decision, while he tried to remember if he had broken a twenty recently… He had! Yesterday, when he stopped by the deli to get a coffee.  The guy hadn’t been crazy about giving him nineteen dollars in change, either.

“Sure,” he said.

He took out his wallet.  There was no ten, only three twenties and a few singles.  He blankly handed her a twenty.

“Hold on, I’ll get you your change,” she said, and headed to the adjacent table.

“Careful, it’s heavy.”

Gluten Free

Hey, how you doin’ little pizza pie?
You are the apple cobbler of my eye;
You look like a panini fallen from the sky;
Just a little taste of you I wanna try;

Gluten Free! Gluten Free!
Gluten Free! Gluten Free!

Hey my lasagna babe you look so fine;
My little cupcake yeah – you’ll soon be mine;
Delicious canolies all in a line;
If I can’t eat you up it would be a crime;

Gluten Free! Gluten Free!
Gluten Free! Gluten Free!


I want to slurp you up just like spaghetti;
Warm you like toast that’s nice and bready;
Run my fingers through your raw cookie dough;
Why I can’t have you baby I just don’t know;


My cookie cuttin’ days are just about through;
My angel cake went and left me too;
No devil’s food for me, you know it’s true;
Babe I’d go hungry if it weren’t for you;

Gluten Free! Gluten Free!
Gluten Free! Gluten Free!
Gluten Free! Gluten Free!
Gluten Free! Gluten Free!

A Plea to Iowans on the Eve of the Caucus

I am writing on the eve of the Iowa caucus with a plea to voters in Iowa, many who see Donald Trump as the answer to American’s problems.

He is not.  His rhetoric against Islam and Muslims is already pouring gasoline on a conflagration, serving no other purpose, and his election to the presidency would have the effect of increasing the quantity of gasoline a million-fold.  Members of the three great monotheistic religions have coexisted peacefully together before, so it is not without precedent that I still have cautious optimism that it can happen again in my lifetime.

I cannot speak for all Americans, but I do not want my president to lead my country into a religious war with Islam.  There can be no winner in such a war.  The dangers are too great.  And the only security system in the world that can prevent random attacks is a totalitarian one.

The election of Donald Trump to the presidency would only escalate the tension between Islam and the West.  I am concerned that his election could lead to a thermonuclear event in the next ten years, on one side or the other.

Again, today I plead with my fellow American citizens of the great state of Iowa.  Please do not elect Mr. Trump to be leader of the Free World.  We will be more safe and secure as a country without the terrifying drastic measures he has proposed.

Thank you for reading this.

Daniel M. Tsadok

Dune: An Analysis of the Atreides-Harkonnen War

(Warning: Dune Spoilers Aplenty)

In Frank Herbert‘s novel Dune, the feud between the Atreides and the Harkonnens was “kanly” – no holds barred.  The word appears early in the novel, when the Baron Vladimir Harkonnen is discomforted by the Duke Leto Atreides‘ usage of the word in their final correspondence, in which the Duke refuses to meet with the Baron for a peace negotiation.  It is within this context that the story of Dune begins.

This feud reached its climax in a Harkonnen surprise attack on the Atreides home on Arrakis, in which House Atreides was virtually wiped out, with the exception of a handful of Atreides survivors, including the Lady Jessica Atreides and her son, Paul Atreides, the ducal heir.

The extent of the Harkonnen victory gives the impression that the Duke was outmatched.  Even the Lady Jessica thought of the Baron Harkonnen as “too potent an adversary” when she encountered him the aftermath of the Baron’s victory.  However, the Duke Leto may have been the greatest tactician alive in the universe at the time, superior to the Baron.  He was aware that Arrakis was a trap, and even that the Padishah Emperor had secretly sided with the Harkonnens.  He knew that the spice harvesting equipment would be damaged, and that he would be blamed for a poor harvest.  But he walked into the trap knowing also that the spice melange was the most precious commodity in the universe, and that control of Arrakis would give him tremendous power and wealth.  He also knew that the native Fremen would make potent allies on the planet.  He was supported by talented people, some “legends in their own lifetime”.  The Duke came to Arrakis as prepared as one could be under the circumstances.

How then, did the Duke allow himself to fall victim to the Harkonnen attack?  Leto made several critical errors.  A direct attack by the Harkonnens, even one aided by the Emperor, might not have succeeded, and a failed attack on the Duke could be disastrous for both the Baron and the Emperor.  The attack must involve treachery.

The Duke knew this, of course.  The Lady Jessica had received warnings of treachery through her Bene Gesserit sisterhood, in a message hidden in the Bene Gesserit way: written in a form of braille on a leaf in the royal gardens on Arrakis.  His son Paul heard similar warnings from the Fremen, whom the Atreides were already courting as allies, after saving the life of his Fremen housekeeper.  The Duke, while aware of the danger, still did not know, however, “which hand held the knife”.

The Harkonnen master stroke, most likely devised by the Baron’s advisor, mentat Piter De Vries, came in the form of a “scrap of a note”, with the Baron’s own seal, implicating the Lady Jessica as the Atreides traitor, falling into the hands of the Atreides mentat, Thufir Hawat, the Duke’s “Master of Asassins”.

In the moment that Hawat, shaking, approached the Duke with news of the note, the Duke made a fatal error.  The Duke decided to pretend that he believed the note, in the hopes that the real traitor might lower their guard.  As part of this decision, he pulled his best man, Swordsmaster Duncan Idaho, from a critical mission recruiting the Fremen to keep the Lady Jessica under surveillance.  Hawat was similarly distracted from detecting other threats, especially the real traitor, Paul’s tutor, Dr. Wellington Yueh, who betrayed the Atreides by deactivating the Atreides House shields immediately before the Harkonnen attack.

Why did the Duke weaken himself so?  Why play out a charade of distance from his partner when he most needed her counsel, trained as she was as a Bene Gesserit?  Why, when he must have known in his heart that the Lady Jessica, whom he hadn’t married in hopes of making an alliance with another Great House, not only had his best interests in mind, but loved him, and their son?

One factor may be that Leto relied overly on Hawat, a human computer, and one of the best mentats in history.  Hawat had virtually complete control of security in House Atreides, and when the evidence alleging Jessica’s involvement with the Harkonnens reached his hands, he was overwhelmed by the possibility, as intended by De Vries.  To Hawat, the Lady Jessica was a much more obvious suspect than Yueh, who was Imperially conditioned not to harm the Atreides.  Only the twisted mind of De Vries could imagine the possibility of breaking such conditioning, and Hawat could not.

The Baron understood the limits of a mentat well.  The Baron saw De Vries only as a dangerous tool to be used.  He instructed his nephew, the presumed heir to the barony, Feyd-Rautha Harkonnen, on the limits of a mentat (in the presence of De Vries) before making his attack.  The Duke failed to understand Hawat’s limitations.  Jessica, by contrast, realized that Hawat was vulnerable, and that the note was aimed at him.  She even presented this possibility to Hawat, making him realize that he himself was a target of Harkonnen intrigue, something he had left out of his computations, thus exposing the mentat’s blind spot.  But too late.

Leto’s more fundamental error was to deny the love that bound himself and Jessica, love that he should have realized transcended any of the intrigues that the Harkonnens had put against them.  It was only when Leto denied this love that he was lost.  Shortly before the Harkonnen attack, Leto made the decision to change his strategy and marry the Laddy Jessica.  But too late.  The Harkonnen attack was already upon him.

Would the Atreides have prevailed had the Duke married the Lady Jessica?  Given the disastrous results of Leto’s decision to instead follow Hawat’s plan, it is likely that the marriage would have raised morale and strengthened House Atreides at a critical time, focused Hawat’s energies more productively, and allowed Idaho to cement his bond with the Fremen.  Yueh might have been exposed in time, and Harkonnen attack, stripped of a critical element, might have been postponed, giving the Atreides enough time to recruit the Fremen, allowing them to repel virtually any attack.

Jessica herself, always completely loyal to the Atreides, had been ignorant of her parentage until her extraordinarily gifted son noted the genetic markers in her and himself shortly after the attack.  The fact that Jessica actually was a Harkonnen, and the daughter of the Baron, no less, should be considered among the great ironies in modern fiction.

YouTube Approval Ratings

As of this writing, President Obama’s approval rating is 40%, according to Gallup, down from about 51% a year ago.  I’ve written about the voting aspects of YouTube before, so I was interested in how the YouTube ecosystem reacted to the latest State of the Union speech, as compared to last year’s speech.  For both speeches, I looked at the numbers for three different sets of videos: the official White House release, the Wall Street Journal’s release, and one put up by the New York Times (links to each below).

The first thing that became apparent is that the “approval ratings” for videos of the president’s speech were always higher than the president’s approval ratings according to the polls.  The official White House copy of the 2014 speech got 1,961 “Likes”, and 1,429 “Dislikes”, or a 58% approval rating.  This was the lowest of the batch, but still considerably higher than the poll numbers.  By comparison, the official release of the 2013 speech had an astonishing 81% approval rating.  That’s obviously a marked drop, but consistent with the relative drop in poll numbers.  More people also watched and voted on the 2014 speech: 45,000 more views (a 12% increase) and 1,000 more votes (a 50% increase).

The Wall Street Journal version showed a different trend: a drastic drop in views of more than 80% (from 374,004 in 2013 to 71,935 in 2014), but a comparable approval rating (67% to 61%).  Finally, the New York Times showed exactly the opposite trend: more than double the views (245,700 to 504,950), and an *increase* in approval ratings (61% to 68%).  In addition, the total number of votes tripled on the Times version, from 1,404 to 4,422.

That’s a lot of data, but what does it mean?  The first thing I would take away from these numbers is that it was a fairly successful speech, in the sense that many more people liked it than not.  57% is pretty good.  True, it’s not as good as 87%, which the 2013 Inauguration Speech got, but still a significant majority.

Also, the sample size is significant: about a million people watched the speech on YouTube, internationally, and it seems like the general trend is that the number of people who are watching the speech that way is increasing.  For comparison, the New York Times release of the president’s 2009 Inauguration speech got a mere 53,815 views, compared to 1.16 million for the 2013 speech, or twenty times more.  Possibly more importantly, participation is going up, not just viewership.  The percentage of people voting on videos, as opposed to just watching them, is increasing.

Perhaps the most troubling trend is the drop in viewership of the Wall Street Journal versions of the videos.  The Wall Street Journal is considered a conservative publication, so the possibility of a five-fold drop in viewership of the State of the Union among conservatives online could indicate a radical disengagement.  It may simply be a failure of marketing on the part of the Wall Street Journal, but it is worth investigating.  The corresponding increase in the New York Times versions only stress the point.

Finally, the demographics of YouTube are most likely very different than the demographics of television, and certainly than the demographics of households being polled.  YouTube is also international, so many of people voting on the State of the Union videos may not be American, and the president has generally been popular abroad.  The voting sample for YouTube is also more likely to skew younger than that of the polls.  In other words, the YouTube audience is more likely to be in the president’s political base.

There is no question that if current trends continue, the information revealed by YouTube viewership and voting numbers will be increasingly important to politics and beyond.

Video Sources:
2013 State of the Union: White House Official
2014 State of the Union: White House Official
2013 State of the Union: Wall Street Journal
2014 State of the Union: Wall Street Journal
2013 State of the Union: New York Times
2014 State of the Union: New York Times
2009 Inauguration Speech: New York Times
2013 Inauguration Speech: New York Times

Messing With Ruby

I’m overriding concatenation here, which completely messes up Ruby’s interactive console:

tsadok$ irb
irb(main):001:0> class String; def +(s); "no"; end; end
=> nil
irb(main):no:0> yes
irb(main):no:0> 1 + 1
irb(main):no:0> puts "hi"
irb(main):no:0> ^D
NameError: undefined local variable or method `nononono' for main:Object
irb(main):no:0> ^D