The world of technology and development looks vastly different now than it did 3 or 4 years ago. With all this change it’s bound to happen that new lingo is tossed around, moments before another new best thing hits the development world. If we don’t embrace the change and open our minds up to learn, we quickly feel like a fish out of water and are left behind.
About 2 years ago I was considering to gain some skills outside of .NET, especially as the market for open-source and cross-platform was becoming more demanding and making some noise. However, I’m delighted to see what Microsoft has been busy with lately and it seems they’re embracing the market change as well and are steering themselves in that direction. Let me touch on some of the changes to frameworks, compilers, application models and IDE and see if we can make sense of them.
A disclaimer: this is written from a .NET perspective and not objectively to development as a whole.
After .Net 4.5 there are a couple of new frameworks that have made an appearance. Why so many and what are they?
- .NET 4.5.1
- .NET 4.5.2
- .NET 4.6
- .NET Core
- .NET Native
- .NET 2015
The biggest reason for this release is Windows 8.1. Both Windows 8.1 Store Apps and Windows 8.1 Phone Store Apps need .NET 4.5.1.
Some other smaller enhancements & features:
- JIT improvements (Specifically for Multi-core machines)
- 64-bit edit and continue (without stopping app)
There are 2 noticeable changes in the .NET 4.5.2, one for ASP.NET and other (yes believe it) for Windows Forms.
ASP.NET: The bigger change in ASP.Net is probably the HostingEnvironment.QueueBackgroundWorkItem. In the past if you suggested to “fire a task on a seperate thread and forget about it”, serious red flags were raised. This was because IIS needs to recycle your application regularly and if it happened to do so while your task was busy, the work would never complete. HostingEnvironment.QueueBackgroundWorkItem allows you to “fire and forget”, return a response to the user and the task can safely continue (only up to a max of 90 seconds).
Windows Forms: As some devices support higher and higher resolutions, the scaling in WinForms became a problem. Things such as the little drop down list arrow became absolutely tiny. NET 4.5.2 has introduced a feature to allow resizing for High resolutions, solving this problem.
This is the next full version of the .Net framework. There are a whole bunch of new features and improvements. Some of the many new features include :
- Better event tracing
- Base Class Library (BCL) changes.
- New Cryptography API’s
- Plenty ASP.NET enhancement
But probably the most notable feature for me is the new JIT compiler, RyuJIT. This is a 64-bit JIT compiler optimized for 64-bit computing. Great thing is you’ll get better performance without actually doing anything (on 64-bit machines).
This guy has made some headlines. Imagine a .NET Framework that could be deployed via NuGet. No need for specific framework prerequisites to be installed, but a framework that ships with the application. Imagine no more, this is what .NET Core has brought to the table. .NET Core is also modular which means that you don’t need all part of the framework, only those that you care about.
The biggest features though in my opinion, is that .NET is no longer limited to Windows. It is a cross-platform implementation of the .NET Framework. Yip, we can now deploy .NET applications on Linux or Mac. It’s important to note that .NET Core does not have everything that the full .NET Framework has yet.
I’m sure that you’ve heard hard core C++ junkies say “If you wrote this in C++ it would be much faster”. Why don’t we all switch to C++ for a little performance gain? That’s easy. Productivity almost always trumps Performance. Does it really matter to the client that it took 350ms to execute instead of 150ms? What matters is that it took only 10 minutes to develop instead of 30! Not just that but also that we can rest assured that our memory is safely managed by the CLR’s Garbage Collector.
Well .NET Native is an interesting twist to this age old tale. It allows you to compile code directly into native (machine code) instead of IL code (which only gets converted to native code at runtime by the JIT compiler). This way it avoids needing to run on the full CLR as the usual .NET applications do, but still includes a refactored runtime for Garbage Collection.
Can we still step through our code and edit and continue? Fortunately yes we can. When “Debugging” the code actually runs off the CoreCLR (Part of .NET Core) and is not natively compiled. This also prevents extended compilation times each time we debug.
Some benefits using .NET Native:
- Faster startup times (JIT doesn’t need to convert to native code at runtime)
- Smaller memory footprints (optimizations made to chuck out what we won’t need at runtime)
- C++ compilation with C# productivity.
Of course this coin also has 2 sides. Limitations:
- Must compile into specific architecture (since JIT used to handle this, we must now make both x86 and x64 builds)
- Limited (currently) to Windows Store development
.NET 2015 is an umbrella term for these new .NET “components”:
What’s new on the compiler forefront and why should we care? Whether you’re indifferent to understanding the different compilers and their benefits or care deeply about the matter, knowing what’s new and what that means for development is important. So what is new?
- .NET Native Compilation
Before I jump into these, We very briefly need to highlight how a .NET application compiles and executes.
- We write some C#
- Compile. This runs our code through a compiler (c# compiler in our case – csc.exe) which outputs IL (Intermediate Language) code.
- Running our application, the JIT compiler (Part of CLR) converts IL code to native code as needed
- Native code is executed and cached (in memory)
This image was taken from this blog, which does a fantastic job at explaining the basics of the JIT compiler.
Roslyn is a rewrite (from ground up) of the C# and VB.NET compilers. It’s an open source solution, allowing us as developers to not only view how items get compiled, but also get our hands dirty in customizing compilation (if needed). The compilers have been written in their own languages (C# compiler code is C# and VB.NET compiler code is VB.NET).
Probably the most important features that Roslyn brings to the table is a set of API’s that allow us to create some interesting things such as implement customized intellisense or refactoring. The API allows us to do static analysis which means we can analyse code without actually having to execute it. Also Roslyn can compile code “on-the-fly”. This means that you don’t need to recompile code before running it again, as the Roslyn compiler will do this for you in memory.
A silly refactoring example might be, in Visual Studio, clicking on a global variable, hitting Ctrl + . and then then choose our custom “Convert to Property”. Our code written with Roslyn API will then grab the variable, analyse it, perhaps adapt it to some naming standard and convert it to a property. We can now easily build and deploy our refactoring tool to NuGet allowing others to easily download and use our tool.
Although Roslyn is probably not something most developers will get their hands dirty with, it certainly will open a flood-gate for Visual Studio productivity tool and extensions.
Although JIT compilers are nothing new, the next-generation 64-bit JIT compiler for .NET has been released and dubbed RyuJIT. It’s performance is a lot better compared to the previous 64-bit JIT compiler. The heaviest workload of a JIT compiler is at startup as it starts converting IL code to native code and caches it in memory. RyuJIT now starts up to 30% faster.
.NET Native Compilation
We’ve already touched on .NET Native and what makes it so valuable. The .NET Native compiler compiles all our code (including .NET Framework and 3rd party) code directly into machine (native) code. We’ve discussed the advantages of this earlier. This is just to mention the new compilation chain .NET Native uses to magically convert code to machine.
So we’ve looked at the new Frameworks and touched on new compilers. There’s one more area that also boasts change. The application model. The one making the most noise IMO is ASP.NET 5, but UWP for Windows 10 is still worthy of some attention:
- Universal Windows Applications (UWP)
- ASP.NET 5.
Universal Windows Applications (UWP)
UWP for Windows 10 has been recently released. What is UWP? Basically it allows us to develop a single application which will be able to deploy to a whole range of all Windows devices. Desktop, Mobile, XBox, Surface Hub etc…
The biggest feature for me is that UWP is now optimized by the .NET Native runtime (I won’t go through the benefits of this again. See the .NET Framework section of why this is cool).
ASP.NET 5 (previously referred to as ASP.NET vNext) has been released and boasts some great and interesting features and changes. First off, a lot has changed and to touch on all changes is out of the scope of this article. I’ll mention some things that stood out for me personally.
- First and top of my list, ASP.NET 5 can run both on the full .NET Framework and on .NET Core. Running on .NET Core means it’s now possible to host our sites on OSX or Linux.
- ASP.NET does no longer support WebForms, but only ASP.NET MVC
- No more VB yet? Only C# is supported at the moment.
- Some great TagHelpers which are closer to pure HTML to be used instead of the usual Razor HtmlHelpers.
- Support for some popular client-side libraries such as GruntJS, NPM and Bower.
- Built-in support for Dependency Injection
Plenty more info and goodies to be found on the ASP.NET 5 site
Tying together all the new features, we have a new IDE (Visual Studio 2015).
Visual Studio 2015
Visual Studio 2015 RTM has been out since mid-late July (I think) and using it for a couple of weeks I’ve noticed some cool features:
- We can now debug lambda expressions. This is VERY cool. (Quick watch a collection, run a Linq Query and get results immediately)
- Visual Studio has built in support for Cordova. Previously we’ve needed to compile from the command line.
- When running from one breakpoint to another, the elapsed time shows. (No more manual timer code to check how long a method took)
- Compiler support for C# 6 (and VB 14 of course).
- VS Premium and Ultimate merged into Enterprise. So if you previously had premium account, you’ll now get “upgraded” to Enterprise. This finally allows the use of CodeLens feature (been around in VS 2013 already)
- Includes a built in Android Emulator which can be used to debug Xamarin / Cordova apps.
Seeing the effort and improvements that Microsoft has put into some new products recently and how their shift towards a more open-source ecosystem and cross-platform intentions, I believe there are exciting times ahead and at least for the next while, in my opinion it’s looking both promising and safe to be a .NET developer!