OdeToCode IC Logo

Language Quiz

Tuesday, September 27, 2005 by scott

What language is the following code snippet using?

var person = new


    Name = "Steve",

    JobTitle = "National Assurance Orchestrator"


A) JavaScript
B) C# 3.0
C) COBOL.NET with WinFS extensions.
D) None of the above

For hints, see Steve Maine’s excellent post “On JSON” (JavaScript Object Notation), and Abhinaba’s informative rant “C# 3.0: I do not like Anonymous types”.

The Weeks Ahead

Monday, September 26, 2005 by scott

This week is Microsoft's MVP Summit in Seattle. I’m looking forward to seeing the city of Seattle, home of the National UFO Reporting Center. I hear Microsoft has a branch office or something nearby, too. I'm also looking forward to meeting many people I only know electronically, and cornering members of the MSBuild team. I want information, and not about aliens.

In the middle of October, I’ll be speaking at VSLive! 2005, in Orlando, Florida. The topic will be debugging with Visual Studio 2005, and I’m in the midst of preparing a pretty cool demo, complete with bugs. It’s not often that you want to start off a presentation with an exception.

The .NET Rocks! Road Show is making a couple stops in my neighborhood (Baltimore on October 18th, and D.C. on October 19th).

At the end of October is the Mid-Atlantic Security Code Camp. If you are anywhere near Reston, Virginia during the last weekend in October, you should stop in. The line-up of talks should be available soon.

This concludes post #300. Past performance is no guarantee of future results.

Ted’s C# 3.0 Overview

Thursday, September 22, 2005 by scott

Ted Neward has a great post analyzing new C# 3.0 features.

Ted refers to the language enhancements as mostly “syntactic sugar”. In other words - the syntax additions don’t change the expressiveness of C#, but merely add conveniences and shortcuts. We write less code while the C# compiler generates more IL behind the scenes.

Over the years I’ve been puzzled by the term ‘syntactic sugar’. People generally use the term in a derogatory sense, as in: “C++? Pffft. That’s just C with some syntactic sugar”.

Isn’t every language just syntactic sugar when compared to, say, CPU opcodes?

Notes From the Atlas Hands On Lab

Wednesday, September 21, 2005 by scott

Rough and random thoughts while playing with the new Atlas bits.

Lab 1

Lab 1 creates a master page with <atlas:script> tags to ensure links to the Atlas framework .js files are sent to the client. I’d like to see this functionality in a base class so it isn’t copy and pasted everywhere, or simply injected auto-magically, perhaps when an attribute like <% @ Page AtlasEnabled=”true” %> appears.

Nifty master page tricks: the master page uses a ContentPlaceHolder inside the %lt;head%gt; tag, which makes it easy for content pages to override the contents of head. The master page does not define a %lt;form> tag, but leaves the content pages to define the tag (typically with action=”” since there are no postbacks involved).

Glitch: the setup puts a default.master and a default.aspx in the same directory, which can produce duplicate definitions for _default in the codegen directory. The errors appear in temporary files with scary names, and the errors come and go depending on how many files compile. It’s scenarios like this that make the system appear broken and one reason why people hate the project-less web project.

Cool: you can generate JavaScript proxies for a web service by browsing to the asmx file and appending /js (why not ?js to be consistent with ?wsdl?). Assuming you wire up a button’s onclick event, you can pull back and process results with relatively simple code. Lab 1 passes the contents of a textbox to a HelloWorld type service, which essentially echoes the input back with a timestamp.

function DoSearch()


  var SrchElem = document.getElementById("SearchKey");


      SrchElem.value, OnRequestComplete




function OnRequestComplete(result)


  var RsltElem = document.getElementById("Results");

  RsltElem.innerHTML = result;


Lab 2

Lab 2 performs the same work as Lab 1, but with a declarative syntax. Instead of writing JavaScript you write a mess of declarative XML that only a machine can love. Excerpt:






    <binding dataContext="SearchKey" dataPath="text"

            property="parameters" propertyKey="query" />



      <invokeMethod target="resultsBinding" method="evaluateIn" />



