What is managed code?

Asked

Viewed 248 times

5

In a conversation with a co-worker about what language was used to develop Windows, he said that many parts should still be developed in C and C++, as it was necessary to run unmanaged code. Other parts are already developed in C#. Hence the doubt arose: what differentiates managed code from unmanaged and which application of each of them?

1 answer

5


Windows is essentially built with C and most of the newer Apis are in C++, with some compatibility with C. There’s nothing important about Windows that uses . NET, it can be completely uninstalled. It’s a myth to think that Microsoft is developing almost everything in C#. It makes sense to her.

The . NET is a platform that Microsoft created to give more security and flexibility in software development. I even had the intention of moving everything to . NET, but it was unviable. NET is an implementation of several technologies, among them the Runtime called the Common Language Runtime. That one Runtime manage the execution, execution permissions, and memory used. As much as the programmer wants to do insecure and/or problematic things in his code, the platform does not let, everything has to go through it and it manages what is possible to do, so it is called managed code.

The most obvious form of management is the Garbage Collector that controls all memory allocations and releases, it takes for itself the memory management.

It is possible to have implementations that rely only on GC management. So, strictly speaking, the managed code is the one that uses GC to take care of the memory, while the unmanaged one allows you to do what you want with the memory.

Some people may think of other things, but you still have managed code even if it’s native, even if you don’t have one Jitter, one CAS, and other technologies.

Note that . NET is very important to Microsoft and a lot of application stuff is being done for you to use, but nothing on core operating system. Even now they have disassociated . NET from OS.

Related: What is marshalling and how it works?.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.