Search This Blog

Wednesday, June 22, 2011

X++ is a Managed Language

Developing in .NET Managed Code and other X++ enhancements".
Some of the "minor" improvements in the X++ language in Microsoft Dynamics AX 2012.
These includes:
  1. New AS and IS keywords - with the same semantics as in C#. In X++ they work for class and table types.
  2. Support for Attributes - just like in C#.
  3. Table inheritance.
  4. Tightening up of various language constructs. X++ no longer allows return type covariance, return type contravariance, parameter covariance, parameter contravariance, and visibility contravariance. This fully aligns X++ with C#. To explain this in less language-savvy terms, it means an overriding method must have the same return type and parameters as the method it is overriding. Further; it cannot reduce the visibility, e.g. it cannot make a public method private.
  5. The dangling semi-colon is not required anymore. The spontaneous applause was much appreciated.
 X++ as a managed language-
The BC.NET component has been re-engineered. In Microsoft Dynamics AX 2009 it is basically a face-less client that allows the managed world to call into the AX stack. The X++ code in AX 2009 can call out into the managed world using interop. Notice that when you call out into managed code, you cannot call back into the same AX session. I.e. no round-tripping. In Microsoft Dynamics AX 2012 this is changed. The new BC.NET component is a now thin conversion layer that can attach itself (in-process) to the AX client(s), the AOS and regular managed code. It will ensure all marshaling and type conversions happen seamlessly between the two realms,having a X++ class pass itself to a C# class, and let the C# class change the state of the object, by invoking a method on the X++ class. It just worked exactly like you would expect.

In Microsoft Dynamics AX 2012 we are compiling X++ code to the CLR. At compile time we generate an XML representation of the pcode, which we can convert into IL. At run-time we will be executing the IL for batch jobs, service calls and RunAs constructs. (RunAs is a new method allowing you to request the X++ logic to be executed as IL.). Peter demonstrated how the performance characteristics are vastly different particular in situations with extremely many objects or extremely many methods calls. Even in less-extreme situations running X++ as IL is beneficial as for example it reduces the time database locks are held, and thus improves performance and scalability.