Wednesday, October 12, 2011

Dart Hits Some Bullseyes

On Monday, Google announced a new programming language named Dart.  It aims to be faster than JavaScript and better suited to large scale software projects.  After thinking about the language for the last couple days, I think Google's engineers have started a compelling replacement for JavaScript.

Any client-side web programming language will be used by programmers from all backgrounds.  Dart's optional typing lets both static typing enthusiasts and dynamic language enthusiasts have what they want (with some minor compromises).  Throughout this article, I've linked to Dart code samples on the Dartboard so you can try for yourself.

"I Hate Static Types"


Many web developers come from a dynamic languages background and actively dislike static typing.  Many more probably have no idea what static types are and simply grew up writing JavaScript code.  Both groups of developer should be happy with Dart.  They never have to enter a type declaration and Dart is still an improvement over JavaScript.

Dart provides block scoped variables rather than the function scoped variables used in JavaScript.  Accidentally overwriting a function scoped variable is one of the most common JavaScript errors I encounter.  It's more likely to become a problem as functions evolve and grow.  With Dart, for example, this is less likely to happen.

Dart also provides a succinct function syntax rather the verbose JavaScript one.  As often as client-side programming uses callback functions, this sort of code is a pleasant change of pace.

Dart even has string interpolation.  Anyone who's programmed in Perl and JavaScript for longer than 5 minutes knows how nice this will be.

Some developers may not care, but Dart provides immutable variables with compile time errors.  As far as I can tell, JavaScript "const" just silently ignores subsequent assignments.  I've debugged quite a few JavaScript programs where code modified a variable it shouldn't have.  Declaring a final variable and receiving an error would have saved me lots of debugger time.

Dart makes some other improvements which aren't as noticeable.  For example, Dart's namespace rules should eliminate bugs from global variables.  The language spec makes several accommodations which should eventually make Dart run faster than all current JavaScript engines.  Lars Bak, who developed the super-fast V8 JavaScript engine is one of Dart's main developers.  He ought to know a thing or two about making a language that can run fast.  Dart's library system also allows for optimizations that could substantially improve website load times someday.

Even if Dart just used dynamic typing, these changes alone are enough for me to switch.

"I Love Static Types"

Many other web developers come from a static typing background and want types when developing for the browser.  GWT and Closure Compiler show how far these developers will go to have their static types.  Dart's type system gets them most of what they want.

One benefit of static typing is describing a developer's intentions.  JavaScript developers often use specially formatted comments for this purpose.  One can think of Dart type annotations as a more succinct version of the same thing.  Since Dart type annotations don't change a program's semantics, they really are just fancy comments.  As always, the comments can be wrong if your tools don't enforce otherwise.

The Dart compiler performs type checking.  If you want to catch type problems at compile time, just pay attention to the warnings (hover over line 4).  Even though they're not errors, the compiler did the hard work for you. Dart also provides a development mode for runtime type checking.  These checks are disabled in production, but it reminds me of the well-tested robustness principle, applied to programming languages.

Since type annotations are part of the language, it's likely that future tools will handle type inference.  Closure Compiler already does this for JavaScript, so the tools will probably arrive soon.  Type annotations also provide additional hints the JIT could use to further improve performance.  With JavaScript, the JIT must rely entirely on its own observations.

Be Patient

Many of Dart's critics act as though the language is finished.  Yes, the Dart to JS compiler produces horribly bloated JavaScript.  No, Dart doesn't have mixins.  Yes, Dart's VM is slow.  A quick glance at the version number (0.01) suggests we should be patient.  The Dart issue tracker and mailing list are full of good discussions about solving these problems.  The language designers are open to evolving and improving the language.

Dart isn't perfect and can't be perfect, but I think it will become a meaningful, valuable improvement over JavaScript

Friday, September 30, 2011

Easily Anonymous Bitcoins

There have been some healthy reminders recently that Bitcoin isn't anonymous out of the box.  I've gotten the impression that sentiment has swung the other direction toward thinking that Bitcoin anonymity is very difficult to attain.  As xkcd humorously reminds us, we should think about security and anonymity practically.  If you buy marijuana with Bitcoin and your neighbors can smell the evidence every Friday night, Bitcoin's anonymity isn't your problem.  It's fairly easy to anonymize Bitcoin enough that it's not the weak link.

  • install Tor and use it for all subsequent browsing steps
  • visit Instawallet to anonymously create a Bitcoin wallet
  • List $100 cash for sale on Silk Road Market
  • Mail the cash through any US Postal Service drop box
  • When the Silk Road bitcoin payment arrives, withdraw it to your Instawallet
