November 2012 - Posts
The SDP started last Sunday in the shadow of rockets fired on Israel and an alarm and evacuation around 10:30AM. Nonetheless, attendance was almost full and all sessions were delivered as planned. We had three tracks with a total of 18 talks, and mine was concerned with running Node apps on Windows Azure.
This was a similar -- although not identical -- talk to what I did at the Israeli Windows Azure User Group last month. You can find the slides and demos here, but you will have to substitute your account names and keys if you want to run the demos on your machine or upload them to Windows Azure. The talk was recorded, as were all other talks; if you attended the conference you will get an email with details on how to access the recorded talks from all three tracks.
Here's a nice screenshot of some of the messages attendees wrote in my interactive bulletin board demo:
Some of the things we covered:
- Introduction to Node.js, HTTP client, express, nstore
- Windows Azure Portal and the command line 'azure' tool
- Uploading a simple Node app to Windows Azure Web Sites using git integration
- Accessing Azure Table Storage from a Node app
- Using a SQL Azure database from an on-premises Node app
- Connecting a Windows Azure Mobile Service and Windows Store app to the same SQL Azure database
- Using Node with MongoDB in an Ubuntu VM running on Windows Azure
- Using WebMatrix to download and modify a web site from Windows Azure
Thanks for attending, and stay tuned for more updates about next year's SDP. You can save the date already: it will be May 5-9, 2013!
I am posting short links and updates on Twitter as well as on this blog. You can follow me: @goldshtn
The last two talks I went to at BUILD… Spending all my time preparing for the Windows Azure Conference next week, where I have two sessions: one on Node.js and one on Windows Azure Mobile Services.
Herb Sutter – The Future of C++
Herb has been giving this talk for a few years in a row now at major conferences, and there’s something new every time – this really tells you a lot about the excitement in the world of C++ during these years, culminating with last year’s standard, C++11.
Herb shared the plans for an out-of-band Visual Studio update to the C++ compiler, of which a CTP is now available. This update brings the compiler up to par with almost every important C++11 feature, including:
- Variadic templates – definitely my favorite, and the subject of a talk I gave at the SELA C++ Conference in June
Shameless plug – my talk from June :-)
vector<int> v = { 2, 3, 4 };
- Explicit conversion operators
- Raw string literals
- Default template parameters for function templates
template <typename T, typename U = int>
T* make_array(U size) …
Herb also talked a lot about the C++ ISO working group (WG21), which has now been split into numerous study groups (SGs) focusing on exciting subjects including reflection, transactional memory, filesystem APIs, networking, and more.
By Herb’s estimates, we should see a minor standard as early as 2014, with generic lambdas, runtime sized arrays, static-if, thread safe containers, and more… Next, in 2017 we should expect the next large revision to the standard, with primarily standard library additions and changes emanating from the study group work over the next couple of years.
At the end of talk, Herb announced the isocpp.org website, which is designed to be a hub for C++ developers online, and the Standard C++ Foundation, a non-profit organization for improvement of C++ understanding and use.
When all’s said and done, I suggest you keep honing your C++ skills (I have), not for lack of other languages but for the sheer power and elegance of some C++ features, for performance, for easier use of intrinsics and other hardware quirks, and – needless to say – for portability.
Scott Hanselman and Jon Galloway – Bleeding Edge ASP.NET
Frankly, I was pretty exhausted at this point in the day, and coming up with a flu that chased me all the way back to Israel. Jon and Scott pulled a great talk, focusing on the ASP.NET Fall 2012 Update as well as some even newer features. Most of the talk was a huge demo (or set of demos), focusing on:
- Facebook application template for Visual Studio (not just authentication support) + Facebook C# SDK NuGet package
- SPA template
- Mobile application template
- Scaffolding prototype which generates a master page, mobile master page, EF data context, and whatnot
- Web Essentials prototype extension for TypeScript with source maps that allow debugging of TypeScript code, displaying the generated JavaScript code in a tooltip
This funny talk was a great way to round up the conference. Looking forward to next year’s BUILD!
I am posting short updates and links on Twitter as well as on this blog. You can follow me: @goldshtn
I had barely time to blink, and BUILD is almost behind us. The fourth day was shorter than the rest, but there was one session that made my morning and my day:
Subramanian Ramaswamy – Deep Dive into the Kernel of the .NET Framework on Windows Phone 8
This long title was well-justified, as the .NET Framework on Windows Phone has been revamped as dramatically as the underlying Windows CE –> Windows NT kernel drop-in. This talk was divided into two parts – one about the productivity enhancements for .NET developers on Windows Phone, including easier interoperabiliy with unmanaged code through WinRT components, easier code sharing between platforms with Portable Code Libraries, and async support from C# 5.0. But that’s not what I came for :-)
The second part of the talk focused on CLR internals, and how they were used to improve the startup and execution performance of managed Windows Phone apps. The .NET Framework on Windows Phone 8 is built on top of the CoreCLR, which is the same CLR powering Silverlight applications. Along with CoreCLR, the team has made performance improvements including “compiling in the cloud” to an intermediate device-specific language called MDIL, better optimizations in the native image generation, and introduction of the CoreCLR garbage collector, which is generational and has multicore allocation support.
The “compile in the cloud” initiative involves taking the IL code generated by the C# compiler on the developer’s machine and compiling it with an aggressive optimizing compiler to a device-specific language – MDIL. MDIL files consist almost entirely of ARM assembly instructions, with the exception of specific placeholders that are compiled to ARM assembly only when the app is installed.
To understand the rationale behind MDIL, consider the two current alternatives: JIT and NGEN. Windows Phone 7.5 apps use JIT, which means IL code must be compiled to ARM instructions during startup and runtime. The set of optimizations performed by the JIT is also very limited because of time and resource constraints. Desktop and server apps can use NGEN, which compiles IL code to native assembly instructions (typically during application installation), which improves startup but requires full recompilation when updates to the .NET Framework are applied. In other words, if Windows Phone 8 apps used NGEN, the first compilation could have occurred entirely in the cloud, but any subsequent .NET Framework updates would require a costly recompilation process to be performed on the user’s device. Considering the constrained hardware and power available, recompiling all apps could take hours and noticeably hinder the user experience.
With that said, how does MDIL address this problem? MDIL files contain placeholders, compiled to native instructions only at installation time and recompiled again whenever framework updates are installed. Such placeholders are required whenever your app’s code accesses types from other assemblies (such as the .NET Framework assemblies). For example, when invoking a method, accessing a field, or any other operation that is dependent on object layout, instead of generating the actual ARM assembly instructions, the IL –> MDIL compiler generates a placeholder, logically resembling the following:
; load field ‘n’ from object ref r0
ldr r3, [r0 + “fieldoffset(n)”]
; call method ‘foo’ of object ref r0
add r1, r0, “methodoffset(foo”)
blx r1
Because the placeholders are the exception and not the rule, this compilation process is not as costly and will provide a great user experience. The only thing that needs to be updated when the app is installed or when framework updates are applied are the external placeholders.
Towards the end of the talk, Mani mentioned the CoreCLR garbage collector, which is a weakened version of the workstation GC on desktop CLR. Namely, the collector is generational and allows multiple allocations to proceed at once from multiple cores (I assume with a form of multiple heaps – this needs further investigation). Additionally, the object tracking for roots is less conservative than in the Compact Framework GC – for example, in the following method, the XML document will be collected after the GC.Collect call:
var doc = new XMLDocument();
doc.Load(…);
Console.WriteLine(doc.OuterXml);
GC.Collect();
Console.ReadLine();
All in all, the CoreCLR on Windows Phone offers an exciting perspective on inventiveness and creativity when optimizing for ARM and for less powerful devices.
Clearly, there are some followup questions still waiting for answers. How do you inspect MDIL to determine what the optimizer is doing? Is MDIL coming to the desktop and server as well? Is there still room for JIT optimizations at runtime, such as hot-patching interface dispatch stubs? I hope to find the time to explore this further in the coming weeks :-)
I am posting short updates and links on Twitter as well as on this blog. You can follow me: @goldshtn
No keynote today, but Scott Hanselman’s 8:30AM talk was a great replacement – he himself called it an “unkeynote”. Also, before the talk Scott looped some hilarious videos, such as MacBook Wheel from The Onion.
Scott Hanselman – One ASP.NET and the Cloud
This was really keynote material in that Scott highlighted some of the recent developments in what the cloud means for developers. He started by showing the Azure PowerShell cmdlets, which give you provisioning of websites or virtual machines by virtue of a few keystrokes. These are the “five computers” somewhere in the world – Azure, Amazon, and other cloud providers – which provide infinite compute capacity at your fingertips.

The next point Scott made is that the browser itself is a virtual machine – running JavaScript – which provides a plugin-less experience for very complex software: Commodore 64 and x86 emulators being a notable example of how the browser becomes a virtual machine.
Screenshot of the JSLinux effort, which runs a Linux system on top of an x86 emulator implemented entirely in JavaScript.
Instead of treating browsers like dumb terminals that wait for HTML to pour down from a powerful server, we can leverage the power of the user’s multiprocessor device with hardware-accelerated graphics if we run code inside the browser’s virtual machine. Some pretty cool demos with the D3 visualization and graphics library really drove the point home.
Scott couldn’t not mention the VanillaJS effort, which you should definitely check out. This is a 0 bytes download, giving you exceptional performance and a slew of great features ;-)
Some notable quotes from the talk:
“Furiously Googling with Bing”
“JavaScript is the assembly language of the web”
“JavaScript is an operating system”
Anders Hejlsberg – TypeScript
This talk was very educational although I already had a chance to fool around with TypeScript a little bit. The big problem TypeScript is designed to address is that of developing large-scale JavaScript applications. With the lack of modules, classes, clean inheritance and strong static typing, JavaScript makes large-scale development exceptionally hard, and tools can’t help with auto-completion, refactoring, compile-time errors and other goodies.

