DEV Community

Cover image for What really is the .NET framework?
Thanh Truong
Thanh Truong

Posted on • Edited on • Originally published at underthehoodlearning.com

What really is the .NET framework?

In this first part of this series, we'll explore the .NET Framework at the high level. We will:

  • Learn what a framework is
  • Learn what the .NET framework is all about and its components
  • Explore a brief history behind the creation of the .NET framework

What is a framework?

A framework is a software model for development of software applications. A framework has defined open or unimplemented functions or objects that can be selectively overridden to provide the desired functionality of the application. A software framework is made up of one or many components:

  • Programs and shared code libraries that developers can call when developing applications so that they don't have to write the code from scratch.
  • Application Programming Interfaces (APIs) to ensure all different components can interact with each other.

A software framework is an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software.

platform-tech

The purpose is to allow developers to dedicate their efforts to the application's specific requirements rather than having to reinvent the wheel every time their applications need to perform some common function. Instead, they can focus on the code that is unique to their applications and the user interface that ties it all together.

For example, let's say your application needs to be able to ping another IP address on the network. Instead of writing that piece of code yourself, you can use code from the shared library that performs that same function.

Using a framework also helps provide standards between applications. Other developers can make sense of what a program is doing more easily and users of the applications can count on things like Open and Save As dialog boxes working the same in different applications.

Frameworks take the form of libraries, where a well-defined API is reusable, but it's important to acknowledge that a framework is different from a library.
Now that we understand what a framework is, what is the .NET framework then?

What is the .NET framework?

.NET is a software development framework and an accompanying ecosystem of tools, languages, and runtime that is designed and developed by Microsoft to ease application development across various platforms, from desktops to mobile devices. In a nutshell, it is a virtual machine for compiling and executing programs written in different languages such as C#, VB.NET, etc.

For the remainder of this article, we will use the term ".NET" to refer to the entire .NET platform in general. As you shall learn below, Microsoft uses the term ".NET Framework" to refer to their own longstanding implementation of the .NET standard, which is one of the three "flavors" of .NET and exclusively focuses on Windows.

The image below shows the main components of the .NET framework.

20181002-.NET-Explanation

There are currently three flavors of .NET shown as the top layer in the above image.

  • .NET Framework is the "full" or "traditional" flavor of .NET that's distributed with Windows. Use this when you're building a desktop Windows app or working with ASP.NET 4.5/4.6.
  • .NET Core is the cross-platform .NET that can run on Windows, Macs, and Linux. Use this when you need to build applications that can run on any platform.
  • Xamarin (Mono) is used for building mobile apps that can run on iOS, Android, or Windows Phone devices.
  1. Common Infrastructure This is the base layer of components that enable the entire ecosystem to actually execute in practice, from compliers to languages to runtime components. Code written in any .NET language is compiled to an intermediate bytecode language called the Common Intermediate Language (CIL). CIL code isn't human-readable, but can be ported across operating systems and platforms. The CIL is then compiled again by the Common Language Runtime (CLR). CLR implementations are platform-specific, and they compiled CIL code into machine-readable code that can be executed on the platform at that moment. In the process of creating local machine-readable code, the CLR also manages a lot of low-level application functionality, such as garbage collection and threading that is crucial to the app performance but is tedious for developers to deal with. I wrote two other articles discussing the CIL and CLR in more details. If you're interested in learning how these work under the hood, check them out following the links below:
  2. .NET Standard Library The .NET Standard is a specification for the .NET platform. The purpose of the standard is to solve the code sharing problem for .NET developers across all platforms by defining a specification that all platforms will be able to use. In short, .NET Standard is a set of APIs, that all .NET platforms have to implement. Why do we need standards? The .NET platform was forked quite a bit over the years. Although this is actually a really good thing as it allowed tailoring the .NET to fit the needs of multiple platforms, this forking poses a massive problem for developers writing code for multiple .NET platforms because there isn't a unified class library to target. This is where the .NET Standard comes in. For developers, this means that they only have to master one base class library. Libraries targeting .NET Standard will be able to run on all .NET platforms. And platform providers don't have to guess which APIs they need to offer in order to consume the libraries available on NuGet. The .NET Standard Library is the set of fundamental APIs (commonly referred to as Base Class Library (BCL) that all .NET implementations must implement. The BCL is the set of fundamental APIs that are independent of UI frameworks and application models. It includes the components that will form the infrastructure for just about any application you'd write - classes and types that are helpful in performing day to day tasks like dealing with strings and primitives, creating database connections, performing I/O operations, etc. A good analogy to help understand the difference between .NET Standard and .NET implementations (.NET Framework, .NET Core, Xamarin) is that of HTML and browsers. Think of HTML Specification as the .NET Standard and the different browsers as the .NET implementations.
  3. App Models We don't use the .NET Standard directly. However, we benefit from it indirectly. The .NET Standard ensures that all .NET platforms share the same API shape for the base class library. Once you learn how to use it in your desktop application, you know how to use it i your mobile application or your cloud service. Also, with the .NET Standard, most class libraries will become available everywhere, which means the consistency at the base layer will also apply to the larger .NET library ecosystem. An app model in the context of the Microsoft .NET platform, is all the framework components that are specific to a certain type of app. It typically includes classes, interfaces, unit tests, configurations, etc. For example, the Windows Forms app model would include all the code that you use to create a desktop client Windows application (form, Button, Label).

How was the .NET framework created?

Microsoft started working on the .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
  • ADO.NET: used for data access

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.

In 2016, Microsoft acquired Xamarin, previously a proprietary technology for cross-platform mobile development, making it open source as well.

In May 2019, Microsoft announced the big release that unified the whole ecosystem. All .NET products was bundled in the .NET 5 development platform allowing developers to build applications on Windows, Linux, macOS, iOS, watchOS, Android, tvOS, or using Web Assembly with just a single .NET.

For the remainder of this series, we will focus on the .NET Core platform. But first, let's take a peek "under the hood" (😉) to explore how the compiler builds your code. Before your code (written in any .NET language) can be executed by the computer, it needs to be compiled first. So, let's do that in the next two articles.

Top comments (0)