Yes. Many of us will ask the question, what the hell is this? Well, these are MS short-forms for various runtimes. Visual Basic Runtime (MSVBRUN), Visual C++ Runtime (MSVCRT), .NET Common Language Runtime (MSCOREE and MSCORWKS). There are many more runtimes, like Java Runtime Environment (JRE) and alike.

But what is Runtime?
As computers can only understand Zero and One, it becomes tedious to write programs using these bits. Just imagine writing a Notepad or WordPad using 0s and 1s. So, we have so called programming languages like C/C++, VB, Java which allows us to write applications and business logic in developer readable form. Once these applications are written in any of these languages, these applications are compiled into ‘Object Code’ or sometimes ‘Intermediate Code’. However, still these machines are so dumb that they can’t understand this code. So, we need some kind of translator, who can convert the object code into binary which can be understood by these machines. So, basically runtime converts the compiled object code into 0s and 1s and machines executes the command.
But, this is just a small part of these Runtimes. Apart from this code execution, some runtimes are smart enough to provide various services. Below mentioned are some of the services provided by .NET CLR

  1. Automatic Memory Management:
    This is like a waiter in a hotel. He’ll first put empty dishes in front of us to serve food (for example, ‘allocation’ for resources) and will clean the table by removing those dishes after use (which is called Garbage Collection).
  2. Cross Language Support:
    It is just like having your own translator who understands all the languages under the sun. Which simply means, using CLR (and with the help of Common Type System in .NET), developers can easily call, debug, handle exceptions in any .NET supported language without a hassle. That is – language interoperability is possible between C#, VB.NET, etc… without writing any special code.
  3. Security Provisioning:
    CLR also provides a features called Code Access Security [or CAS in MS terms :) ], which checks the code for vulnerability and permissions it has been granted, before it actually executes it. So, if I give you one EXE which is a screen-saver but behind scene it is formatting a hard-drive. Using CAS, you’ll get warning about such behaviour of the code. And you’ll be saved :)
But now, with .NET Fx 4.0, MS is introducing a new term ‘DLR’.
DLR is nothing but Dynamic Language Runtime. Just like CLR helps to execute and manage execution of ‘statically typed languages’ like C# and VB.NET, DLR will help to execute and manage ‘dynamically typed languages’. There are many dynamic languages and we’ve seen and using one dynamic language since a long time. Remember JavaScript? Where var was dynamic. One facet of dynamic languages is they can identify or discover objects during runtime, whereas in case of statically typed languages developers need to define all the types well in advance (i.e. during design time). In case of JS, the variable var can decide the type of object during runtime or execution. e.g.
var x = "5";

alert(typeof x);

image

Just like that, now .NET supports new languages - IronRuby and IronPython. But, why do we need these languages? What SO dynamic in it?

As MSDN states, following are the advantages of dynamic languages:

  • The ability to use a rapid feedback loop (REPL, or read-evaluate-print loop). This lets you enter several statements and immediately execute them to see the results.


  • Support for both top-down development and more traditional bottom-up development. For example, when you use a top-down approach, you can call functions that are not yet implemented and then add underlying implementations when you need them.


  • Easier refactoring and code modifications, because you do not have to change static type declarations throughout the code.
But, this doesn’t mean that C# and VB are out of business now. Rather,  DLR has provided  ‘dynamic’ type to C# and VB to support dynamic behaviour in these languages. Now, existing .NET languages C# and Visual Basic can create dynamic objects and use them together with statically typed objects. For example, C# and Visual Basic can use dynamic objects for HTML, Document Object Model (DOM), and .NET reflection.

As of now, DLR sits on top of CLR and provides facilities to languages like IronRuby, IronPython, C# and VB.NET.

Because of DLR, there many more opportunities for developers. Its going to provide new ways to address different issues, provide more flexible (or should I say ‘dynamic’) way to write code and build rapid applications.

Resources:
  1. Complete documentation about DLR is available at CodePlex.
  2. MSDN Magazine Article on DLR: here
  3. MSDN library documentation about DLR: here

Share Related Posts with Thumbnails
blog comments powered by Disqus