# Microsoft Redux and the Nexus 7

It has now been a couple of weeks since Microsoft’s announcement of Surface, but with no obvious release date or pricing. At the time there seemed to be some surprise at the short notice launch of the product. It seems to me the that reason for this was Google’s impending announcement of the Nexus 7 tablet.

I have been in the market for a portable device with a large screen for some time now, as using a smart phone to browse the web and watch films does not really work for long periods of time.

I had waited to see what the WWDC would announce, and it was a little disappointing. Only the MacBook Pro retina version was really of any note. The iPad had a slight upgrade as did the MacBook Air.

Now the dust has settled, I’ve ordered the Nexus 7. It does what I need which is to browse the web, plays movies, and display books. And it has a modest high DPI screen.

What about Microsoft? It seems to me that they’ve learnt almost nothing from Apple or Google. They managed to keep the Surface secret, and apparently could have kept it secret for longer. Until when? Until they had stock available for people to buy. Which is precisely what Apple do, and what Google have done. There is a couple of weeks delay, and some limited availability, but you can still buy one now.

The Surface device looks very appealing: a tablet with a cover that happens to be a keyboard that adds little to the weight of the device, and in the Intel version it can be used as a proper desktop laptop. But they’ve lost my sale right now. I want something now, not in 9 months, and I’m not waiting. Once I have the Nexus 7, I’m unlikely to buy a new one until it breaks, or turns out to be rubbish. Pricing the Nexus 7 at sub £200 is a shrewd move.

For tech products, that’s a throwaway price. It’s mid-range mobile phone price, and how often do you update those? You now have to wonder at what price Microsoft are obliged to offer an ARM-based Surface tablet. The form factor may be different but the market sector is similar: budget tablets.

The Surface tablet might just save Windows 8 from itself, especially the Intel version. But on the desktop Windows 8 is a mess, I’m still going to predict a sales disaster. Outside of OEM channels, enterprises and existing PC users are unlikely to upgrade. Little or no upgrading, just like Windows XP (or indeed, Windows 2000).

If the Surface tablet were available today, despite Windows 8, I would probably have bought one, more expensive than the Nexus 7. But it isn’t. My money has gone to Mountain View instead.

The boost threading library nicely abstracts the underlying operating system primitives into a consistent set of functions. The main author, Anthony Williams, maintains an interesting and comprehensive website. There is some interesting technical details about the implementation on stackoverflow for example, if you are not interested in looking at the implementation directly.

As you, the reader, are probably aware, the boost::thread library has more-or-less become std::thread in C++11. If you are running solaris, get off it. Really. Boost doesn’t support it and it holds you back.

As has been mentioned many times, “threading is hard”. The old adage about having to be twice as smart to debug code as you were to write it probably extends to being twice as clever again to debug threaded code. Fortunately with C++11 we have a few new language features that can help us out of some potential problems.

Consider this excerpt from the D Progamming Language book (TPDL) which covers Concurrent programming in D. The tl;dr version is that D implements concurrency via message passing which makes threading less prone to problems.

Can we do something similar in C++? Yes, and we have some new features to help. With C++11 we now have rvalue references, copy elision, and we have std::unique_ptr and fortunately they are present in VS2010 since the C++11 standard took so long to arrive.

With std::unique_ptr we can do this (from wikipedia):

std::unique_ptr<int> p1(new int(5));
std::unique_ptr<int> p2 = p1; //Compile error.
std::unique_ptr<int> p3 = std::move(p1); //Transfers ownership. p3 now owns the memory and p1 is rendered invalid.

p3.reset(); //Deletes the memory.
p1.reset(); //Does nothing.


So how does this help us? Consider the following contrived pre C++0x/11 example:

//  main thread
Processor processor;  //  implicitly starts a worker thread

//  temporary object
boost::shared_ptr<Widget> ptrWidget = boost::make_shared<Widget>(some_args);

processor.doSomethingAsync(ptrWidget);
//  some later change to the code introduces a thread bug:
ptrWidget->someMutatingMethod();  // <--  whoops!


What is wrong with this? Our main thread has a shared pointer to a Widget, which of course could be a polymorphic type. We pass the shared pointer to background thread, which also has a pointer to the same data. This is a classic ‘abstraction leaky’ threading scenario. Two threads have access to the same underlying data, often without the developer realising.

