Microsoft should pull a Dominos  

Thursday, July 01 2010

The state of the union

The writing is on the wall for Microsoft. They have posted diminishing revenues since 2008 and have consistently not been phased by it. The situation has become so dire that rumors have been circulating about some of the best talent that Microsoft has (like Jay Allard, among others) are readying to leave because of disagreements with CEO Steve Balmer. Now one can say that’s not unusual given how long Allard was with the company, but I’d still be curious.

Having worked with (and for some time at) Microsoft over the last five years I saw a pattern of hubris, failure to communicate, and downright incompetence. It’s this pattern that I believe has led to recent developments such as three different mobile operating systems.

When I speak with current and former employees the company is the butt of at least a couple of jokes, but overall they are pretty indifferent to company affairs beyond the scope of their own group. This is merely a symptom of a larger corporate structure issue, put simply: Microsoft operates like a feudal society


Read More...
  • Posted by Charlie Robbins

Being Batman Full-time  

Monday, June 21 2010

Bruce Wayne gets paid

Still reading? Thanks. I’ll try to keep it short. I was born with the hacker mentality; i.e. a strong desire to understand exactly how things around me work. If you’re uncomfortable with the word “hacker” let me start off by saying you should just stop reading now.

I was recruited by Microsoft when I was 19 at a McGill University job fair. I didn’t think I had a snowflakes chance in hell, but I went to the interview anyway. I also had some reservations about working for “the man,” but when you’re 19 with no job prospects you’d be surprised how quickly one changes their mind. I got the job, and my “career” began although I didn’t look at it that way. I worked at Microsoft that summer and I ended up going back to Microsoft the following year to work on WPF (then “Avalon”).

By this point, I was also already using Rails 1.1 in my spare time to hack together some projects on the side. I was writing .NET during the day and so bored with it that I would come home and tinker with other stuff. This is what I mean when I talk about Bruce Wayne by day and Batman by night. Bruce Wayne has to pay for Batman’s exploits. If Wayne Industries were to fail, so would Batman. I had found something that paid well and supported my lifestyle. The rest of my career is relatively mundane so I won’t bore you with all the specifics. It’s pretty standard stuff for any motivated code monkey. Work to live, not live to work.

Batman kicks ass

Throughout this time though, I was consistently not satisfied with the work I was getting. It was challenging in a “how fast can you type” kind of way, but it didn’t get me up in the morning. What it did do though was pay my fucking bills, which if you’ve never lived in Manhattan are not cheap. But living in Manhattan is home to me: I was born here and I’ll probably die here so moving out was not an option.

So I kept hacking at night: coding, contributing when I could, and getting as much diversity as I could in the philosophy and approach employed by various languages, communities, and frameworks. It was exciting to me just to see what was out there.

Getting to the point, being Batman full-time

I was still programming; I kept working and pushing open source technologies in my own professional work. As time went on, I kept getting the same feeling that I needed to kick ass full-time. The money was good, but I realized that I needed to move on. So I quit my job and I’m pursuing my ass kicking ambitions full-time.

The purpose of the above story was not to evangelize one language or platform over the other. It was to illustrate a point about choosing to do what you love through my own personal experience. Hopefully some of you will be catalyzed to do the same.


  • Posted by Charlie Robbins

Increase the performance of large WPF applications across the board  

Tuesday, May 11 2010

I was just debugging a very long render delay in some WPF code and I came across this little tidbit.

The quote of interest is: “Each time a control references a ResourceDictionary XAML creates a new instance of it. So if you have a custom control library with 30 controls in it and each control references a common dictionary you create 30 identical resource dictionaries!”

Normally that isn’t a huge problem, but when you consider the way that I personally (and have suggested to others) that they organize their resources in Prism projects it gets to be a serious problem. For example, let’s say we have this project structure:

 
/MyProject.Resources
    /Resources
        -Buttons.xaml
        -DataGrid.xaml
        -Global.xaml
        -Brushes.xaml
        -WindowChrome.xaml
        -Icons.xaml

