dynamic languages for .net clr

Post on 15-May-2015

1.337 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Dynamic Languages for .NET CLR

Dynamic programming languagesIn the broadest sense of the word

Dynamic programming language is a term used broadly in computer science to describe a class of high-level programming languages that execute at runtime many common behaviors that other languages might perform during compilation, if at all. These behaviors could include extension of the program, by adding new code, by extending objects and definitions, or by modifying the type system, all during program execution.

Source: Wikipedia

BrieflyChanging types at runtimeNo types at allGenerate code at runtimeSimplified deployment

Where Dynamic Languages fit

Rapid prototype developmentBetter string processing capabilities

Dynamic VS StaticDynamic

Languages

Simple & Easy to Learn

Late bound

Highly Expressive

No compilation

StaticLanguages

Type safety

Runtime Performance

Compile-time checking

Intelligent tools

Dynamic Languages on .NET

Dynamic Language Runtime

Iron Python

Iron Ruby

C# Others…

.NET CLR

Is C# dynamic language..?

Yes..optionally.. New dynamic keyword in C# 4.0

Dynamic VS Object dynamic dyn = 1;

object obj = 1;

//NOT MUCH DIFFERENCE System.Console.WriteLine(dyn.GetType()); System.Console.WriteLine(obj.GetType());

dyn = dyn + 3; obj = obj + 3; // THROWS ERROR //obj = (int)obj + 3;

More Readable Code

The Dynamic Type in C#

Calculator calc = GetCalculator();int sum = calc.Add(10, 20);

object calc = GetCalculator();Type calcType = calc.GetType();object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 });int sum = Convert.ToInt32(res);

ScriptObject calc = GetCalculator();object res = calc.Invoke("Add", 10, 20);int sum = Convert.ToInt32(res);

dynamic calc = GetCalculator();int sum = calc.Add(10, 20);

Statically typed to be

dynamic

Dynamic method

invocation

Dynamic conversion

DLR Website

http://dlr.codeplex.com/

Microsoft VisionImplemented as Iron Languages

Iron Python, Iron RubyAll languages run on .NET runtimeEasy to use .NET librariesEasy to use other .NET languagesEasy to use in .NET hostsEasy to use with .NET tools

Current StatusDLR 1.0Iron Python 2.7.2.1IronRuby 1.1.3

IronPythonIronPython Websitehttp://ironpython.codeplex.com/

IronPython vs CPythonIronPython

Written in C#Works with .NET VMProduces IL codeAssemblies, Modules

CPythonWritten in CWorks Python VMProduces Python Byte CodeModules

Tools to Develop IronPython

Python Tools for Visual Studiohttp://pytools.codeplex.com/

Iron Python Shell

Exploring Iron PythonDemo

Using .NET Class Libraries(HelloWorld example)

Using C# DLL in Iron Python(Extending Iron python with C#)

Embedding Iron Python in C#Windows Forms

ASP.NET Iron Python http://aspnet.codeplex.com/wikipage?title=

Dynamic%20Language%20Support

Demo

What about LinuxIron Python can run on LinuxMono

How to ContributeBoth Iron Python and DLR are open source projects

Iron Python Project will accept source code and bugs

DLR is just open source

Dynamic Languages in Java Java 223 SpecificationJython

Real world example

http://Ironserver.codeplex.com

top related