Weep: Lab 2 didn’t work for me immediately and I had to stare at the XML and compare the above to what was in the sample. Not knowing what else to do I started stepping through the Atlas JavaScript. I was deep inside a JSON.serialize method when I realized it was building a payload like “query:foo”, where “foo” was the value I typed into the textbox and “query” was the name of the web service parameter – except I had named my parameter on the C# method differently.

I hope that none of the XML cruft will have to be hand written. I hope there will be some way to keep the XML and web method in sync, or decoupled. Lab 1 worked because the JavaScript proxy was custom generated from the code– I hope something along those lines will be available for the declarative service method bindings.

Lab 3

Lab 3 added auto-completion to the textbox control, which I found rather appealing in a scary way. When typing into the textbox the JavaScript will invoke a web service method and bring back a list of possible matches to display in a DHTML control.

Unfortunately, this lab started throwing a JavaScript exception, so once more I tried to step through the optimized-for-transport-no-whitespace JavaScript of the framework. I thought my head was going to explode. I gave up and posted on the asp.net forums, and  found that changing:

<div id="completionList" />


<div id="completionList"></div>

made everything work.


Lab 4

Lab 4 implements the same auto-completion textbox as Lab 3, but with a server side Atlas control instead of client side gunk.








Lab 5

Lab 5 uses Atlas server-side controls to call a web method and populate a templated listview control. The word “bindings” appears a lot. Excerpt:

<atlas:Button runat="server" ID="fillButton" Text="Get URL List">





        method="select" />




The declarative syntax feels passive and the terminology is vague, but I suppose that is the nature of the beast and something I have to get over.

This concludes my notes from the Atlas hands on exercises. I’m certain you have not enjoyed them half as much as I have enjoyed typing them in.


Tuesday, September 20, 2005 by scott

Concurrency is terribly difficult. Example: a primary cause of the massive North American blackout in 2003 was a software race condition. The application logged over three million production hours before the bug manifested itself.

Nevertheless, concurrency, here we come. Herb Sutter points out why with his article: “The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software”.

Mr. Sutter explains how future CPU improvements will no longer give applications a free performance boost - clock speed and execution optimizations are topping out. We need to increase the concurrency of our applications to take advantage of the next wave of CPU improvements (multiple cores).

Like Jeff Atwood, I don’t think concurrency is an area the typical application developer is ever going to deal with. Instead, the revolution will happen in the runtimes, the platforms, and the languages we use.

ASP.NET developers already use a runtime to write applications that process requests in parallel. Even a simple console mode program in the CLR has work happening concurrently. On the platform side, T-SQL developers have parallelism readily available with SQL Server’s Service Broker on the horizon.

While the platforms and runtimes are moving ahead, I’m not sure what is happening with languages. When Comega first appeared I thought the next version of C# would be taking a turn towards new concurrency abstractions, but I see no mention of these in the C# 3.0 specification.

As far as languages go, perhaps the LINQ / DLinq / XLinq features are enough to chew on and iron out first.

Developer Toolbar For IE

Sunday, September 18, 2005 by scott

The beta version of the IE Developer Toolbar is now available. The toolbar allows you to inspect the DOM, view class names and IDs, clear the browser cache, validate the markup, and more.

Other than a minor annoyance (the installation required a reboot), the toolbar looks great and works well. If you’ve ever used FireFox’s web developer extension you’ll know just how invaluable this tool can be.

The IEDevToolbar.dll the setup package deploys doesn’t appear to use managed code, though. Bummer.

SiteMapProvider using SQL Server

Saturday, September 17, 2005 by scott
If you are looking to build a custom ASP.NET 2.0 SiteMapProvider to read site navigation information from SQL Server, then look to Jeff Prosise’s “Wicked Code” column in the June 2005 issue of MSDN Magazine.