You can now spend Bitcoins from this Instawallet with complete anonymity.  Instawallet doesn't know who you are (because of Tor).  Silk Road doesn't know who you are (because of Tor).  The USPS doesn't know who you are (anonymous drop boxes).  The person who sold you Bitcoins doesn't know who you are (anonymous US mail).

Slightly more complicated: buy a Bitcoin mining rig and connect to a mining pool through Tor.  Newly mined coins are completely anonymous.  You can send them to your Instawallet or to a Bitcoin client running behind Tor.

There are hundreds of variations on these techniques, but the results are the same.  High power forensics and digital surveillance might be able to pierce the anonymity veil.  At that point, your attacker is probably motivated enough that Bitcoin anonymity is the least of your worries.

Thursday, September 01, 2011

On Tax Breaks

For those who don't know my biases, I support the notion that that government is best which governs least.  The question in this post is how to apply that principle to specific tax policy decisions.

Preface

On a regular basis, governments propose to exempt certain favored activities from taxation.  Some libertarians support these tax breaks because it reduces the government's overall tax revenue.  I think the market manipulation embodied in targeted tax breaks exceeds any benefit from reduced revenue.  If existing tax breaks can be removed in a revenue neutral way, that's ideal.  If not, I think the market is still better off to have them removed; even if it means higher government revenue in the short term.

A Vain Street Thug

Consider the following scenarios:

  • A street thug walks up to me and says, "I'll shoot you unless you give me $20". He then spends $20 to have his shoes polished
  • A street thug walks up to me and says, "I'll shoot you unless you give me $20 or polish my shoes"

The first scenario mirrors taxation.  We pay taxes because of threatened force.  Both the tax revenue and subsequent expenditures appear in government budgets for all to debate.

The second scenario is like a tax break.  To retain my money, I must act as the government directs.  Neither my lost labor nor his polished shoes appear in the government budgets.

In both cases, the government manipulates the market to obtain its desired result.  In one case it's transparent and obvious.  In the second, it's hidden behind a facade of choice.  The offer to polish his shoes doesn't make the thug's hold up any less objectionable.

Wind Production Tax Credits

Here's a real example.  Uncle Sam offers a 2.2¢ per KWh tax credit for producing electricity from wind. Depending on the time of year and local market conditions, the tax credit alone can exceed revenue from selling the electricity.  Even when electricity rates are high, wind farms aren't profitable enough to use the entire tax credit themselves, so they sell their tax credits to investors who use the credits to offset their own tax liability.  Obviously, the wind farmers aren't "keeping their hard earned money", they're selling political favors granted to them by Congress.

These kinds of tax credits also create a dangerous bubble in the market.  In a free market, the price of electricity would drop as new generation capacity comes on line.  The lower electricity prices tell producers that they should reconsider any plans to build additional capacity. Highly efficient projects may proceed despite the lower prices, but inefficient projects will be abandoned before they're built.

The tax credit changes this dynamic. The credit exists at a fixed price until Congress changes it (ignoring inflation adjustments).  Anyone that builds a qualifying wind farm gets the tax credit.  As new electrical capacity goes online, the price of electricity still drops, but the tax credit stays the same.  Since the tax credit revenue accounts for such a large portion of the wind farm's total revenue, wind farmers don't hear the market's message to stop building.  They construct wind farms whether they're needed or not.  Once Congress removes the tax credit, the completed, inefficient wind farms immediately become unprofitable and are abandoned; leaving a mess for someone to clean up.

From this perspective, Wyoming's .1¢ per KWh tax on wind electricity can be seen as a 4.5% push back against Federal manipulations of the electricity market.  If Wyoming's tax were set to exactly match the Federal tax credit, it could be seen as an old-fashioned nullification of manipulative Federal policies.

Health Care Benefits and Income Tax

In 1942, Congress passed the Stabilization Act which prohibited employers from increasing wages faster than a certain rate.  Since businesses still wanted to compete for the best employees, they began offering benefits as a way to skirt the price controls.  In 1943, an administrative ruling declared these benefits exempt from income tax.  This created the third-party payer system of health care we have today.  When employees consume health care, they're doing it on their employer's dollar.  Since it's not their money, employees consume more than they otherwise would.  Employees are also less sensitive to price increases.

