Feed Subscribe
Exception has been thrown by the target of an invocation.


On efficiency loss with JavaScript

by ondrejsv 15. September 2011 22:34

With the hype of Windows 8 HTML5/JS apps I’m again and again rediscovering some of the pitfalls of the JavaScript language which bring issues we never have with strongly-typed languages like C#.

The first scenario is going to be quite common not only when using the new promise/then feature. (Snippet is taken from one the tutorials on the MSDN.) Look at the processPosts function that gets called when the xhr promise gets asynchronously fulfilled. There is no way the IDE would know the type (more precisely available methods and fields) of the argument and thus providing IntelliSense because the function could be called from everywhere:

image

If we write the code to run when the promise is fulfilled as an anonymous function and Visual Studio would be way smarter, it could theoretically provide IntelliSense on the result argument by parsing and processing the xhr promise but it does not so:

image

The second pitfall comes from the fact that any code could be run in a context of any HTML file. When you reference a .js file from an HTML page, some of the global variables get alive by getting references of the screen elements with variables of the same id. If you make a typo in the name of a variable, you would not find it out until you run the page. Of course, there is no IntelliSense either because the variable could be of any dynamic type at run-time. This pitfall is really a feature of all dynamic languages but for a programmer used to program user interfaces in ASP.NET and Silverlight which have concepts of code-behind coded in strongly-typed C# it represents a loss in efficiency, indeed.

image

image

Tags:

Some observations on managed Windows 8 metro applications

by ondrejsv 15. September 2011 20:20

This is an unstructured list of interesting things I found when playing with the new metro applications.

While HTML5/JS metro applications always run in a host process WWAHost.exe (Windows Web Application Host?), .NET apps does not, they run directly in its own process:

image

image

When deployed locally from the Visual Studio, applications (both HTML5/JS and .NET) are stored within the folder AppxLayouts in the user folder. It is interesting that XAML and content files are not embedded as resources in the executable but they are left alone:

image

As the WinRT is native, every external event such as Click comes from the blackbox:

image

If we look at modules currently loaded when a managed application is running:

image

we’ll find some interesting things:

  • despite the fact that in a Metro app you may use only a subset of the full .NET, it looks like some of the full .NET modules are loaded (mscorlib.dll, System.Runtime.dll, System.Linq.dll, System.Core.dll, System.dll, System.Xml.dll and others), so a managed application obviously does not only forward calls to the native WinRT,
  • of course, a number of WinRT modules are loaded (with .winmd extensions)

.NET 4.5 assembly references are evident if we look at the application from the Reflector:

image

Tags:

List of Windows 8 Metro applications in DevPreview

by ondrejsv 14. September 2011 23:13

We all know that that there are two main approaches to develop new “Metro” style applications in Windows 8: HTML5/JavaScript and .NET (predominantly C# and VB.NET) and one complementary approach (C++/XAML). What technologies did Microsoft choose to write demo applications coming in the Developer Preview?

Here’s a short list containing all applications packed up in the Windows 8 Developer Preview together with technologies they are build on and other comments.

So what would be a management summary? 29 applications, 5 of which are written in .NET/XAML, 2 probably in C++/XAML and the rest are HTML5/JS.

Name Technology Comment Immersive tile
Alarms HTML5/JS   image
Piano (audiotagpiano) HTML5/JS   image
BitBox HTML5/JS sound loops sequencer image
BUILD HTML5/JS just a little app showing BUILD sessions image
Copper C++/XAML ??? simple 3D demo image
Five in row HTML5/JS   image
Flashcards HTML5/JS   image
News (hermes) HTML5/JS   image
Chess (checkm8) .NET/XAML   image
Ink Pad HTML5/JS   image
Labyrinth HTML5/JS   image
Measure It HTML5/JS   image
Memories .NET/XAML   image
Mopod HTML5/JS   image
Air Craft (myplane) HTML5/JS   image
Near Me HTML5/JS   image
Notespace HTML5/JS   image
PaintPlay HTML5/JS   image
Picture Stream (picstream) .NET/XAML    
Socialite HTML5/JS    
Stock HTML5/JS   image
Sudoku .NET/XAML includes Tim Heuer’s code image
Tile Puzzle HTML5/JS   image
Treehouse Stampede! HTML5/JS   image
Tube Rider C++/XAML ???   image
Tweet@rama HTML5/JS    
Weather HTML5/JS   image
Word Hunt HTML5/JS   image
Zero Gravity .NET/XAML Ported Windows Phone 7 application image

Tags: