Using C# With .NET?

Rebels.io
3 min readFeb 17, 2021

When I first started programming C# .NET, I wondered if it was really necessary to use the .NET Framework. In order to answer this question, let’s first get a clear picture of what the C# and the .NET Framework entails:

What is the .NET framework?

The .NET Framework is part of the .NET Developer Platform. It consists of:

  • Common Language Runtime (CLR)
  • Base Class Libraries (BCL)
  • Application Framework (APIs)

What is C#?

“C# was developed around 2000 by Microsoft as part of its .NET initiative […] being one of the programming languages designed for the Common Language Infrastructure (CLI).”

C# is a programming language that gets compiled using Just In Time (JIT) compilation. This means that it gets compiled into an Intermediate Language (IL) first, and a Common Language Runtime (CLR) is needed to convert Intermediate Language into Native Machine Code. The CLR is platform dependent, as is the machine code it produces.

C# and .NET:

So now that we have defined what C# and .NET are, let’s make a complete picture of the above:

Compilation

Looking at the overall picture, we see that C# can be used without .NET. Still, we kind of get stuck after compilation because the CLR (that comes as part of the framework) is needed to convert Managed Code (referred to as Intermediate Language previously) to Native Machine Code, a crucial step to get to an executable program. I presume there are alternative ways to compile C# right into Native Machine Code, but if you do so, you would lose the Cross-platform capacity you have when using .NET Framework.

Framework Libraries

“A programming language is a formal language comprising a set of instructions that produce various kinds of output.”

This undoubtedly known definition of a programming language immediately makes me think of all those libraries that save me time. As mentioned before, the .NET Framework consists of many libraries. They can be divided into three groups according to Joseph Albahari and Eric Johanssen, authors of C# 8.0 in a nutshell: The Definitive Reference.

CoreLib

“[…] include C#’s built-in types as well as the basic collection classes, and types for stream processing, serialization, reflection, threading, and native interoperability.”

Base Class Libraries

“[…] providing features such as XML, JSON, networking, and Language-Integrated Query (LINQ)”

Application Framework APIs

“Sitting above this are application frameworks, which provide APIs for developing particular kinds of applications […]”

When creating a new C# .NET project in your IDE, you will at least find CoreLib and the Base Class Library assemblies in your project. Depending on your chosen project template (the kind of application) assemblies of the third group, Application Framework APIs will also be present.

By looking at the contents of CoreLib and BCL alone, we see things we use every day working with C# .NET and that I wouldn’t want to work without (and I don’t think I am alone here).

There is much more to say about what the libraries offer, but I would exceed this article’s purpose by doing so.

Conclusion

C# is a language that can be used without the libraries offered by .NET Framework. There are probably compilers that can compile C# directly into Native Machine Code. However, by doing so, you would lose considerable benefits: Your software is no longer cross-platform, and you will have to (re)create all libraries by yourself.

History also shows us that the intended use for C# is within the .NET Framework, and +20 years of effort has brought C# .NET where it is now.

As for me, I will happily continue to use C# the way it is intended: within the .NET Framework.

Sources:

--

--

Rebels.io

Rebels. Realize. Revolutions. Information Technology & Services based in Amsterdam. https://www.rebels.io/