How to Build a Shelf or the Differences between Language, Framework and Runtime

Differences between Language x Framework x Runtime

Introduction

When I first start in the programming world of modern languages those 3 things start to show up in every tutorial and documentation that I read. And even today I saw some developers struggle on those definitions. So, I thought that would be a good idea to write a really small article about those 3 things.

Frameworks

That might sound surprising for the new developers that were learning a new language, but the base and first thing of those 3 definitions, need to be the Framework.

Officially speaking the Framework is a set of Libraries/APIs. But you can think of it as a set of tools to accomplish your object. Imagine that you want to build a shelf. A good Framework would be one that gives you a saw, a hammer, a rule, a pencil… perfect tools to work with Wood and Nails. A not so good Framework would be one that gives you a solder, an anvil, a hammer… this one would be good to build metal things, but no to work with wood.

So, to choose the best Framework for your project, you need to think about what you want to accomplish. In the previous example, we want to build a shelf, so, the first Framework seems a reasonable choice. Bringing back to the development world, if I want to build a backend service, running microservices for example… .NET 5 would be a reasonable choice for example (of course it’s not the only one).

Languages

Ok, now that I have my Framework I can choose my Language. More than once you will see that the same framework can work on different languages. For example, on top of .NET 5 you can use C#, VB, F#… Confusing?

You can think the language as the material that you will use with your tools. In the last example we choose a Framework that allow us to work with wood. Great. But what kind of wood? Oak? Ash? Maple? We have different colors and resistances depending on the wood and of course some of them are more suitable to build a shelf than others, also your skills with some of them will be better than with others. So, we have a lot of tradeoffs when choosing the language, I mean, the wood… that we will work with.

Also, our toolbox have the basic tools, but we will probably need some others. Maybe a specific wood glue? Some paint and brushes? Those are not included in the Framework, we need to include in our project as dependencies and they may depends on the language/wood that we choose. Because of that, knowing beforehand the final objective of the project and the Framework is really important to also define our Language.

So, back to the development world, as we choose the wood tools Framework and the Maple wood to work with… we can choose the .NET5 Framework and the C# language to work with.

Runtime

Ok, we have now our Tools, our Wood Logs… we are ready to build!!! Well… actually no. You can of course build a shelf with what you have already… and it will be comparable with a developer opening Visual Studio, choosing “New Project”, choosing .NET 5, C# Console Project, writing a C# Hello World and pressing F5 to Run it. It will work. It will appear “Hello World” world in the Console. So… why I’m saying that the Framework and Language is not enough? Before I explain what happened when you press F5 on your Visual Studio, let’s go back for the shelf example for a moment.

You are with pencil and rule on hands, looking anxiously to all that wood, eager to start building your shelf. But what will be the width of the shelf? And the height? Well… that depends on the room that it will stay when it is ready, right? If your roof is 2m height you just can’t build a shelf that is 5m height, no matter how beautiful that would be. Also, if your room doesn’t have any kind of energy… you can’t add leds and other kind of illumination to your shelf that will depend on external energy, you will need to think about batteries or something like that. So, the room that your shelf will stay in the end matters a lot for your project.

Backing to the development world, the runtime is basically some software that will do the interface between the Framework, your software and the Operational System (OS, like Windows or Linux) that your project is running on. At the beginning, .NET Framework was a framework that runs only on Windows. Just few years ago Microsoft releases the .NET Core that would be cross environment and later the .NET 5, also a cross environment framework. But wait, we are talking about frameworks again? Well… yes. Actually, the runtime works side-by-side with the framework since it will kind connect the framework with the OS. Not surprisingly it also gets some names really similar with the frameworks. For example, we have the .NET 5 Framework and we also have the .NET 5 Runtime. You will use the .NET 5 SDK to develop using .NET 5 Framework and the .NET 5 Runtime to run .NET 5 applications. In our example, if you send the shelf to someone, the recipient won’t need the tools like the saw that you use to build the shelf …. just the room to keep the shelf (The runtime environment) and the already “modelled” wood in form of the shelf (The C# compiled program).

When you write a simple .NET 5, C# Console Hello World program, what Visual Studio is doing for you is providing also a basic and generic .NET 5 Runtime to test your program. It does not mean, for any reason that it will run the same way in EVERY environment. Think about it as you are building the shelf for a friend, but since it will be a surprise you are building the shelf in your own garage. Your garage may be 1,80m height while your friend’s office is 2,00m height. So, what fits in your garage will fit in your friend’s office, but you could do it a little higher if you knew the correct specifications before.

Conclusion

I took a lot of freedom defining something in this text (Yes, I won’t mention CLR and other things like that). But the idea here is to help the fresh developer to better understand some basic concepts that I really struggle to understand on modern languages at the beginning.

The other problem that you, as a fresh developer, may find is that the names gets a little confusing. But think about our example so far.

We have our Framework, that defines our tools. That will be our wood working tools and our .NET 5 Framework. To use it, we need to download the .NET SDK (What makes sense, right? A Software Development Kit will have the tools that we will need to work with .NET 5 Framework, some of them will also include a runtime environment for your tests!).

With the SDK, we will need the material that we will transform to the final project. In our example we will get a bunch of woods and logs and build a beautiful shelf using our SDK. Well, we will code a bunch of C# operators and objects to a beautiful program that do what we need using the .NET 5 SDK.

When we have our wood modeled in our beautiful shelf and our objects and operators built in our beautiful program, we can send it to our friends. They will open the room or download and install the .NET 5 Runtime, and will install our gift in their room our OS.

I really hope that this small article helped some of you to better understand the differences between Frameworks, Languages and Runtimes the same way I think that it would helped me when I start to develop on .NET years ago. But if some questions still remain or if you have some suggestions… please comment. I will be happy to answer or update this article :)

Just a average nomade developer