Monthly Archives: December 2012

WinRT C++: Raising PropertyChanged event on a GUI Thread

If you are a WPF developer you don’t have to raise the PropertyChanged even on a GUI Thread, but it seems as though same pattern in C++ WinRT Windows Store component requires this even to be raised on a GUI Thread.

I happened to stuble upon another blog (http://w8md.wordpress.com/) which helped me with my Unit Testing (http://w8md.wordpress.com/2012/09/26/async-unit-tests-in-ccx/).  It happened to refer to a project on CodePlex called Hilo.  Looking at the source code in the TestHelper.cpp class (TestHelper.cpp) I found helpful code.  Adapted it below:

In the .h file:


namespace RSSParser
{
  [Windows::Foundation::Metadata::WebHostHidden]
  [Bindable]
  public ref class ViewModel sealed : public INotifyPropertyChanged
...
  protected:
    void RaisePropertyChanged(String^ propertyName);

In the CPP file:


void ViewModel::RaisePropertyChanged(String^ property)
{
     CoreDispatcher^ dispatcher = CoreApplication::MainView->CoreWindow->Dispatcher;
     dispatcher->RunAsync(CoreDispatcherPriority::Normal,
       ref new Windows::UI::Core::DispatchedHandler([=] () -> void
      {
       PropertyChanged(this, ref new PropertyChangedEventArgs(property));
      }));
}

Advertisements

My Software Project

I’ve been using my Surface since the end of October, 2012 and I have yet to find a decent news reading app which would load all the articles in the background and let me read their full text during my commute. I spend about an hour on the bus into the city and have plenty of time to invest on some reading.

As a bonus, I’d like to have each article be formatted for easier read.  Ads removed.  Instapaper and Readability do that, but I don’t want any of my users to have to sign up for those services.  I want my customers to deal with my app.

So I started coding the app in C++ on top of Windows RT.  The home for my project is here: http://windowsnewsreader.codeplex.com. I’d like to invite other developers to read and contribute.  It’s under Ms-PL license, Microsoft’s Open Source.

Microsoft’s New Products

Now that Microsoft released all the products they would use to compete against Apple and Google, it’s worth reviewing how the offering from the three major players stack up.  Apple pretty much defined the three categories below.

  • Computers
  • Smartphone
  • Tablets

They are also the most successful and the most admired for it.  It makes sense to start with them.  I started using Apple products when I got my iPhone.  I was impressed with the product and saw it as a solid contender.  Back then the only real competitors to iPhone were phones running Google’s Android.  Microsoft was trying with their Windows 7, and overall hardware quality was not up-to par with the iPhone.  In fact not until recently, neither Google’s Android, nor Microsoft’s Windows Phone based devices had a contender with hardware that was good enough to rival experience one would have using an iPhone.  The Galaxy SIII, IHMO, is equal or even better than the iPhone, while latest Windows 8 devices are also up there.  I am using Nokia 920 and am very happy with the device.  I did not commit myself to too many apps on the iPhone, so did not feel as much pain when switching to a new ecosystem.

My reason for writing this post is to air my frustration with Microsoft.  I am a Software Developer, whose fortunes were tied to the success of Microsoft in the enterprise.  It was a successful relationship for me.  I understood their philosophy and was comfortable around their APIs.  I learned .NET and enjoy developing GUI applications that ran on Windows computers.  Microsoft’s languages and frameworks held their own against Java and open-source offerings from Computer Science perspective, while Microsoft’s clout provided a reliable base of customers who need new software and can hire me to write it for them.  As new products such as Smartphones and tablets gained popularity being an enterprise Microsoft developer seems a bit less comforting then before.  So naturally, I waited for Microsoft to come out with propose a set of products which I, the developer can start coding against, without making a gigantic leap away from the languages, frameworks and philosophy with which I was comfortable for years.  Well, my wait is over.  Let’s see what I got.

A small review first.

Apple

They are the only ones that go it alone.  They create hardware, software, even the chips on which their systems run.  Their Mac computers use Intel chips, but they are reviewing the possibility of switching to ARM-based processors, which they would, likely, produce themselves. Their products are phenomenally successful and by being first at creating a usable smartphone and a tablet, they established a fairly high bar for competitors to clear as they consider competing in this segment.

Here’s how Apple’s products fall into the three categories above.  All products are made and completely controlled by Apple from software to hardware.

  • Computers – iMacs running MacOS
  • Smartphones – iPhone running iOS
  • Tablets – iPad + iPad mini running iOS

By being first, they also created and nurtured a large ecosystem consisting of apps, services. developers and fanboys which helps reinforce their dominance in this game.  This creates a strong level of stickiness, making it more difficult for users to switch, because they are used to a large number of apps in the store, a strong level of support and even something as simple as familiarity with the way their products work.  I recently switched away from my iPhone and I even found it difficult to adjust to the new set of sounds on my phone.  Like Pavlov’s dog I was trained to react to sounds of text messages differently than sounds of arriving emails.

Google

Google competes in all three categories, and has some success influencing the tablet category by popularizing the 7″ form factor.  Unlike Apple, they are all about partnerships.  They do not make their own hardware.  They license their software which is used by others to build finished products.  To make some products stand out as Google-signature products they use Nexus brand as a halo brand on devices which enjoyed higher level of Google influence during their development.

Here’s how Google’s products fall into the three categories above

  • Computers – Chromebooks – developed by partners using Google’s Chrome OS
  • Smartphones – phones developed by partners, Samsung, LG, HTC, SONY and others. They run a version of Android OS.  Nexus is currently developed by LG
  • Tablets – tablets developed by partners running a tablet-adopted version Android OS.  Nexus is currently developed by ASUS

Google began competing against Apple early on.  Unlike apple which had a single iPhone to offer, Google cast their Android net as widely as possible.  Phones running Android OS came in different shapes and sizes, with and without touch screen or keyboards.  Thanks to aggressive push from Google along with an open approach to their app store, the number of phones running android is greater than the number of iPhones in the wild.  The ecosystem is also well established with most important apps being available on Android as well as on iOS.

Chromebooks are not a real competitors to laptops running Windows or MacOS, they are weaker and can’t run any apps developed for other platforms.  But Google is trying to make them relevant by creating an internet-based ecosystem into which these Chromebooks would plug-in.  And once this ecosystem is robust enough, Google should be able to show us that we don’t need powerful PCs or Macs to be as productive or as entertained, we should be able to just have Chromebooks and use the internet as brought to you by Google for everything else. Consumers were first to use GMail for mail and Google Docs for apps.  As software matured Google turned to enterprises.  They succeeded by turning quite a few enterprises away from using in-house email and document management system in favor of their internet-based apps.

Microsoft (finally!)

For a while it seemed as though Microsoft did not want to participate as Apple and Google were having all the fun.  Since 2007, the year when iPhone came out, they saw their main product, Windows and Office taking losing their relevance as more people skip investing in PCs altogether as non-PC devices gain more power and ability and are able to truly replace the PC with all the functionality they offer.  By not being in the game Microsoft could become completely irrelevant.  As alternatives became real and viable, people were finally able to turn away from the PC.

Microsoft woke up in 2011.  They created internet-based versions of Office and Outlook to counteract Google’s offerings on the internet.  On the OS front, they bet on Windows 8 and Windows Phone 8.  Just as Google and Apple, Microsoft offers two OS, but the unlike their competitors they use a mobile Phone OS, Windows Phone 8 solely for the phone.

Here’s Microsoft’s breakdown of products into categories.

  • Computers – Windows 8 – based PCs developed by partners.  Some PCs carry a Microsoft Signature brand to separate them in the crowded PC market.
  • Smartphones – phones developed by partners, Nokia, Samsung, HTC, running Windows Phone 8.
  • Tablets – Windows8/WindowsRT – based tablets developed mostly by partners.  Microsoft Surface is made completely by Microsoft.  This is a special case.

Notice that unlike Google and Apple, Microsoft decided that Windows 8, the full-featured OS that branched from the Windows tree is the OS of choice for their tablet universe. Was this the right choice?

As of right now, my answer is No.  It’s not “mobile” enough.  It’s definitely a lot more touch friendly than any previous version of Windows.  It’s also lighter, faster and can run on the low-powered ARM chips. But its missing some fundamental feature we are used to when using mobile devices.  These are simple feature we take for granted, such as:

  • Ability to see current time, usually on top of the screen
  • Ability to see battery status, usually on top as well
  • Ability to see the status of the Wi-Fi connection, usually on top too
  • Ability to select all items in their native mail app.  You can do this by popup – opening an On-Screen-Keyboard and doing a CTRL-A (really Microsoft? a keyboard for this)

Basically, it’s not mobile enough.  Along with general glitchiness to which I can devote a whole blog post, their Surface is not a good product. But even if they can fix the glitchiness by releasing new drivers, I think they are still going to be held back my the choice of the OS they used on their mobile device.  In the meantime, some of the design choices they made in the OS are wrong.  Here’s a link to an issue I had raised in the community.  Basically, the problem is that badly written apps can affect the performance of the whole OS!

There are some positives by choosing Windows as an OS for the tablet. I wish I could add more, but for me only these were important.

  • Ability to have multiple users, as Windows is inherently multiuser
  • Ability to run Office.  I proof-read my wife’s college paper on the Surface running Word. I also edited a spreadsheet I had created for the purchase of my new home.
  • Ability to code for the device using Microsoft Visual Studio

This last one is, probably, the most important reason.  I really want it to succeed.  I can write Java and, I did write a demo app for the iPhone in Objective C.  But I would really like to continue using the tools with which I am comfortable.  As of now, it does not look good for Microsoft.