The subsequent rise in health care costs caused by this market manipulation provided the impetus for government health care programs like Medicaid and Medicare.  These programs now account for a substantial portion of Federal expenditures.  The wage and price controls were fortunately abandoned decades ago, but the health insurance tax break remains.

Even if eliminating this particular tax break were to increase government revenue by $200 billion annually, as some estimates state, it's hard to imagine it would be as damaging to the U.S. health care market as the manipulative tax breaks themselves have been.

Encouraging the Lobbyists

Because Congress has granted so many tax breaks in the past, people expect that they might grant tax breaks in the future.  It's hard for industry to resist the temptation of exempting themselves from taxes and leaving their competitors to carry the burden.  Those who give in to temptation hire lobbyists to lavish kickbacks on politicians who might be the slight bit inclined to carve out another loophole.  As long as this kind of power exists, it will be bought.

Keep Your Eye on the Prize

In the end, the goal is to eliminate all general taxes.  Once the income tax and sales tax is abolished, it's no longer possible to manipulate the market with tax breaks or the threat of higher tax rates.  Until that day, I think a flatter, broader tax structure, which requires everyone to feel the pain, is the option least harmful option.

Saturday, June 11, 2011

Bitcoin: Resilient Internet Payment

I blogged six months ago about why Bitcoin matters. Since that time, I've developed some services with Bitcoin and had two of them shutdown by PayPal freezing my account. I've also sold thousands of dollars worth of Bitcoins in cash sales on the street. I've come to the conclusion that my earlier statement about Bitcoin being "resilient in the face of disaster" may be Bitcoin's most important attribute.

Features

Bitcoin has seven main features. Critics usually choose one feature, argue that it doesn't hold and conclude that Bitcoin will fail. I think any three of these features could fail simultaneously and the currency would still succeed. Consider it an architectural margin of safety. The seven features are:
  1. Predictable supply
  2. Anonymous payments
  3. Permanent payments
  4. Fast payments
  5. Low transaction fees
  6. Easy cross-border transfers
  7. All purchases allowed
Most of these features are well documented elsewhere so I won't explain them further. Fast payments (#4) may need some clarification. When I accept a credit card payment, it clears in a couple seconds. That corresponds exactly to a Bitcoin transaction arriving. After 180 days the credit card payment is essentially permanent. For Bitcoin, permanence takes about 1 hour. In that sense, Bitcoin is faster than credit card networks.

Investors

The Bitcoin investors I've worked with care almost entirely about the limited, predictable supply. Some of them are gold bugs or real estate mavens. They've gotten rich on the limited supply of those commodities and see similar opportunities with Bitcoin. Nearly ever feature except the inflation caps could fail and they'd still be happy. A deflationary spiral is their dream come true.

As this demographic holds greater Bitcoin wealth, anonymous payments and easy cross-border transfers will become more important. Bitcoin has potential to become the Swiss numbered account of the future.

Online Retailers

For businesses selling goods and services online, predictable supply is arguably irrelevant. As long as there's no hyperinflation, they'll do fine. However, they care deeply about features 3-6. Fraud and payment processing fees are substantial costs to their business. I know of at least one Bitcoin vendor who offers a 5% discount for Bitcoin purchases because Bitcoin eliminates those two transaction costs.

I've bought and sold services with Bitcoin dozens of times with people outside the United States. In each case, the experience was more pleasant and less expensive than using PayPal or a credit card. Features 1, 2 and 7 were completely irrelevant to these transactions.

Unpopular Commerce