Unlike other efforts (such as Google’s Dart), TypeScript starts from pure JavaScript and adds support for arrow functions (lambdas), static typing, interfaces, classes, and modules. The whole thing is compiled down to readable JavaScript code that you can debug and inspect using the standard developer tools in any browser.
TypeScript source:
class Player {
constructor(public name: string, public id: number = 0) {
}
play(game: string) {
document.write(this.name + " is playing " + game);
}
}
var p = new Player("Sasha");
p.play("Diablo");
JavaScript produced by the TypeScript compiler:
var Player = (function () {
function Player(name, id) {
if (typeof id === "undefined") { id = 0; }
this.name = name;
this.id = id;
}
Player.prototype.play = function (game) {
document.write(this.name + " is playing " + game);
};
return Player;
})();
var p = new Player("Sasha");
p.play("Diablo");
With this static typing comes the power of the tools – in-browser playground or Visual Studio, you get auto-completion, error squigglies at compile-time, and refactoring support letting you keep your sanity when working on large JavaScript code bases (to quote: “at some point, JavaScript turns into write-only code”). Anders drove this point home by demonstrating a refactoring of the TypeScript compiler, which is itself written in TypeScript!
Anders then showed a bunch of TypeScript features, including classes, modules, interfaces, type inference, optional properties, accessor functions, static methods, default parameter values, inheritance, and many others. This is really not the same JavaScript you learned to hate!
import connect = module('connect');
import express = module('express');
var app = express.createServer();
app.get('/echo/:message', (req, res) => {
res.end('Your message: ' + req.params.message);
});
var port = process.env.port || 8080;
app.listen(port);
Using modules and arrow functions in Node Finally, you don’t have to write TypeScript declarations for standard libraries. The TypeScript installation ships with type declarations for libraries like jQuery and jQuery UI, whereas WinRT type declarations are automatically generated from WinMD files.
If you haven’t tried TypeScript yet, there’s nothing to download to get started: head on to www.typescriptlang.org and start fooling around in the online playground.
Nathan Totten – JavaScript from Client to Cloud
This was a Node talk, and I didn’t expect to learn anything new but mostly to see how Microsoft perceives Node and its accompanying Azure support. Nathan provided a quick overview of Node, the single-threaded event loop model, and discussed some scenarios in which to use Node, such as lightweight server-side applications and web services. Perhaps more importantly, Nathan discussed when to not use Node – for CRUD solutions over data (Rails or ASP.NET are better), and for CPU-bound processing (because of the single-threaded model). To conclude the overview part of the talk, Nathan mentioned iisnode, which is what the Azure Web Sites infrastructure uses to host Node.js apps on Azure. iisnode can scale node.exe processors to multicore machines, and now has also WebSockets support with Windows Server 2012.
Then, Nathan turned to the demo. In the demo, he started with a local website that uses socket.io for WebSockets, mentioned some developer tools like node-supervisor and node-inspector, and then uploaded the Node app to Azure and developed a simple Windows 8 JavaScript app connected to the same server. At the very end of the talk, he even managed to squeeze in a quick demo of the azure Node module, which he used to access Azure Storage from the on-premises Node app.
All in all, this has been a nice overview of Node and Windows Azure in just sixty minutes. I will definitely be applying some lessons from this talk to my own presentations ;-)
I am posting short updates and links on Twitter as well as on this blog. You can follow me: @goldshtn
Satya Nadella and others – Day 2 Keynote
Day two started with Satya Nadella orchestrating an amazing keynote with Scott Guthrie, Scott Hanselman, Josh Twist, Jason Zander, and David Campbell. This amazing lineup of speakers showed multiple demos, including live coding, covering the most recent developments – mostly around the Windows Azure Platform.
Satya’s point of view on the current state of Windows Azure is that it is a complementary offering to Windows 8 and Windows Phone 8, in that it provides a great backend for mobile apps. This great backend is not just words – it’s Windows Azure Mobile Services, announced just a few weeks ago and progressing at an incredible rate. (I have taken a great interest in WAMS, and even managed to squeeze it into my Node.js talk at the local Azure UG last week.)
For example, here’s what you need to do to authenticate a user using Facebook – yes, seriously:
var user = await MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook);
Josh Twist from the WAMS team announced support for Windows Phone 8 – alongside the existing support for Windows 8 and iOS. I bet Android support is coming as well, which will make WAMS an ideal backend offering for your mobile apps on every platform. In his demo, Josh showed how easy it is to integrate data tables in your mobile app, to send push notifications from server-side scripts between devices, and how to perform user authentication using identity providers such as Twitter and Facebook.
Alongside with that great backend, Windows Azure powers more than 200 Microsoft services, including Bing, Office 365, and Xbox LIVE. Scott Hanselman hopped to the stage to build an ASP.NET web site with third party identity providers and a Web API service, and continued to use it from a Windows 8 app.

