What is .NET? An Introduction Microsoft’s Framework

Back in the early 2000s, the applications built with .NET were aimed exclusively for Windows desktop and the framework itself was strictly developed and maintained in a closed source format. However, with the introduction of .NET Core, Microsoft made a complete shift and revolutionized software development. Applications could now be developed for a broader set of operating systems and platforms including Linux and macOS. Not only that, the development of .NET Core was made public with Microsoft sharing and receiving feedback directly on its GitHub set of repositories under the supervision of the .NET Foundation.

Fast forward almost 20 years, we’re now on the verge of .NET 6, which is expected to be released this November. It’s going to somewhat “finish” the unification of .NET Framework with .NET Core all under the same umbrella of .NET – a long process that started with .NET 5.

In this article, we’ll explore the main features that make .NET one of the most popular platforms out there.

What is .NET?

To put it simply, .NET is an open-source software development platform built by Microsoft. It allows us to build cross-platform software products that can run on Windows, Linux, macOS, iOS, Android, etc. 

It’s used for creating many different types of applications and services and provides the necessary programming environment for all software development phases. Its surrounding ecosystem is a great fit for businesses and individuals that want to develop a wide range of software products, from desktop and mobile apps to web apps and cloud-powered services.

The History of .NET 

In the late 90s, Microsoft created .NET hoping to compete with Sun’s Java, which was making a huge impact in the software development world. Envisioning a cross-platform development paradigm, Microsoft started incorporating the best brains in the market to develop its own software development ecosystem, going from desktop to the Web with Active Server Pages (ASP) and later on with ASP.NET, finally making the shift from on-premises to the cloud in recent years with Azure. Cross-platform is now something that we can take for granted when employing the .NET platform.

As you can see, it’s been a long road (almost 25 years) since its inception and that makes .NET rock-solid today. The following timeline depicts the main events related to .NET:

For a more complete list, here’s a detailed breakdown of events that lead us to the current state of .NET

.NET’s Main Features

The following list depicts .NET Framework main features:

  • One framework, multiple languages: .NET introduces a Common Type System (CTS) that defines all possible data types and programming constructs supported and how these may interact with each other. This allows .NET to support multiple application development programming languages, including C#, F# or Visual Basic.
  • CLR – Common Language Runtime: All the programming Languages in .NET are compiled into an intermediate language known as Common Intermediate Language (CIL). This intermediate language is not interpreted but compiled to native code in a way known as Just In Time compilation (JIT). The combination of these is called Common Language Infrastructure (CLI).
  • Interoperability: Often, interaction between new and old applications is required. The .NET Framework provides a way to access features that are implemented in programs that run outside the .NET environment.
  • Base Class Library: The Base Class Library (BCL) is a type library available for all languages that use .NET. The BCL provides classes that encapsulate many common functions, including reading and writing files, image design, database interaction, XML and JSON manipulation, etc.
  • Security: .NET allows code to run in different levels of security without the use of a separate security mechanism.
  • Automatic Resource Management: .NET CLR automatically manages memory, network, database connections, etc. It invokes built-in functions to allocate and deallocate the memory used by objects during runtime. This removes the burden of managing memory from the developer.
  • Portability: Applications written in any .NET language are portable. That means that when the source code of a program written in a CLR compliant language compiles, it generates machine-independent, intermediate code. It’s also possible to mix and match code written in the languages supported by the framework.
  • Easy and rich profiling and debugging support: Integrated Development Environments (IDEs) like Visual Studio or Visual Studio Code provide a place to develop and debug .NET applications. The framework provides rich debugging and profiling information which is highly integrated within these IDEs. This helps us to check the application performance and track down runtime exceptions.
  • Deployment made easy: When it’s time for application deployment, the developer has plenty of options to package the app depending on the desired deployment environment (desktop, mobile, cloud, etc.).

.NET’s Common Language Infrastructure

The most important .NET component is located within the Common Language Infrastructure (CLI). The CLI’s purpose is to provide an agnostic language platform for application development and execution, including but not limited to components for exception handling, garbage collection, security, interoperability, etc.

The CLI implementation in .NET is called Common Language Runtime (CLR). The CLR is composed of four primary parts:

  • Common Type System (CTS)
  • Common Language Specification (CLS)
  • Just-in-Time Compiler (JIT)
  • Virtual Execution System (VES)

Assemblies

The Common Intermediate Language (CIL) is hosted in partially compiled code libraries called .NET assemblies, which for a Windows implementation means a portable executable (PE), a file (EXE) or a Dynamic Link Library (DLL). These form the .NET distribution, version and security units.

Metadata

Every CIL is self-described through metadata. The CLR checks the metadata to ensure the correct method is called. Metadata is usually generated by language compilers and also describes all the information about the assembly.

Base Class Library

The Base Class Library (BCL) is available for all .NET languages. It provides encapsulation for the most diverse functions used by programs developed with the support of the .NET Framework.

.NET Programming Languages

While it supports alternatives such as F# and Visual Basic, .NET’s main programming language is C#.

C# is a modern, object-oriented, and type-safe programming language that enables developers to build many types of secure and robust applications. C# has its roots in the C family of languages, which should make developers with a background in C, C++, Java, and JavaScript feel comfortable working with it.

