The Good and the Bad of .NET Framework Programming
.NET is a software development framework and ecosystem designed and supported by Microsoft to allow for easy desktop and web application engineering. It’s a popular free platform currently used for a lot of different types of applications as it provides the programming environment for most software development phases. .NET best suits businesses that look for a wide range of features like web-based services, desktop software, and cloud infrastructure support.
.NET in 16 minutes or less
The history behind .NET
Microsoft started working on .NET framework in the late 90s. The idea was to create a platform based on so-called managed code, code that can be executed under a runtime environment. This was needed to improve development experience and relieve engineers from handling security operations, active memory management, and other low-level efforts that C/C++ developers had to bother with.
The first release of .NET Framework in 2002 introduced C#, a language for writing managed code that had a design similar to C++. The framework itself aimed at Windows-based computers and servers. It had WinForms, a GUI library for desktop applications; ASP.NET, a framework for Web; and ADO.NET for data access. All these elements were driven by Common Language Runtime (CLR) to compile and execute managed code.
To unite various functions, .NET offered a framework class library (FCL) that included the base class library (BCL), network library, a numerics library, and others.
Since that time, the framework has undergone multiple iterations spanning runtime updates, new desktop graphical systems (WPF), APIs for service-oriented applications (WCF), and more.
In 2014, Microsoft announced a dramatic shift in the way .NET exists by presenting .NET Core, a new cross-platform, cloud-friendly, and open-source version of the framework. .NET Core made it to a release in 2016, becoming the main technology to consider for new .NET projects. Gradually, Microsoft started porting existing services to work with Core. Some that didn’t receive official ports, like Windows Communication Foundation (WCF), were substituted by alternatives sourced from the community.
.NET ecosystem before 2016
Also, in 2016, Microsoft acquired Xamarin, previously a proprietary technology for cross-platform mobile development, making it open source as well.
Microsoft continued moving towards “transparency between the product team and the community,” and open sourced Windows Presentation Foundation (WPF), Windows Forms, and WinUI frameworks in December 2018.
But that’s not all. In May 2019, the company the big release that will unify the whole ecosystem: All .NET products will be bundled in the .NET 5 development platform. That means devs will be able to build applications on Windows, Linux, macOS, iOS, watchOS, Android, tvOS, or using WebAssembly with just a single .NET. The platform will come with new APIs, language features, and runtime capabilities. Also, .NET 5 will include ASP.NET Core, Xamarin, Entity Framework Core, WPF, WinForms, and ML.NET.
Soon .NET platform will be organized this way. Source: .NET Blog
Four previews of .NET 5.0 have already been shipped, and the release is scheduled for November 2020.
With these changes yet to come, for now a .NET practitioner could work with three separate branches of the Microsoft platform: .NET Framework – still dominant across businesses, .NET Core – a fresh environment, and Xamarin for mobiles. Additionally, Microsoft suggested .NET Standard library to connect APIs across all three and ultimately make the lives of engineers easier.
What is .NET development platform
.NET comes in four flavors: .NET Framework, .NET Core, Xamarin, and Universal Windows Platform (UWP).
These implementations combined are called the .NET development platform. Each of them contains frameworks and libraries to build various applications.
The .NET Framework released back in 2002 is the first and oldest implementation of the platform. It includes three main application models – WPF, Windows Forms, ASP.NET Forms – and Base Class Library.
Windows Presentation Foundation (WPF) is a UI framework used for creating graphical interfaces primarily for desktop client applications on Windows OS. WPF uses the capabilities of Extensible Application Markup Language (XAML).
Windows Forms is a GUI class library within .NET Framework. Windows Forms are used to develop desktop applications with rich graphics that are easy to update and deploy.
ASP.NET. While the previous two components are designed for desktop engineering ASP.NET is used to develop dynamic websites and web applications. There is the Common Language Runtime (CLR) in its core that gives developers the opportunity to write ASP.NET code using different .NET languages that we discuss below.
Base Class Library (BCL) provides the most common functionality like classes in namespaces and is the core of the Framework Class Library (FCL), a set of reusable interfaces, classes, and value types that are closely integrated with the Common Language Runtime (CLR). The combination of FCL and CLR constitute the .NET Framework. The base class library also includes ADO.NET, data access technology used by developers to access databases.
As .NET Framework supports only Windows-based devices, there was a need for a cross-platform package.
.NET Core was released in 2016. It’s a cross-platform re-build of .NET Framework. Unlike the old version, engineers can now use the product on Linux and macOS and create applications that aren’t necessarily tied to the Windows family. The new system aims at conquering the cloud space as some providers like Digital Ocean are Linux-driven. Not only is .NET Core cross-platform, its different versions can also be installed side by side on the same device. .NET Core includes ASP.NET Core and Universal Windows Platform (UWP).
ASP.NET Core is a rebuild of ASP.NET that happened to be a more modular framework than its predecessor. ASP.NET Core allows you to build the mobile backend, web apps, and services. It’s also cross-platform and runs on OS X, Windows, and Linux.
The third implementation is called Xamarin and is used for mobile applications and Mac products. Originally, Xamarin was designed independently from Microsoft and was a proprietary product. Then Microsoft acquired it in 2016 making it a fully open source branch of the .NET platform. Xamarin uses the Mono runtime and a version of the .NET Framework adjusted to work with APIs for iOS, Android, and Xamarin.Mac. To get an elaborate overview of this product, check our Xamarin pros and cons article.
All runtimes use a common infrastructure that makes the entire ecosystem work. It provides runtime components, languages, and compilers.
Universal Windows Platform (UWP)
UWP provides a common type system, APIs, and application model for all devices running on Windows 10. So, UWP enables development of universal apps for PC, tablet, Xbox, Surface Hub, HoloLens, or Internet of Things (IoT) devices.
UWP app developers get access to the Microsoft store that charges only 15 percent for non-gaming subscription-based apps, unlike Google Play Store and App Store. Other services include an execution environment (AppContainer) and Extension SDKs to call specialized APIs for different devices.
In 2016 Microsoft also introduced .NET Standard, a library that combines APIs from .NET Framework, .NET Core, and Xamarin allowing engineers to use a single base-class library rather than mastering three different ones related to each .NET implementation. This step unified the ecosystem and brought a higher consistency to reusing components across different platforms.
.NET ecosystem after 2016
.NET development platform is best served with Visual Studio IDE used for building, debugging, and publishing applications across all platforms and devices.
Common language runtime (CLR)
Common Language Runtime (CLR) is the heart of .NET, an application virtual machine that manages memory, implements code access security, verifies code safety, and provides execution of threads and code. CLR is what makes the .NET code a managed one.
As we mentioned, the idea of CLR is to make developer’s life easier. Besides, it allows engineers to design systems with multiple languages, as CLR enables them to communicate and integrate their behaviors. The runtime checks the needed versions of applied services to ensure that all dependencies are intact and the code works as intended.
In .NET Core, an open-source CoreCLR is used. While nearly identical to CLR in .NET Framework, CoreCLR is adjusted to the .NET Core cross-platform makeup.
The languages that you can use with .NET can be ultimately divided into two major groups: 1) the main officially supported languages by Microsoft, and 2) the rest of the languages that are CLI-compliant.
Main languages. Most of .NET development happens with C#, F#, and Visual Basic.
The rest of CLI-compliant languages. CLI means common language infrastructure. It’s a technical standard for high-level languages that can be compiled into common intermediate language (CIL) and further compiled into a byte-code. Besides, those three mentioned above, there are about 25 active CLI-compliant languages, including C++/CLI, IronPython, Oxygene, Phalanger, and more. There’s also a number of languages that are no longer used, like IronRuby.
.NET starter pack
If you’re just starting with .NET, here are some useful links for the beginning of your journey:
.NET guide – the general documentation by Microsoft for newbies;
.NET Core guide – for those considering transitioning to the Core version, go here;
.NET framework – the original .NET documentation;
Xamarin – the docs for mobile development;
.NET foundation – the headquarters of the .NET open-source community;
Best .NET tools – our take on the best tools, supported by expert opinion;
.NET Core and framework – download it here; and
.NET developer community – all about chatter and support with links to social media, forums, blogs, live workshops, and organizations like .NET foundation.
Now, let’s look deeper at the advantages and drawbacks of using .NET development platform. Most of the points can be applied to the entire ecosystem, while some of them relate only to its specific components, which we’ll specify in the respective sections.
Pros of .NET development
Object-oriented software development model
.NET is based on object-oriented programming (OOP). OOP is a development model for breaking down software into smaller pieces that are easier to manage and combine. OOP compartmentalizes data into objects, i.e., data fields, and describes objects’ behavior and contents through the declaration of classes.
A modular structure helps define the behavior of objects and their interactions without managing object inner attributes. OOP simplifies programming by making the code manageable, easier to test, and respond to recurring issues. It also eliminates unnecessary programming and generally means less coding for developers. .NET makes it possible to reuse code and components, save time and – subsequently – the cost of development.
Reliable and simple caching system
Caching means keeping data in a temporary storage place to call it faster when needed. The stored data is the result of an earlier information request or the duplicate of information stored in other places that would take longer to retrieve from.
The caching system in .NET is robust and simple to use. It’s also designed to be extensible. The Object Cache class allows developers to create a custom cache implementation to be used for improving performance and scalability of Windows client and server applications.
Visual Studio IDE
An Integrated Development Environment (IDE) is a single product for programmers that makes application development easier by providing all the tools needed to write and test software.
Visual Studio is a Microsoft IDE used for building, debugging, and publishing applications across all platforms, including Android and iOS. Visual Studio is integrated with .NET and provides the features of language-specific environment.
The key features of the Visual Studio IDE:
- It’s used as a single IDE for all .NET applications.
- The IDE has integrated compilation and debugging features.
- Collaborative features include a Git-first workflow, real-time collaboration on the same codebase, and integrated code reviews.
- The solution can be used for applications based on code written in different languages.
- Visual Studio allows for customizing the environment to match user preferences.
Additionally, Visual Studio Marketplace offers a wide range of editor extensions from Microsoft and other providers to enable team collaboration, continuous integration, third-party connections, cloud development management, etc.
Cross-platform design of .NET Core
.NET Core is a cross-platform .NET implementation that allows the code to run on macOS, Windows, and Linux. Unlike the original .NET framework – which is not completely open – .NET Core has a fully open source code that ensures that a wide engineering community can continuously contribute to its development.
If you’re writing in C#, F#, or Visual Basic, your code will run on each of the compatible operating systems. This enables companies to reach the widest variety of platforms staying within the .NET ecosystem. At the same time, cross-platform design ensures that the whole .NET community with a large pool of different engineering skillsets shares experience.
Flexible deployment and easy maintenance
One of the important .NET Core features is flexible deployment. It can be installed as a part of your application or require a separate installation. The modular design contemplates including all the dependencies you need. The deployment itself is as easy as copying a folder.
Another benefit is that you can have multiple .NET Core versions running side by side on the same machine to cover different projects and seamlessly perform deployment tasks.
Universal .NET Standard
Since 2016, the .NET ecosystem has been enhanced with a large class library called .NET Standard. It’s based on the number of base class libraries for .NET Framework, .NET Core, and Xamarin. These are used to work with common functions such as graphics rendering, database interaction, and manipulations with XML documents. The .NET Standard library greatly simplified developers’ work.
Prior to .NET Standard, a programmer had to redevelop an application or a library for the new platform and then distribute all the updates across various platforms. Currently, the library supports all dependent libraries across applications. However, you should check version compatibility to successfully leverage .NET Standard.
You may check your product compatibility with .NET Standard here and track updates on the Microsoft documentation site
.NET has a large community of developers. Interestingly, it unites engineers from small, midsize, and enterprise-grade companies. This means that almost any issue can be resolved with the help of community members.
Since .NET Core is open source, its libraries, runtime, and compiler are available on GitHub and have many contributions. According to the Stack Overflow 2019 survey, ASP.NET took fourth place among the most popular web frameworks while .NET and .NET Core placed second and third respectively as the most used frameworks beyond web development.
Most popular frameworks Stack Overflow Survey 2019
Besides that, .NET Foundation that fosters open development and teamwork around the .NET ecosystem. .NET community and commercial developers use it as the main forum for idea exchange.
Automatic monitoring in ASP.NET
ASP.NET has built-in automatic monitoring. The Windows Web Server strictly monitors web pages and applications that run on it. In case any issues such as the memory leaks or infinite loops occur, it immediately alerts about them. This allows for directly correcting these behaviors and creating new processes. The monitoring ensures higher stability and transparency of .NET applications.
Powerful Roslyn and RyuJIT compilers
.NET uses two compilers, Roslyn, to compile C# or VB code into CIL (common intermediate language), and RyuJIT, to run just-in-time compilation of CIL into native code. Both compilers are highly regarded by the .NET community as Microsoft actively improves them.
Roslyn has been available since 2011. In 2014, it became open source and in 2015 was included in Visual Studio. Besides the fact that it’s open source, Roslyn exposes APIs to offer rich code analysis for the developer. This means that unlike traditional black-box compilation, with Roslyn, developers can read the compilation data at every stage.
RyuJIT is responsible for compiling CIL to byte code. The full transition from the old JIT was completed in 2018 with the idea of improved performance. And, generally, engineers agree that RyuJIT is faster. According to .NET 5 Preview 1 and Preview 2 released in spring 2020, numerous improvements to RyuJIT were made to enhance the quality of the machine code generated by JIT (“code quality” as Microsoft specialists call it). “In summary, about half of the following improvements are actual new optimizations, and the other half is due to changing the flow of RyuJIT to enable existing optimizations to apply to more code patterns,” noted .NET Team Program Manager Richard Lander.
Active Microsoft support
Since .NET is Microsoft’s platform technology you would expect the company to actively support and develop it. But the point is, Microsoft is really good at what they are doing. Perhaps there’s no other technology company with such a full and coherent ecosystem that checks off all boxes for engineers, from IDEs and frameworks to cloud services.
Microsoft does its best to further evolve. The transition to .NET Core was a major step in terms of the ecosystem development, as it embraced cloud and focused on performance improvements.
In 2018 Microsoft introduced the ML.NET framework for C# and F# languages. While it’s too early to say how successful this initiative will be, .NET eventually becomes a one-stop platform for anyone. Also, let’s keep in mind the release of .NET5 planned in fall 2020.
Disadvantages of .NET development
Even though .NET is considered one of the strongest engineering platforms out there due to extensive infrastructure and proven product development history, it comes with a set of problems.
Limited Object-Relational Support
As we mentioned above, .NET uses the object-oriented programming (OOP) language model. This model is centered around objects rather than “actions” and data rather than logic. The support of data-oriented software application development in .NET Framework and Core are provided by the Entity Framework.
Entity is an object-relational mapper (ORM) that links object-oriented .NET Framework and relational (SQL) databases. Some engineers believe Entity Framework isn’t flexible enough and may not support all available database designs. This also means that there’s a chance that at some point Entity Framework may not be supporting new database designs. Another problem is that the framework may eventually be abandoned by Microsoft.
On the bright side, you can always choose another ORM alternative, so it remains a debatable point.
Building .NET apps isn’t cheap regardless of open source technologies. Mostly, your expenses will be spent on Visual Studio IDE and other additional collaboration and quality assurance services that Microsoft offers to simplify your work. As of today, the base version of Visual Studio will cost you $1,999/year for one new engineer and $799 for subscription renewal. An enterprise release that includes various cloud, enterprise mobility, QA features, and more will be about $6,000 the first year and $2,569 for renewal. However, you still can try to become a Microsoft Partner to have a number of subscriptions for free. For non-profit and educational purposes, there is also the free Visual Studio Community.
Even though you can use .NET Core on Mac and Linux machines, the best way is to use Windows for .NET engineering, which also comes with licensing costs.
The barrier will be even higher if you’ve never used Microsoft products before and you have to migrate from say AWS cloud ecosystem to Azure.
The gap between release and stability
Perhaps, this problem cripples all Microsoft products not .NET stack only. But it’s definitely worth mentioning. The newly released products lack proper documentation, support, stability, and are prone to drastic changes. In one of AltexSoft projects, our architects decided to use a fresh DocumentDB (now Azure Cosmos DB) but then were forced to design custom data architecture as the product suffered a number of technical issues that could jeopardize the entire project.
One of Y Combinator users has vividly described this issue: “My problem with these kinds of Microsoft technology evangelism articles/videos is that it always seems like Microsoft has juuuust gotten their new hotness to work, and is telling the world that it’s awesome, and ready for production. Then you go to implement it, and as soon as you leave the perfect world of their demo, it all falls apart, and THEN you find out the docs were written for the beta version, and no longer apply, so you’re left guessing at the right invocation signature for the method you need.”
The problem of memory leaks is not uncommon in any technology. Simply put, the framework doesn’t release the memory that it no longer needs. .NET is frequently criticized for memory leaks and memory-related issues. Although .NET has a garbage collector for this sort of problem, engineers still have to invest additional efforts into proper resource management. And the leaks keep on growing as the application scales.
Fortunately, any engineer will be able to find detailed and effective recommendations for detecting leaks in .NET.
Bumpy transition to .NET Core
.NET Core is the next big step in Microsoft’s platform development. As always happens, the transition period may be long and difficult. The applications built with the old .NET Framework outnumber those with .NET Core. And it doesn’t necessarily mean that all of them will experience this transition. In corporate environments, the transition may not be prioritized as much. Nonetheless, these systems need support.
Another related problem here is that the mature .NET Framework had many supporting projects around. For example, many developers expressed concerns about abandoning Windows Communication Foundation (WCF), a runtime and API set for service-oriented applications used by many .NET practitioners. Microsoft decided not to port WCF to Core. Instead, they leveraged community effort, as one of .NET Foundation team members donated an open source alternative, Core WCF. Again, this isn’t directly managed by Microsoft, nor does it provide full compatibility with the original WCF. Developers will have to spend a little extra effort to complete a transition.
Scott Hunter, from .NET program management, posted that you won’t find ASP.NET Web Forms, .NET Remoting, and some other services in .NET Core. They’ll be gone for good, freeing the way for new technologies.
When to use the .NET
Scalable products. Usually, business needs are growing and your software has to scale with it. .NET provides a scalable environment and allows for redesigning ongoing applications in order to match the growing needs of the business.
Cross-platform needs. In case you need the app that will work across platforms, .NET will be a great choice as most platforms are covered and you can reduce development effort while expanding your desktop or mobile app to other operating systems. Also, .NET can be used for such specific engineering cases as gaming (including Xbox) and AR development (including HoloLens).
Enterprise-scale infrastructures. It’s still a debatable point whether .NET is designed mostly for enterprise use. But Microsoft makes sure it provides the widest toolset possible to build and cross-integrate enterprise products, both internal and public ones. It also supports a robust enterprise mobility ecosystem.
This article is a part of our “The Good and the Bad” series. If you are interested in web development, take a look at our blog post on the