By using the language features and ‘leaning on the compiler’ we can make the code safer. Since std::unique_ptr conveys ownership explicitly and the data is isolated from differing threads. We can use the sink-source idiom to help safely move the data around easily:

std::unique_ptr<Widget> getWidget() { return std::unique_ptr<Widget>(new Widget); }

Processor processor;  //  implicitly starts a worker thread

//  pass a widget to the background thread
//  std::unique_ptr and std::move the ownership and copy elision
//  note:  no accessible temporary object here
processor.doSomethingAsync(getWidget());


We no longer have a problem with shared data between threads. This is just one trivial way to remove potential problems in your code base.

Unless you are really concerned about performance, using std::move is certainly recommended, and is probably going to be the preferred way of writing robust threaded code in C++.

# Windows 8 and How Microsoft Needs Its Own Jobs and Ive

A rare opinion piece.

Not one to shy away from stating the obvious, but Malcom Gladwell recently stated that history will remember Bill Gates for charity work, but forget Steve Jobs. I happened to agree with this, with the proviso that this will only be true if Bill Gates’ charity work is successful. I don’t think that history has forgotten John D. Rockefeller, who was arguably the Jobs/Gates of his day.

However, in the short term Steve Jobs and Jonathan Ive are going to be remembered for driving product design for the best part of two decades.

Microsoft need their own Jobs and Ive. If you’ve read Jobs’ biography, you’ll know that whilst he made all the important decisions, in his own strange way he did ‘listen’ to advice and change decisions where change was warranted. Apple’s share price and market capitalization demonstrate how successful the company was.

Why do Microsoft need their own version of Jobs and Ive? Windows 8.

They don’t need a Jobs clone, but they need someone who can cut away, let’s be blunt, all the marketing crap that seems to come from Microsoft these days. They need an Ive who is prepared to say when design doesn’t work, and the Jobs-clone to agree.

It could be argued that Bill Gates fulfilled the Jobs role at Microsoft, a decade before the press seem to deify Jobs for doing things that Gates was villified for.

It seems that Windows 8 is just Windows 9 Beta. In the release candidate, the tablet/phone OS styling, ‘Metro’, has been pushed into the Windows desktop, forming a difficult to use mess.

Someone at Microsoft should have stopped this. This is exactly what Jobs and Ive would have stopped.

The Metro design is arguably one of the biggest IT design changes in decades, and on a phone and tablet it works well.

Windows 7, in my opinion is the best and most usable version of Windows ever.

Together the desktop + Metro in Windows 8 seems to be a major step back from Windows 7 (and yes, I have installed it on hardware, and not a VM, and tried to use it as my main desktop). Will Windows 8 be successful? Given the usual OEM installs that follow Windows 8, there will definitely be sales. As far as businesses are concerned, I can see them skipping this version altogether (just like Vista). It is a shame from a technology point of view because there have been major changes that are going to make Windows development much more interesting and enjoyable (WinRT). If businesses don’t adopt it, sales for new Windows 8 software will suffer, and the Windows-based sofware industry suffers. There are already tens of thousands of developers out there that do not own a PC or any Microsoft product to do their day to day work, something unthinkable just 10 years ago. This could just exacerbate that.

The other problem that Microsoft have is, unbelievably, sales and marketing. They seem to eschew plain English for current buzzwords (e.g. Lightswitch – that tells me nothing about the product, and I’m not going to search to find out what it does either). A sensible descriptive name makes your product discoverable.

They also seem to think that having multiple versions of products is the way forwards (I recall a link to price vs. product, but can’t find it). This might be software versus hardware, but Jobs took the opposite view: reduce product lines. He reduced the product line by 70% and ultimately produced only 4 products. Apple are now the biggest tech firm in history.

Apple give away XCode for development at all levels, but until the other week Microsoft weren’t going to give away the basic VS 2012 Express C++. Whatever happened to ‘Developers! Developers! Developers!’? Your platform lives and dies by the apps on your platform. The cheaper your development tools, the more people use them to produce applications.

If Microsoft are prepared to make a radical overhaul of Windows by adding the Metro interface, they should make a radical overhaul of the company itself. It is looking increasingly like Windows 8 will be Microsoft’s jumping the shark moment.