What about this new eXceLleNT Dynamics AX compiler?

As the new major release of Dynamics AX is released, we can now dig a little deeper into some of the new stuff available to us now. And boy did they put in a lot of effort! Previous major releases did bring us some new tools, but there was a balance between new tooling and new functionality. With this major release, the focus is definitely more on getting the technology stack up to date. One of those new things available to us, is a whole new nice and shiny compiler!

 

Many of you guys will recognize the picture below. In Dynamics AX 2012 RTM and FP, you could literally wait for hours for your compiler to finish. This was because of the single threaded 32-bit compiler in the client. R2 CU6+ brought some relieve by introducing a command line tool that could compile your application with multiple workers, but still the process of compiling X++ and CIL afterwards, was not quite what it should be.

compiling

But now those days are over! A new compiler rises! So let’s have a look and see what stuff this brings along.

XLNT (X++ language Toolkit aka Excellent)

XLNT is a framework written in C# that is similar to the Roslyn compiler framework (but much smaller) (https://roslyn.codeplex.com/).  It has been built up from scratch in C# because the old compiler stack (C++) was from a time where hardware and CPU power was not as powerfull as today.

 

Below you can see a simplified schema of how the compiler is built now. It uses a more phased approach where you are able to ‘plug in’ passes based on what you want to achieve (Compilation, Best Practice checking, …). You can see the compiler as a set of building blocks that you can use for different scenario’s.

CompilePasses

Visual Studio Integration

In this major version of Dynamics AX, Visual Studio has become the IDE for all of your X++ source coding on a daily basis. And because of that, one of the two ways you can access the compiler is from within the GUI of Visual Studio (and the other one is a command line tool called xppc, which can be a post on it’s own)

 

To start a compilation, you can do one of two things:

 

  • you can just build your solution / project as you would do with any other C# application. This will invoke an incremental compile of what has changed. To be able to give you a good experience within Visual Studio, this type of compilation is triggered when you go around and change things and will only compile a subset of your model by only recompiling the netmodules in which the changed objects reside.
  • Another way of compiling is to use the new Dynamics AX menu to perform a build on the models you select. This is called a full compilation of the model and will compile all of the netmodules related to your selected models.

FullBuildWindow

If you save your source code written in Visual Studio, every single method is persisted into its own XML file. The XLNT framework is responsible of writing to and reading back from the XML files. (aka stitching and unstitching).

 

Basic navigation (stuff like Go to declaration) relies on cross references. So to be able to do this, the compiler will contain a pass that handles cross references and bulk copies related data to the cross reference database (DYNAMICSXREFDB). Also keep in mind that when you do not need a building block like this (say in a nightly build), you can just leave it out and compilation time will be much less.

X++ Compilation

In previous versions, not all of the code was generated in MSIL. A part of the code was still compiled into P-Code and being interpreted at run time. Another part was transformed into MSIL by XSL transforming P-Code generated by the compiler. But as of now, this is entirely gone and everything is generated in MSIL managed code by the compiler!

 

On top of that, the new compiler is massively parallel : as Microsoft states: “This thing will get his hand on all of the resources it can take to do as many things in parallel as possible. It means that you need to run this on a machine with at least 16GB of memory for a full build. That’s just how it’s designed.”

 

Another feature which is really nice, is the diagnostics support. At each point in time, the compiler can output error messages that will be included in the diagnostic telemetry available for the application. Based on this telemetry data, you can get an insight into different aspects of compilations. Microsoft is able to act on compiler errors, crashes, … much quicker then before to improve the compiling experience.

Best Practices

Let’s not leave out best practices. As Peter Villadsen quoted : “BP’s are important, anyone who says different, has not been in the industry long enough and not suffered enough. They are the result of many years of industry practice and should not be disregarded.” And I could not agree more. For years know, we have been making an effort and succeeded in customizing Dynamics AX without introducing new best practice violations. And to help with this, the XLNT framework also provides the tooling for checking best practices and authoring custom rules.

 

The best practice checking tool, like the compiler, can be run automatically when compiling or can be called using a command line tool. And Microsoft has clearly taken this seriously because for the first time ever, they too have adopted a zero tolerance approach for all of their code. So yes, all best practices have been addressed!

 

So this is in a nuttshell what the new compiler is all about. Stay tuned for more!

One thought on “What about this new eXceLleNT Dynamics AX compiler?

Leave a Comment Yourself

Your email address will not be published. Required fields are marked *