C# has these great constructs built-in:

  • Generics, partial classes, anonymous types, iterators, nullable types, static classes, delegate interface.
  • Implicit types, object and collection initializers, auto-implemented properties, extension methods, query and lambda expressions, expression trees, partial methods. 
  • Dynamic binding, named and optional arguments, generic covariance and contravariance, embedded interop types.
  • Asynchronous tasks with async and await (task asynchronous programming model). 
  • Roslyn (compiler-as-a-service), exception filters, await in catch/finally block, auto property initializer, string interpolation, name of the operator, dictionary initializer.
  • Tuples, pattern matching, record types, local functions.
  • Using declarations, nullable reference types, async streams, null-coalescing assignments.

C# is open-source and maintained at this GitHub repo, where new language features are developed, adopted and specified together with the Roslyn compiler GitHub repo. Roslyn is where the specification takes form and gets added to the language itself. It implements both the C# and Visual Basic compilers with an API surface for building code analysis tools.

.NET’s Move to Open Source

Today both .NET and C# are open-source. I say today because this wasn’t the case in the past, which made companies and developers stray away from it. When Microsoft began shifting towards open source in 2014, it opened the source of .NET Framework to promote its software ecosystem and stimulate cross-platform development.

You can find its repositories at this GitHub page (currently, it has 197 repositories). These repos contain the source code that makes .NET cross-platform capable. It’s maintained by Microsoft and the .NET community.

In sum, it’s a win-win game for everyone, as it allows ideas to be openly discussed with great minds scattered around the world. Once an agreement is achieved, implementation begins, followed by an exhaustive code review process. It’s only after the submitted pull request complies with all the rigid code standards that the source code is finally integrated into .NET. Here’s one contributing guideline from the .NET runtime as an example.

Not only is new code appreciated, but submitting issues are also of great importance. Overall, GitHub repos make it easy to track the evolution of submitted code and issues. One interesting fact is that .NET consistently ranks among the top 30 most active open source projects since 2017, as tracked by the Cloud Native Computing Foundation.

When we hover over the .NET circle in the chart above, we can see some great statistics about the entire open-sourced .NET on GitHub. In just 6 months we’ve had 56,000 commits, 33,644 pull requests and 1,507 committers:

What used to take years to be implemented or fixed now takes weeks, months, or even days. All aspects of .NET are open source, including class libraries, runtime, compilers, languages, ASP.NET Core web framework, Windows desktop frameworks, Entity Framework Core data access library, and more. Not only the source code but the documentation is also open source.

Help Documentation (Microsoft Docs)

Every developer needs to check documentation to see how a given piece of code works, how the language construct is written, etc. Microsoft has been putting a tremendous amount of effort into building Microsoft Docs for these kinds of things.

.NET is really well covered with tons of documentation and videos (.NET YouTube channel and Channel 9, just to name a few) that explain how things work, from the most basic to the most advanced level. Once we get to the main .NET doc page, we’re presented with the necessary links to jump into .NET easily.

The nice thing about Microsoft Docs is that it is open-source as well. It has its own GitHub repository that hosts everything. The community can contribute to the docs when something is wrong or missing. Take, for example, this .NET Tutorials page. If we scroll down to the bottom, we’ll see a section called Feedback and a link to see all the page feedback submitted so far. These will open @ GitHub where everything is tracked and monitored by Microsoft personnel to keep the doc quality excellent.

Showcase

As a success case and to better illustrate how .NET is used, there’s no better example than StackOverflow. It’s the most famous question & answer website for software developers and is ranked at position 52 globally on Alexa as of 2021. It launched in September 2008 and is built on top of the .NET platform. In 2016, the architecture lead shared some info about the site’s technologies being used in a series of posts titled Stack Overflow: The Architecture – 2016 Edition. We see the use of .NET 4.6.1 and ASP.NET MVC 5.2.3 amongst other supporting libraries that also use .NET behind the curtains. More recently, they made the move to .NET Core as described in this article: Stack Overflow Migrate Architecture from .NET Framework to .NET Core.

Conclusion

When we talk about .NET for software development, we’re speaking about a broad range of things. Applications can be developed using one of the multiple available programming languages, which are very feature-rich, being on par or even surpassing related programming languages like Java, Python, and the likes. Ultimately, this means decreased time to market as everything we need to develop is so well-integrated and of such good quality that transforming an idea into a product can be done very quickly.

The open source community used to dislike Microsoft, given the closed-source format used in its software development ecosystem which led many developers and companies to stray away from it as it was more expensive to build and host .NET apps due to software licensing costs. However, things have changed because of Microsoft’s move to the open source format and their closer relationship with the entire community. New features are being added with the participation of community members, and bug fixes are hitting developers’ hands way faster than they used to be, thanks to a more streamlined .NET release schedule. It’s important to understand that open source in this context does not mean a lack of quality. All code provided by the community through pull requests is really well tested and filtered by Microsoft maintainers before being merged into the main branch. This guarantees a very high quality.

So why would you choose .NET over any other framework? The most straightforward answer is that it provides everything needed and is highly integrated from start to end, allowing you to develop, deploy and maintain code easily. Its cross-platform nature allows your business logic to be ported to many different kinds of platforms with no trouble.