Visual Studio Async CTP: A Few More Things

October 28, 2010

I gave a couple of examples in my previous post which demonstrate, IMHO, how async methods can simplify existing approaches to asynchrony in C# programs. Both examples were fairly simple in that they didn’t involve cancellation, progress reporting, UI thread dispatching, or exception handling. I’m happy to report that accomplishing these objectives is as easy as doing nothing else than what we’ve already seen. This is a result of a fairly sophisticated C# rewriting process that the compiler applies to async methods, not unlike the rewriting process applied to iterator blocks (“yield return” and “yield break”). For...
no comments

Visual Studio Async CTP: The C# Perspective

During today’s PDC session on the future of C# and VB, Anders Hejlsberg announced the availability of the Visual Studio Async CTP, implementing a set of changes to the C# language that support a new pattern for asynchronous programming. There’s lots to be said about the language support and the framework implementation that enables it, and the CTP is not the final words that will be said. There’s a comprehensive set of samples you can find at the MSDN Code Gallery, and I strongly suggest that you download the CTP and run some of these samples today. ...
one comment

Writing a Compiler in C#: Parsing, Part 1

October 17, 2010

In the previous installment we saw the core of a lexical analyzer, a module that generates from a stream of characters a set of tokens for symbols, identifiers, keywords, integer constants, and string constants. Today, we move to parsing. The parser’s job is to give semantic structure to the syntactic tokens bestowed upon it by the lexical analyzer. There are, as always, automatic tools like yacc that create from a BNF grammar a program that parses tokens in a certain language. However, it is often more efficient and certainly more educational to write a parser by hand. ...
no comments

All-In-One Code Framework Coding Standards

October 12, 2010

I recently stumbled upon the All-In-One Code Framework project on CodePlex. It’s a very impressive collection of samples in C#, VB.NET, and C++, and most of the samples I’ve seen are of superb quality. One thing that’s cool about this project is that they publish their own set of coding standards. It’s a very elaborate 87-page document written in the “Framework Design Guidelines style” with “DO” and “DO NOT” items sprinkled liberally throughout the guidelines. It’s relevant for C# and C++ developers alike. Anyway, here are some nuggets of wisdom I gathered from the document: ...
no comments

Writing a Compiler in C#: Lexical Analysis

October 6, 2010

I’m going to write a compiler for a simple language. The compiler will be written in C#, and will have multiple back ends. The first back end will compile the source code to C, and use cl.exe (the Visual C++ compiler) to produce an executable binary. But first, a minor digression. Over my blogging years, I developed this tendency of abandoning blog post series just prior to their final installment. I abandoned the unit testing series, the primality testing series, and many other “series”. Therefore, I’m not going to call this thing a “series”. I might...

The Case of the Wrong Window Owner

October 3, 2010

This post was inspired by a debugging war story Dima Zurbalev told me a couple of days ago. All the credit for finding the bug and describing the diagnostic process belongs to Dima. (This isn’t the first time—see Garbage Collection Thread Suspension Delay and Improving Cold Startup Performance for two additional examples of Dima’s work.) Anyway, the case in point is a WinForms application that stops responding (I reproduced this in a simple scenario, but originally the problem was obscured by additional details). After attaching WinDbg to the process and loading SOS, the managed thread inspection shows three...
no comments