Previous month:
June 2008
Next month:
November 2008

October 2008

PDC 2008 - XAML with .NET 4.0

from #pdc2008: XAML enhancements!
XAML nowadays is used with the UI (WPF, Silverlight), Workflows (WF), and Electronic Paper (XPS).
XPS is just going to be an ECMA standard!

With all these uses XAML is going into a language evolution. Goals of this is to make XAML faster and easier to use.

The XAML language extensions are defined by this list:

  • improved named references
  • support for built-in types
  • full generics support
  • support for arbitrary dictionary values
  • declarative events without compiling
  • declarative definition of types
  • arguments for non-default constructors
  • factory methods
The notepad for XAML, XAMLPad, has been enhanced. Besides the XML and object box it now gives a DOM box to display the DOM model. With the F12 key, a visual representation of the XAML type is shown.

For reading/writing/processing XAML, .NET 4.0 includes the System.Xaml.dll assembly. It contains XamlXmlReader, XamlXmlWriter, BamlReader, BamlWriter, DomReader, DomWriter, ObjectReader, ObjectWriter. Now it's easier to develop e.g. a SVG conversion. To convert from SVG to XAML, the SVGReader and XamlXmlWriter come into play. For creating objects on the fly out of SVG, SVGReader and ObjectWriter are used.
The System.Xaml assembly will be available here: http://go.microsoft.com/fwlink/?LinkId=132499

In the early days of XAML and WPF, simple applications have been shown that just need XAML code but no code-behind. Now it is possible to write an application that makes use of WPF, WF, and WCF purely using XAML.

Christian


PDC 2008 - Parallel Extensions to the .NET Framework

From #pdc2008, Parallel extensions to the .NET Framework are part of .NET 4.0!

The thread pool has been enhanced with great new features. The new features can be accessed from the Task API. The Task API can be used similar to the Thread class and offers some advanced features. For the tasks to queue up, the pool now not only includes a global queue but also a local queue for every thread in the pool. This can enhance performance because of data cached in the CPU.
With the new API, other than starting tasks some more features: tasks can be started in a parent/child relationship, it is possible to suspend/continue/wait/cancel tasks, and get results from the task (using the Future class). This class might be renamed to Task as well (in the future).

Tasks are well integrated into Visual Studio 2010. For debugging tasks new windows Parallel Tasks and Parallel Stacks are available.

A common pattern is using threads in a loop to perform some actions on a list of items. The Parallel class gives an implementation of this pattern. Parallel.ForEach offers several overloads to do several actions in parallel with the thread pool.

Declarative data parallelism allows LINQ queries to run in parallel. This feature is for LINQ to objects thus collections that implement IEnumerable. All that needs to be done is to invoke the AsParallel method that does nothing more than casting the IEnumerale interface to IParallelEnumerable. The class ParallelEnumerable then offers extension methods for the IParallelEnumerable interface to call the LINQ operators using threads from the pool.

Christian


PDC2008 - Type System Changes with CLR 4.0

From #pdc2008: the CLR type system is changed regarding "type embedding" and "type equivalence". The primary idea was easier use of COM interop, but the features are also useful with pure managed code.

An issue that we have today regarding COM interop is the deployment of Primary Interop Assemblies (PIO). An application that uses Excel 2007, the primary interop assembly required by the application requires 1.2 MB. In reality you need to install the Office 2007 PIA Redist that requires 6.3 MB. And this is just for Office 2007. The next version requires another PIA redist install.
This is one of the issues solved with the new type embedding feature.

With type embedding PIAs are no longer required. Type embedding is possible by the new CLR and a new compiler switch.

The second feature for the CLR type system is type equivalence. Type equivalence is useful both with COM objects and .NET managed code. Interfaces marked with an GUID attribute are treated equivalent if the same GUID is used. Multi-targeting through interfaces. Does this influence System.AddIn? I've to try this out!

Christian


PDC 2008 - C# Futures

Again, Anders Hejlsberg had a great session at #pdc2008. This time about C# 4.0 and C# 5.0!

C# 1.0 was the core about OO, C# 2.0 added generics. With C# 3.0 is the first version with new language features - LINQ, and this is expands with the future versions. C# is a multi-paradigm language. Of course, it's an OO language (since 1.0), since 3.0 it can also be used as functional language. The main areas of enhancements are in these areas:

  • declarative
  • dynamic
  • concurrent

Microsoft is doing a shift in regard to C# and VB to recognize reality. Features from C# are brought into VB, and features from VB into C# - because the demand is here!

C# 4.0 adds dynamic programming. With this it is easy to call not only .NET objects but also easily COM objects, JavaScript, Python...
The enhancements can be grouped into these areas:

  • dynamic keyword
  • optional and named parameters
  • co- and contra variance

With the new dynamic keyword, a variable can be declared in C# that references a object that is created during runtime, e.g. from COM or JavaScript.

dynamic calc = GetCalculator();
int sum = calc.Add(10, 20);
Every method that is invoked on a dynamic object returns a dynamic result that is dynamically cast to the type the return variable is declared (e.g. an int in the example). A great feature here is the syntax looks the same, no matter if the calculator is a COM object, JavaScript, Python or Ruby. Binders for each of these variants are available, and custom binders can be written as well.
Using C# it is also possible to create dynamic runtime-objects by implementing the interface IDynamicObject or deriving from the base class DynamicObject.

A many times requested feature that is available with C# 4.0 is optional and named parameters. Instead of defining several overloads, optional parameters can be defined:

StreamReader OpenTextFile(
   string path,
   Encoding encoding = null,
   bool detectEncoding = true,
   int bufferSize = 1024);
this can be called wih only the mandatory parameter:
OpenTextFile("foo.txt");
and also with named arguments:
OpenTextfile("foo.txt", bufferSize : 4096);
Of course, named arguments must be after the mandatory parameters.

Optional and named parameters have a great COM Interop story. No more ref missing parameters. "It took 10 years to get back where we were".

Covariance and contra-variance is another new feature. co-variance or contra-variance information can be added to generics, e.g. and . means that T can be used only in output positions, only in input positions. Existing interfaces and delegates such as IEnumerably and IComparable are changed to the new notation. A blog entry with samples about this feature follows here!

Anders also demonstrated C# 5.0 features. C# 5.0 opens up the compiler to offer modern ways for meta-programming - compiler as a service!

More information about C# futures:http://code.msdn.microsoft.com/csharpfuture

Christian


ADC08

Thinktecture and post-Thinktecture sessions at the ADC 08 in Germany:
  • Christian Weyer, WCF - Kommunikationsmuster illustriert
  • Christian Nagel, C# 3.0 in LINQ
  • Christian Nagel, Threading und Synchronization
  • Neno Loje, Windows-Anwendungen ohne Kopfschmerzen verteilen: mit ClickOnce
  • Christian Weyer, WCF und WF gemeinsam einstzen
  • Jörg Neumann, Erweiterbare Anwendungen mit dem Managed Add-In Framework
  • Ingo Rammer, .NET Production Debugging - Erste Schritte
  • Dominick Baier, Autorisierung und Identität in Service-orientierten Anwendungen
  • Ingo Rammer, .NET Production Debugging - Tips und Fortgeschrittenes
  • Dominick Baier, Advanced IIS 7 Development

And that's just the first day

Christian