Download presentation
Presentation is loading. Please wait.
Published byHenry Gilbert Modified over 9 years ago
1
Dynamic Languages & The.Net Framework Shay Friedman ActionBase http://blogs.microsoft.co.il/blogs/shayf
2
בָבָא כֶל שַיו אָרְבֵה http://www.flickr.com/photos/ko_an/1472480778/
3
hru? gr8, i noe u <3 me, i luv u 2 SMS http://www.flickr.com/photos/qilin/527130002/
4
תמסור לקמב " ץ שיש אבט " ש בלת " מ חבל " ז בבח " א ! ושישכח מרבעו " ש ! http://www.flickr.com/photos/kikasso/1399327118/
6
Dynamic Languages & The.Net Framework Shay Friedman ActionBase http://blogs.microsoft.co.il/blogs/shayf
7
Agenda The Dynamic Languages World The Dynamic Language Runtime Dynamic Languages on Everyday Tasks The Future: Dynamic Capabilities in.Net 4.0 Q & A Summary
8
The Dynamic Languages World
10
DEMO Dynamic Languages Introduction
11
Dynamic Language Runtime Expression Trees Dynamic Dispatch Call Site Caching JavaScript Binder Object Binder Python Binder Ruby Binder COM Binder IronRubyIronPhytonC#VB.NetOthers…
12
Dynamic Language Runtime – LOLCODE HAI CAN HAS STDIO? I HAS A FISH ITZ "Yummy" VISIBLE FISH VISIBLE "HAI WORLD!" IM IN YR LOOP VISIBLE “LOOP!” KTHX KTHXBYE Code start Equivalent to: FISH = “Yummy”; Equivalent to: FISH = “Yummy”; Equivalent to: Console.WriteLine(“HAI WORLD!”); Equivalent to: Console.WriteLine(“HAI WORLD!”); Loop start Loop end Code end
13
DEMO Dynamic Languages with.Net
14
Dynamic Languages on Everyday Tasks
15
DEMO
16
Dynamic Capabilities in C# 4.0 נוּדְנִיק
17
Dynamic Capabilities in C# 4.0 Calculator calc = GetCalculator(); int sum = calc.Add(10, 20); 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); 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); ScriptObject calc = GetCalculator(); object res = calc.Invoke("Add", 10, 20); int sum = Convert.ToInt32(res); dynamic calc = GetCalculator(); int sum = calc.Add(10, 20); dynamic calc = GetCalculator(); int sum = calc.Add(10, 20); Statically typed to be dynamic Dynamic method invocation Dynamic conversion
18
Dynamic Capabilities in C# 4.0 public abstract class DynamicObject : IDynamicObject { public virtual object GetMember(GetMemberBinder info); public virtual object SetMember(SetMemberBinder info, object value); public virtual object DeleteMember(DeleteMemberBinder info); public virtual object UnaryOperation(UnaryOperationBinder info); public virtual object BinaryOperation(BinaryOperationBinder info, object arg); public virtual object Convert(ConvertBinder info); public virtual object Invoke(InvokeBinder info, object[] args); public virtual object InvokeMember(InvokeMemberBinder info, object[] args); public virtual object CreateInstance(CreateInstanceBinder info, object[] args); public virtual object GetIndex(GetIndexBinder info, object[] indices); public virtual object SetIndex(SetIndexBinder info, object[] indices, object value); public virtual object DeleteIndex(DeleteIndexBinder info, object[] indices); public MetaObject IDynamicObject.GetMetaObject(); } public abstract class DynamicObject : IDynamicObject { public virtual object GetMember(GetMemberBinder info); public virtual object SetMember(SetMemberBinder info, object value); public virtual object DeleteMember(DeleteMemberBinder info); public virtual object UnaryOperation(UnaryOperationBinder info); public virtual object BinaryOperation(BinaryOperationBinder info, object arg); public virtual object Convert(ConvertBinder info); public virtual object Invoke(InvokeBinder info, object[] args); public virtual object InvokeMember(InvokeMemberBinder info, object[] args); public virtual object CreateInstance(CreateInstanceBinder info, object[] args); public virtual object GetIndex(GetIndexBinder info, object[] indices); public virtual object SetIndex(SetIndexBinder info, object[] indices, object value); public virtual object DeleteIndex(DeleteIndexBinder info, object[] indices); public MetaObject IDynamicObject.GetMetaObject(); }
19
DEMO Dynamic Capabilities in C# 4.0
20
Q & A
21
Summary The Dynamic Languages World The Dynamic Language Runtime Dynamic Languages on Everyday Tasks The Future: Dynamic Capabilities in.Net 4.0 Try it yourself: http://blogs.microsoft.co.il/blogs/shayf http://blogs.microsoft.co.il/blogs/shayf
23
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.