dynamic languages for .net clr

22
Dynamic Languages for .NET CLR

Upload: pysunil

Post on 15-May-2015

1.336 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Dynamic languages for .NET CLR

Dynamic Languages for .NET CLR

Page 2: 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

Page 3: Dynamic languages for .NET CLR

BrieflyChanging types at runtimeNo types at allGenerate code at runtimeSimplified deployment

Page 4: Dynamic languages for .NET CLR

Where Dynamic Languages fit

Rapid prototype developmentBetter string processing capabilities

Page 5: Dynamic languages for .NET CLR

Dynamic VS StaticDynamic

Languages

Simple & Easy to Learn

Late bound

Highly Expressive

No compilation

StaticLanguages

Type safety

Runtime Performance

Compile-time checking

Intelligent tools

Page 6: Dynamic languages for .NET CLR

Dynamic Languages on .NET

Dynamic Language Runtime

Iron Python

Iron Ruby

C# Others…

.NET CLR

Page 7: Dynamic languages for .NET CLR

Is C# dynamic language..?

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

Page 8: Dynamic languages for .NET CLR

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

Page 9: Dynamic languages for .NET CLR

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

Page 10: Dynamic languages for .NET CLR

DLR Website

http://dlr.codeplex.com/

Page 11: Dynamic languages for .NET CLR

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

Page 12: Dynamic languages for .NET CLR

Current StatusDLR 1.0Iron Python 2.7.2.1IronRuby 1.1.3

Page 13: Dynamic languages for .NET CLR

IronPythonIronPython Websitehttp://ironpython.codeplex.com/

Page 14: Dynamic languages for .NET CLR

IronPython vs CPythonIronPython

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

CPythonWritten in CWorks Python VMProduces Python Byte CodeModules

Page 15: Dynamic languages for .NET CLR

Tools to Develop IronPython

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

Page 16: Dynamic languages for .NET CLR

Iron Python Shell

Page 17: Dynamic languages for .NET CLR

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

Page 18: Dynamic languages for .NET CLR

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

Dynamic%20Language%20Support

Demo

Page 19: Dynamic languages for .NET CLR

What about LinuxIron Python can run on LinuxMono

Page 20: Dynamic languages for .NET CLR

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

Page 21: Dynamic languages for .NET CLR

Dynamic Languages in Java Java 223 SpecificationJython

Page 22: Dynamic languages for .NET CLR

Real world example

http://Ironserver.codeplex.com