At this point Satya said that Windows Azure “takes the grudge out of building cloud-scale services”. Indeed, Scott Guthrie demonstrated how Windows Azure Media Services – which you can try online without downloading the SDK – streamline the process of uploading, encoding, publishing, and streaming media to a huge variety of devices. Scott also demoed SignalR and announced the Windows Azure Store with third-party add-ons, including New Relic’s free monitoring and analytics offer for all existing Windows Azure customers.
Towards the end of the keynote, Jason Zander announced that the Team Foundation Service is coming out of preview and is available for free to teams of up to five people. This is great news for small teams looking to bootstrap their source control and continuous delivery environment.
Finally, Dave Campbell announced HDInsight (Hadoop on Windows Azure) and showed the JavaScript library and .NET SDK for MapReduce. As someone who had some experience with the Java SDK for Hadoop, I can tell you that the .NET SDK looks stellar in comparison.
Don McBrady, Jim Radigan – It’s All About Performance: Using Visual C++ 2012 to Make the Best Use of Your Hardware
This was one long title, but a very interesting and informative session for C++ developers. The room was almost full; Jim and Don quickly went through the concepts of superscalar execution and vectorization in modern processors, and explained how the C++ compiler in Visual Studio 2012 determines which loops are safe to vectorize and emits parallelized and vectorized loops when possible.
This is the kind of hints you can give the compiler to automatically vectorize and parallelize your loops – and there’s a math library optimized for vector operations at your disposal:
#pragma loop(hint_parallel(4))
for (int i = 0; i < _countof(arr); ++i)
{
double s = sin(arr[i]);
double c = cos(arr[i]);
arr[i] = sqrt(s*s + c*c);
}
Many more parallelization and vectorization opportunities are available, and Visual Studio 2012 is just a first glimpse at what’s possible. Because the same compiler is used to build Windows, Office, and SQL Server, the compiler team has to be very conservative and cautious with optimization opportunities – so some things simply didn’t make it into the first release. I will definitely watch the space of further optimization improvements in the Microsoft compiler.
I covered some of these topics in the past on my blog [SIMD, auto-parallelization], and some tips on vectorization, instruction-level parallelism, and even C++ AMP have made it to Chapters 6 and 10 of Pro .NET Performance. If you’re more of a .NET guy, it might be easier to digest than this C++-oriented talk :-)
Towards the end of the talk, Don demonstrated C++ AMP with a live “cartoonizer” demo, in which the performance was improved by two orders of magnitude as a result of offloading CPU-bound image-processing code to the GPU. This and other impressive demos are something you can do today: just pick up C++ AMP by Kate Gregory and Ade Miller, and start getting your feet wet with C++ AMP.
Josh Twist – Azure Mobile Services
Josh, a Senior Program Manager on the Mobile Services team, introduced the capabilities of Mobile Services using a long demo in which he built a voting app for categorized events. In just under 50 minutes, he was able to cram the service creation, data tables, authentication using multiple providers, push notifications for both Windows 8 and Windows Phone 8, and most importantly: server-side code with insert and read scripts.
Brandon Bray – Evolution of .NET
In this historical perspective talk, Brandon recalled the design goal of the .NET framework – having developers fall into the pit of success. Indeed, .NET has increased its platform reach (with the embarrassing exception of Silverlight’s untimely demise), and maintained a consistent API surface that you can use across Xbox, Windows Phone, Windows 8, and desktop apps.
Brandon showed some funny videos and PDC slides from the last decade, including Bill Gates elaborating on how every application will become a website and how it will become increasingly important to sync and transition experiences between multiple devices. It’s interesting to see how these trends are even more relevant today, as the line between apps and websites is becoming even more blurry.
At the end of the talk, Brandon discussed some of the performance improvements in the recent CLR versions, including background server GC, multicore JIT, and automatic NGEN. He also briefly mentioned the CoreCLR’s resurrection in Windows Phone 8, where it powers the next generation of Windows Phone applications. Compile in the Cloud, the subject of a talk I plan to attend on Friday, brings machine-dependent IL to the phone, which is much faster to JIT and has a much smaller footprint, resulting in better performance due to better optimization and faster startup times.
Finally, Brandon mentioned the improvements in Compact Framework 3.9, coming to Windows Embedded Compact 2013 that targets less powerful devices, with 256MB of RAM or less – generational GC, code sharing server (like in WP7), and improved code quality for ARM processors.
I am posting short updates and links on Twitter as well as on this blog. You can follow me: @goldshtn