/MyProject.Module1
    /Resources
        -Module1Resources.xaml  
        (References all Dictionaries in /MyProject.Resources/Resources/*)
    /Views
        -View1.xaml
        -View2.xaml

/MyProject.Module2
    /Resources
        -Module2Resources.xaml   
        (References all Dictionaries in /MyProject.Resources/Resources/*)
    /Views
        -View1.xaml
        -View2.xaml

/MyProject.Shell
    /Resources
        -ShellResources.xaml   
    /Views
        -MainShell.xaml

If in your views you reference the module-level ResourceDictionary (which helps for maintainability and modularity) then every time you create an instance of View1.xaml for example, you would have to parse all the ResourceDictionaries in /MyProject.Resources/Resources/* every time. And if in View1.xaml you have a reference to say View2.xaml now you’re parsing it all twice every time! This isn’t really a memory concern but it is a huge performance concern. There can potentially be thousands of lines of XAML code to parse and the time really does add up as your views become nested and more complex

I recently switched all of the MergedDictionary references:


<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source=”/SomeDictionary.xaml” />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

To use the attached SharedResourceDictionary which shadows the Source property and keeps a global cache of all ResourceDictionaries parsed:


<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <SharedResourceDictionary Source=”/SomeDictionary.xaml” />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

And I saw a performance increase of almost two orders of magnitude: From almost 6000ms to 200ms. As always, this code is available on GitHub.


  • Posted by Charlie Robbins

The [Travel] Gods Must Be Crazy  

Monday, March 22 2010

I’m suing American Airlines in the amount of $977.25 for failure to provide services. That includes the $427.25 cost of my round-trip ticket plus ten hours of my time wasted at my average consulting rate of $55.00 / hour. Logistically this involves a forthcoming small claims suit in the City of New York listing their office at 100 E 42nd Street, New York, NY 10017. The $35.00 fee (that I’ve paid before) is a small price to pay for the satisfaction of holding accountable a company that embodies everything that, in my opinion, is leading to the collapse of the American economy.. Why do you ask? It will become apparent through a series of incompetent events that mostly transpired in a couple of hours. Let us start at the beginning though.

This past fall my friend suggested that she, some mutual friends, and I make our way to Austin, TX for SXSW, an incredible indie music, film and interaction festival celebrating its 23rd year in operation. It was pretty much a no-brainer decision for me and I almost immediately booked a round-trip from New York, NY to Austin, TX on American Airline on Travelocity.

Fast forward to 3/1/2010 when my phone records indicate I made a call to American Airlines customer service at (800)433-7300. I called American Airlines to change my round-trip from New York, NY –> Austin, TX to a one-way from Austin, TX –> New York, NY. You see, in the interim my company had asked me to represent them at a large industry conference in Las Vegas, NV. The dates of this conference happened to overlap with my flight to SXSW. So instead of going New York, NY –> Austin, TX I was now going New York, NY –> Las Vegas, NY –> Austin, TX –> New York, NY. The woman I spoke with about this issue told me that this wouldn’t be a problem and that I was all set for my 3/21/2010 flight from Austin, TX –> New York, NY. GREAT!!! … so I thought.


Read More...
  • Posted by Charlie Robbins

MIX10 Keynote Redux : Windows Phone, and Silverlight 4  

Monday, March 15 2010

Although the software announcements made today were somewhat disappointing (no releases, just more betas, CTPs, and RCs) the cross-platform functionality offered by XNA 4.0, Silverlight 4.0, Visual Studio 2010, and Windows Phone 7 were compelling. A number of partners gave demos today that showcased some of the really interesting new features of Blend 4 Beta [download here] that I will be discussing more later tonight:

  • eBay demos Desktop Simple Lister (with help from Cynergy)
  • Netflix demos Smooth Streaming on WP7
  • Foursquare demos location aware services WP7
  • Other great demos: Seesmic, Major League Soccer, and Shazaam

Another big announcement was that they’ve open sourced the Silverlight media framework, that was used to deliver the smooth-streaming HD experience for the 2010 Vancouver Olympic games. The code is available at http://smf.codeplex.com

The focus was very strong on targeting multiple platforms that support Silverlight or XNA with a single code-base. This ubiquity of development has always been a major goal for Microsoft and so-far the case they’ve made is very compelling. I can’t wait to dig into the nuts and bolts of it and post more developer and designer focused analysis.


  • Posted by Charlie Robbins

MIX10 debuts 4s, 7s, and 10s  

Monday, March 15 2010

Microsoft made a flurry of announcements this morning via press release (link to come). As I watch Sterling Quinn, the 16-year-old Yo-Yo champ (20 minutes is too long for a warm-up FYI) I’ve read that Microsoft has:

“Announced the availability of comprehensive tools”

  • Visual Studio 2010 Express for Windows Phone
  • Windows Phone 7 add-in to use with Visual Studio 2010 RC
  • XNA Game Studio 4.0
  • Windows Phone 7 Series Emulator for application testing
  • Expression Blend for Windows Phone CTP

“Available for download today”:

  • Silverlight 4 RC
  • Expression Blend 4 Beta – “New features such as Path Layout enable developers and designers to build and animate innovative user interface design via a groundbreaking visual layout mechanism, without the need to write code.”

“Several leading companies will be creating exciting applications and games for Windows Phone 7 Series.”

“Silverlight adoption has continued at a rapid pace with installations approaching 60 percent of all Internet devices worldwide – an increase of nearly 15 percentage points in just four months.”


More to come. Stay tuned in here or follow me on Twitter @indexzero.


  • Posted by Charlie Robbins

Packed and ready for #MIX10  

Friday, March 12 2010

MIX10 gets started this Sunday. Looking forward to seeing what Microsoft et al. have up their sleeves for Windows Phone, Silverlight 4 and WPF 4. There also seems to be a stronger focus on web standards and Javascript this year:

Here’s a list of some of the talks that I’m planning on attending:

You can read more about my adventures on the floor at MIX10 by following me on Twitter, @indexzero, or checking back here periodically. Hope to see some of you there!


  • Posted by Charlie Robbins

XamQuery: Reconciling the "theory" and "reality" of WPF vs. Silverlight  

Monday, February 22 2010

Disclaimer: This technology does not actually exist yet, I am looking for feedback about this idea and anyone interested in working on it.

I’m sure a lot of you have seen this image. It highlights some of the pain of working with Silverlight coming from a WPF background.

silverlight-wpf-subset

It occurred to me over the weekend that this is really a statement about the consistency of the implementation of XAML DOM APIs. With that in mind the next logical conclusion was that there is a very important parallel in the Javascript world, i.e. the consistency of the implementation of the Javascript and HTML DOM APIs. Thankfully since about 2005, much of this pain has been encapsulated into jQuery.

So what about XAML? What can we do about it? This is where XamQuery would come in. Here’s a highlight of the core features I see and where I have needed them:

  • A XAML DOM selector engine similar to Sizzle. Given that XAML doesn’t have complex selector syntax like CSS this would essentially be a highly optimized tree walker for the VisualTree that would wrap the disjoint APIs in WPF / Silverlight for getting visual parents and children.

  • A set of fluent APIs for creating XAML DOM objects (Panels, Controls, etc) that would wrap some annoying inconsistencies when travelling between Silverlight and WPF as well as making it easier to do things in code that are painfully verbose in pure XAML (I think states of the VSM is a great example of this).

  • A simple plug-in system for System.Interactivity Attached Behaviors to attach into. This would mirror the jQuery plugin system where each selector statement actually returns the jQuery object which you can then call plugins on.

Feel free to contact me directly about this idea. I’m looking to get some like minded developers together to work on this. I think that this could be the thing that takes WPF and Silverlight development to the next level.


  • Posted by Charlie Robbins

Parsing JSON into dynamic objects using MGrammar and C# 4.0  

Thursday, February 11 2010

I gave a talk last week at the New Jersey .NET User Meetup Group on designing textual DSLs using MGrammar. You can download the slides here: Textual DSLs with MGrammar. The code portion of the project was focused around developing a JSON parser into dynamic objects in C# 4.0. JSON has become an increasingly popular data format over the last several years for it’s flexibility and simplicity. The entire JSON specification can be summarized in just five words: objects, arrays, values, numbers, and strings. Each of these diagrams has a clear representation in MGrammar shown below:

Objects

json-object


syntax Object 
  = ObjectStart first:KeyValuePair rest:ObjectPart* ObjectEnd => Object { Pairs { first, valuesof(rest) } };

syntax ObjectPart
  = Comma pair:KeyValuePair => pair;

syntax KeyValuePair
  = key:String Colin value:Value => Pair { Key { key }, Value { value } };  

Arrays

json-array


syntax Array
  = ArrayStart first:Value rest:ArrayPart* ArrayEnd => Array [ first, valuesof(rest) ];

syntax ArrayPart
  = Comma value:Value => value;  

Values

json-value


syntax Value 
  = string:String => string
  | number:Number => Number { number }
  | object:Object => object
  | array:Array => array
  | primitive:Primitive => Primitive { primitive };

Numbers

json-number


token Number = Minus? Digit+ ('.' Digit+)? Exponent?;
token Exponent = ("e" | "E") Sign? Digit+;
token Digit = "0" .. "9";
token Sign = Plus | Minus;
token Minus = "-";
token Plus = "+";    

Strings

json-string


syntax String = '"' text:(text:StringText | empty) '"' => String { valuesof(text) } ;
token StringText = !('\u0022')+;    

Inside the Parser

Much of the actual parsing is done using simple LINQ expressions. First through, you have to install Visual Studio 2010 and the SQL Modeling November 2009 CTP (formerly “Oslo”) and created a new “Oslo Library.” This is important because it sets up all the M and MGrammar dependencies for you.

After you’ve created your Oslo Library, you must add your *.mg file and set the build action to “MCompile.” This will use the M tools to compile the *.mg file into a *.mx image. After that’s completed we can create our parser at runtime:


MImage grammar = new MImage(@"jsonm.mx");
grammarParser = grammar.ParserFactories["jsonm.jsonm"].Create();
grammarParser.GraphBuilder = new NodeGraphBuilder();

Now that we have our parser we can use that to parse the raw text into MGraph:


var inputText = new StringTextStream(sourceText);
var errorReporter = new ParserErrorReporter();
Node rootNode = (Node)grammarParser.Parse(inputText, errorReporter);
JsonmObject obj = ParseObject(rootNode);
return obj;

The rest of the process uses a series of LINQ expressions using some extension methods (included with the project). Here’s an example of how objects are parsed:

private static JsonmObject ParseObject(Node objectNode) { JsonmObject jsonmObject = new JsonmObject();

List<Tuple<string, object>> keyValuePairs = objectNode
    .Edges.FindNodeWithBrand("Pairs")
    .Edges.FindNodesWithBrand("Pair")
    .Select(node => ParseKeyValuePair(node))
    .ToList();

foreach (Tuple<string, object> pair in keyValuePairs)
{
    jsonmObject.TrySetMember(
        new DynamicDictionaryMemberBinder(pair.Item1, false),
        pair.Item2);
}

return jsonmObject;
}

You can see in the above example that in addition to parsing the MGraph, it sets members on our dynamic dictionary. This is how we can parse some sample JSON like this:


{
    "Object" : 
    {
        "String" : "StringValue",
        "Number" : -1.4e1,
        "null"   : null,
        "true"   : true,
        "false"  : false
    },
    "Array"  : [ "StringValue", 42, false, true, null ],
    "String" : "StringValue",
    "Empty"  : "",
    "Number" : -1.4e1,
    "null"   : null,
    "true"   : true,
    "false"  : false
}

Into a dynamic object using our parser like so:


dynamic result = JsonmParser.Parse(new Uri(Environment.CurrentDirectory + @"\sample.json"));
Console.Out.WriteLine(result.Object,String); // ==> "StringValue"

As always this code is on GitHub. I look forward to see more parsers in MGrammar in the future, send any MGrammar hacks my way in email or comments!


  • Posted by Charlie Robbins

Capturing Raw Images from the Microsoft Surface  

Friday, January 22 2010

Surface Multi-touch

As I mentioned in a previous post the Microsoft Surface implements multi-touch using infrared computer vision as opposed to a capacitive approach. This is interesting for a couple of reasons. First it allows the Surface to recognize a very large number of touches. Second, it allows ambitious developers to tap directly into this infrared image data to perform more complex operations (like shape recognition). Getting at this information however is not entirely straight forward though. To simply things I created an attached behavior.

Attached Behaviors

Attached behaviors are something that I’ve blogged about before. They are a very convenient way to add user interface behavior to controls without having to implement a proper subclass. This behavior also implements a custom attached event, which allows you to easily handle and process images captured from the Surface.

Using the Behavior

Using the behavior is simple; you just have to include the library in your solution, add the xmlns and set a couple of attached properties and an event handler:


<s:SurfaceWindow
  behaviors:SurfaceWindowRawImageCapture.IsEnabled="True"
  behaviors:SurfaceWindowRawImageCapture.RawImageCaptured="YourEventHandler">
  (...)
</s:SurfaceWindow>

Optional Parameters

This behavior is designed to be flexible. There are several parameters that allow you to take advantage of this flexibility.

UseExplicitCapture=(true | false)

Setting this property to true will disable the attached event from being raised. It is false by default. Use it if you want to capture images programmatically which is explained below.

SaveTo=”C:\path\to\captured\images

Often it may be necessary to save the images that you capture to a specific location. If you set this property all images captured by the behavior will be saved to the specified directory.

Capturing Images Programmatically

The one drawback to the way that the Surface SDK allows developers to capture raw images is that the ContactDown event must be handled on the instance of the SurfaceWindow itself. What that means is that your attached event handler has to also be on the SurfaceWindow itself. The solution to this limitation is to call the behavior programmatically from your own code:


SurfaceWindowRawImageCapture.CaptureRawImageAsync(
    Application.Current.MainWindow as SurfaceWindow,
    new Rect(100, 100, 100, 100),
    result =>
    {
        // Code to execute when the result has been captured
    });

The Rect that is passed to the method defines an area to crop the entire Surface image. This is useful if you are only interested in a small sub-area of the total Surface. The callback that is passed to the method will be executed after the image has been captured.

Let me know if you run into any issues with the behavior by emailing me: charlie [you know] robbins [obviously] gmail [you know] com. As always, all of this code is available under the MIT license on GitHub.


  • Posted by Charlie Robbins
Subscribe Here