The Internet has been a boon for unpopular commerce such as pornography, gambling, electronic cigarettes and now illegal drugs. Because the commerce is unpopular, many buyers want their orders placed anonymously (feature #2). Pornography and gambling have substantially higher chargeback rates than other industries (#3). Many mainstream payment processors prohibit transactions for these services (#7). In all three cases, Bitcoin provides a solution.

Other Bitcoin features are icing on the cake. They could be removed without reducing Bitcoin's utility for unpopular commerce.

Dissidents

It now seems common for governments to control dissident groups through the financial system. Banks and payment providers are threatened with punishment if they handle funds on behalf of dissidents. Features 2, 3, 6-7 appeal to these groups. Other features could fail and Bitcoin would still be useful for WikiLeaks or LulzSec (both of which accept BTC donations) or funding underground churches in China.

Conclusion

I don't presume to know all groups which might benefit from Bitcoin. I suspect that each of them will want a subset of Bitcoin's possible features. As long as that's the case, Bitcoin has a good chance of succeeding.

Saturday, December 11, 2010

Why Bitcoin Matters

E-commerce in 2008 amounted to $3.7 trillion dollars. That's 12% higher than 2007 while the entire economy increased only 5% during the same period. As online commerce increases, the fundamentals of electronic exchange become more important. Bitcoin is an electronic currency issued without a central bank. It has remarkable properties making it important for an age of electronic commerce.


Transaction Fees Set by a Competitive Market

If all 2008 online commerce had been paid for with PayPal, the fees would have been $62 billion (Amazon and Google charge identical fees). Payment processors provide some additional value but it's largely an expensive system for subtracting numbers in a database.

The Bitcoin network essentially charges no transaction fees. Participants can pay to expedite their transactions, but it's not mandatory. Any network participant is welcome to process any transaction on the network. This makes Bitcoin transaction processing a commodity whose price is likely to remain permanently low.

No central point of failure

Recent attacks against PayPal, MasterCard and Visa remind us how centralized electronic payment processing is. A single PayPal outage can cost 25-30% of an online retailer's sales. It seems unwise to put so many economic eggs in so few baskets.

When was the last time you heard of a BitTorrent outage? Despite the U.S. government, the recording industry and various ISPs trying to destroy it, the BitTorrent network has prospered. Bitcoin's peer-to-peer network is similarly resilient. Failing components are quickly ignored and the network continues processing payments without a hitch.

No chargebacks

Credit card fraud is a challenging problem for large businesses who spend much effort building fraud detection systems. Small businesses can't justify such expensive systems. For them, a bad weekend of fraud can mean a missed payroll. The net effect is to increase the barrier to entry for online commerce which decreases competition and innovation and increases prices.

Bitcoin payments are not reversible by a third party. Just like cash given to a street vendor, Bitcoin payments can't be contested after the hotdog is eaten. If a buyer wants a refund, he must persuade the vendor. This places a greater burden on buyers to beware, but in an era of ubiquitous product and vendor reviews, it's easier for a consumer to find the reputation of a vendor than vice versa.

No long-term inflation

Bitcoin's money supply is strictly limited by the protocol. The total number of bitcoins available approaches 21 million over time. The currency's first decades allow for limited, predictable inflation. Automatic, bi-weekly adjustments recalibrate the system toward these goals.

Mr. Bernanke's helicopter full of cash has highlighted how dangerous a centralized, unpredictable money supply can be. As long as the power exists to inflate a currency, it will be done.

Conclusion

Perhaps Bitcoin itself won't dominate the market, but certainly it shows the way toward a future of low-cost, predictable, digital currencies resilient in the face of disaster.

Wednesday, November 17, 2010

Full Body Scanner Deaths

Some quick back of the envelope calculations suggest that full-body scanners, if fully implemented across all airports, will cost 3 people their lives this Thanksgiving travel season.

Assuming that half of those who disapprove of full-body scanners decide to drive instead of fly, there will be 1.86 billion more miles driven this Thanksgiving than would otherwise happen. Assuming that full body scanners make no impact on flight safety, the extra danger of driving those miles will result in three more driving fatalities than would have happened otherwise. If full body scanners actually reduce airline fatalities, the marginal death rate from driving would be even higher.

For the full calculations, see the spreadsheet.

Wednesday, July 29, 2009

Interruption and the Cost of Context Switching

I've been thinking about interruption lately. I shared some thoughts about anticipating interruptions in an article about the probability of interruption. More obviously, when an interruption happens it costs me something. Specifically, I have to switch from doing one thing to doing something else. There's a non-zero cost to focusing my mind on a new task. That effort is pure overhead. It's like energy lost to friction or electricity spent "heating the whole neighborhood" (as our parents used to say). If one can reduce interruptions, one should be able to reduce context switching costs.

I use a small program that I wrote to record the time I spend working. When I switch tasks, I press a few keys to indicate what I'm working on now. At the end of the month, I use this data to generate invoices, etc. Even though I don't record every context switch in my time clock program, I do record many of them. Reviewing the data for the last 18 months shows that I worked on 1,635 unique tasks. I switched context 7,768 times (subjectively, most of those were caused by interruptions). On average, I spent 25 minutes working on a given task before switching to something else. If I assume it takes me two minutes after a context switch to become productive again (which is a very conservative estimate), it means that I spent 7% of my total working time just switching between responsibilities. That 7% produced very little value for me or my clients.

Managing interruptions is an important component of enhancing one's productivity. I'd be thrilled if I could effectively have 7% more time in a day.