Why Dynamic Language Runtime in CSharp?


In .Net 4.0 Microsoft built a new runtime on the top of CLR for supporting the dynamic programming languages. This new runtime is the DLR(Dynamic Language Runtime) , not only does the DLR allows the dynamic languages  like Ruby and Python to execute code on .net runtime but also allows statically types languages c# to pick up some dynamic language features.

Why Dynamic?

Computer science generally divides languages in two categories. We have dynamic languages (Javascript, Ruby, Python, PHP, and Perl) and we have static languages (C#, F#, Java, Haskell, C,C++). One thing keep in mind that the distinction to often blurred and fuzzy because some languages like C# have features that follows both categories .A dynamic generally is a language allow you to modify the code  and modify the types in the runtime. Dynamic languages like JavaScript, Ruby, and Python they do not have a traditional compiler or compilation face so they do not perform type checking until the program runs.If they perform type checking at all many dynamic languages automatically converts types at runtime to keep an application running. C# is the language on the other hand is a static language even they are talking about dynamic features of C#.It is traditionally a static language because all of the common idioms and patterns for C# revolve around the languages static features, we have the compiler, static type checking at compile time so the compiler will raise an error try to assign a string to an integer variable. Also in C# I can define a class with the property of type string
public class Customer
public string Name{get;set;}

One time when the compiler creating an assembly with these class definition every object I create using this class will have a property of type string. There is now way to change the objects to remove that property and add a new property without changing the definition in the source code in recompiling. The classes in the dynamic languages such as Ruby I can able to change objects instantiated from the class definition also I could remove properties and methods or add properties and methods. In fact most class based dynamic languages  will also be change definition of the class at runtime without recompiling and then all new objects created from the class definition will have the changes made dynamically.

Continuation Article 1 : dynamic keyword in C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s