 Jim Hugunin Partner Architect Microsoft Corporation TL10.

Slides:



Advertisements
Similar presentations
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Taylor Brown Test Lead Microsoft Corporation ES09.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
 Anders Hejlsberg Technical Fellow Microsoft Corporation TL16.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Ken Casada Developer Evangelist Microsoft Switzerland
Bart J.F. De Smet Software Development Engineer Microsoft Corporation Session Code: DTL304.
Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Douglas K. Olson General Manager Microsoft Corporation  Pete Blois Lead Program Manager Microsoft Corporation PC47.
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
 Phil Haack Senior Program Manager Microsoft Corporation PC21.
 Nishant Gupta Program Manager Live Services Microsoft Corporation BB51.
Co- location Mass Market Managed Hosting ISV Hosting.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Gurinder CTO. Lisa Feigenbaum Microsoft Program Manager Visual Studio Languages
demo video demo Dynamic Languages Simple and succinctImplicitly typedMeta-programmingNo compilation Static Languages RobustPerformantIntelligent.
Microsoft Application Virtualization (App-V)
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Rico Mariani Architect Microsoft Corporation.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Chaitanya Sareen Senior Program Manager Microsoft Corporation PC24.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Print Remaining Documents © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Connect with life Connect with life
Dynamic Languages & The.Net Framework Shay Friedman ActionBase
Alex Turner C# Compiler PM Session Code: DEV402 On the Dynamic menu today… The Dynamic Language Runtime How does it relate to the CLR? Dynamic in C#
Calculator calc = GetCalculator(); int sum = calc.Add(10, 20); Calculator calc = GetCalculator(); int sum = calc.Add(10, 20); object calc.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Suggested Item Enhancements – Sales Script and Additional Information © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
 Paul Vick Principal Architect Microsoft Corporation  Lucian Wischik Software Engineer Microsoft Corporation.
Feature: Employee Self Service Timecard Entry © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

Lisa Feigenbaum Microsoft Program Manager Session Code: DEV314.
customer.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
Feature: Void Historical/Open Transaction Updates © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
The CLR CoreCLRCoreCLR © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
 Boris Jabes Program Manager Lead Microsoft Corporation TL13.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

IoCompleteRequest (Irp);... p = NULL; …f(p);
Luke Hoban Senior Program Manager Microsoft Session Code: DTL310.
Visual Studio 2010 and.NET Framework 4 Training Workshop.
MIX 09 4/17/2018 4:41 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Using Dynamic Languages to Build Scriptable Apps
C# in the Big World Mads Torgersen Program Manager
Возможности Excel 2010, о которых следует знать
Tech·Ed North America /18/2018 5:14 PM
Title of Presentation 11/22/2018 3:34 PM
An Introduction To Microsoft F#
Title of Presentation 12/2/2018 3:48 PM
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
4/27/17, Bell #8 What amount of net pay has been earned this period?
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
PENSACOLA ENERGY WORK PLAN OCTOBER 10, 2016
Title of Presentation 5/12/ :53 PM
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
5/24/2019 6:44 PM 1/8/18 Bell #10 In a world governed by the gods, is there any room for human will? Do human choices make a difference? EXPLAIN © 2007.
Title of Presentation 7/24/2019 8:53 PM
Presentation transcript:

 Jim Hugunin Partner Architect Microsoft Corporation TL10

By: public.resource.org

Python Binder Ruby Binder COM Binder JavaScript Binder Object Binder Dynamic Language Runtime Expression Trees Dynamic Dispatch Call Site Caching IronPython IronRuby C# VB.NET Others…

IronPython0.1 Python2.3 IronPython1.0Python2.5 Python2.1 46K 90K 80K 50K 36K

#include typedef struct { PyObject_HEAD PyObject *first; /* first name */ PyObject *last; /* last name */ int number; } Noddy; static PyTypeObject noddy_NoddyType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "noddy.Noddy", /*tp_name*/ sizeof(noddy_NoddyObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ 0, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ "Noddy objects", /* tp_doc */ }; static PyMethodDef noddy_methods[] = { {NULL} /* Sentinel */ }; #ifndef PyMODINIT_FUNC/* declarations for DLL import/export */ #define PyMODINIT_FUNC void #endif PyMODINIT_FUNC initnoddy(void) { PyObject* m; noddy_NoddyType.tp_new = PyType_GenericNew; if (PyType_Ready(&noddy_NoddyType) < 0) return; m = Py_InitModule3("noddy", noddy_methods, "Example module that creates an extension type."); Py_INCREF(&noddy_NoddyType); PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType); } static void Noddy_dealloc(Noddy* self) { Py_XDECREF(self->first); Py_XDECREF(self->last); self->ob_type->tp_free((PyObject*)self); } static PyObject * Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { Noddy *self; self = (Noddy *)type->tp_alloc(type, 0); if (self != NULL) { self->first = PyString_FromString(""); if (self->first == NULL) { Py_DECREF(self); return NULL; } self->last = PyString_FromString(""); if (self->last == NULL) { Py_DECREF(self); return NULL; } self->number = 0; } return (PyObject *)self; } static int Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { PyObject *first=NULL, *last=NULL, *tmp; static char *kwlist[] = {"first", "last", NULL}; if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist, &first, &last)) return -1; if (first) { tmp = self->first; Py_INCREF(first); self->first = first; Py_XDECREF(tmp); } if (last) { tmp = self->last; Py_INCREF(last); self->last = last; Py_XDECREF(tmp); } return 0; } static PyMemberDef Noddy_members[] = { {"first", T_OBJECT_EX, offsetof(Noddy, first), 0, "first name"}, {"last", T_OBJECT_EX, offsetof(Noddy, last), 0, "last name"}, {NULL} /* Sentinel */ }; static int Noddy_init(Noddy *self, PyObject *args, PyObject *kwds) { PyObject *first=NULL, *last=NULL, *tmp; static char *kwlist[] = {"first", "last", NULL}; if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OO", kwlist, &first, &last)) return -1; if (first) { tmp = self->first; Py_INCREF(first); self->first = first; Py_XDECREF(tmp); } if (last) { tmp = self->last; Py_INCREF(last); self->last = last; Py_XDECREF(tmp); } return 0; }

namespace noddy { public class Noddy { public string first, last; public Noddy(string first, string last) { this.first = first; this.last = last; }

Python Objects C-Based Objects C-Based Objects py1 c2

.NET Objects py1 c2

TL44: IronRuby: The Right Language for the Right Job John Lam in Room 515B Today at 5:15PM – Just after this talk!

.NET ?.? DLR2.NET 4.0.NET 3.5 LINQ DLR.NET 2.0.NET 1.0 GC BCL Reflection JIT Generics In Runtime Generics In Runtime Expression Trees Expression Trees Extension Methods Extension Methods Expression Trees v2 Expression Trees v2 Call Site Caching Dynamic Dispatch Dynamic Dispatch Dynamic Codegen Dynamic Codegen Verifier Sandbox Verifier Sandbox Silverlight Fast Delegates Fast Delegates Dynamic Methods Dynamic Methods Script Hosting Compiler as a Service Compiler as a Service ???

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

Object Binder Python Binder Ruby Binder COM Binder Dynamic Language Runtime GetMember Name=“Foo”, IgnoreCase=false GetMember IronPython x.Foo IronPython x.Foo IronRuby x.Foo IronRuby x.Foo C# x.Foo C# x.Foo VB.NET x.Foo VB.NET x.Foo Others… $x{Foo}, … Others… $x{Foo}, … Your Binder

ActionPythonRubyC#VB.NET GetMember x.Foo SetMember x.Foo = y DeleteMember del d.Foo x.send :remove_instance_variable No syntax UnaryOperation -x BinaryOperation x + y Convert No syntax (Foo)xCType(x,Foo) InvokeMember x.Foo(a,b) 2 x.Foo(a,b) Invoke x(a,b)x.call(a,b) 1 x(a,b) CreateInstance X(a,b)X.new(a,b)new X(a,b) Not dynamic New X(a,b) Not dynamic GetIndex x[a,b] x(a,b) SetIndex x[a,b] = y X(a,b) = y DeleteIndex del x[a,b]No syntax 1: Calling a proc rather than a method; 2: this is always a GetMember followed by a Invoke

public abstract class DynamicObject : IDynamicObject { public virtual object GetMember(GetMemberBinder info){…} public virtual void SetMember(SetMemberBinder info, object value){…} public virtual void 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 void SetIndex(SetIndexBinder, object[] indices, object value){…} public virtual void DeleteIndex(DeleteIndexBinder info, object[] indices){…} public MetaObject IDynamicObject.GetMetaObject() { … } }

Return If Parameter n Parameter n Constant 0 Constant 0 BinaryOp - BinaryOp - BinaryOp == BinaryOp == MethodCall Program.fact MethodCall Program.fact BinaryOp * BinaryOp * Constant 1 Constant 1 Parameter n Parameter n Parameter n Parameter n Constant 1 Constant 1 Return static int fact(int n) { if (n == 0) { return 1; } else { return n * fact(n - 1); }

Return If Parameter n Parameter n Constant 0 Constant 0 Dynamic CSharpOp[-] Dynamic CSharpOp[-] Dynamic CSharpOp[==] Dynamic CSharpOp[==] MethodCall Program.fact MethodCall Program.fact Dynamic CSharpOp[*] Dynamic CSharpOp[*] Constant 1 Constant 1 Parameter n Parameter n Parameter n Parameter n Constant 1 Constant 1 Return static dynamic fact(dynamic n) { if (n == 0) { return 1; } else { return n * fact(n - 1); }

def fact(n): if n == 0: return 1 else: return n * fact(n - 1) Return If Parameter n Parameter n Constant 0 Constant 0 Dynamic PythonOp[-] Dynamic PythonOp[-] Dynamic PythonOp[==] Dynamic PythonOp[==] Dynamic PythonInvoke Dynamic PythonInvoke Dynamic PythonOp[*] Dynamic PythonOp[*] Constant 1 Constant 1 Parameter n Parameter n Parameter n Parameter n Constant 1 Constant 1 Return Property Value Property Value Field $global.fact Field $global.fact

def fact(n) if n == 0 1 else n * fact(n - 1) end If Parameter n Parameter n Constant 0 Constant 0 MethodCall Ruby.IsTrue MethodCall Ruby.IsTrue Dynamic RubyOp[-] Dynamic RubyOp[-] Dynamic RubyOp[==] Dynamic RubyOp[==] Dynamic RubyCall[fact] Dynamic RubyCall[fact] Dynamic RubyOp[*] Dynamic RubyOp[*] Parameter self Parameter self Constant 1 Constant 1 Parameter n Parameter n Parameter n Parameter n Constant 1 Constant 1

x * 2 Assume x = 2,000,000,000 In Python x * 2 = 4,000,000,000 In Ruby x * 2 = 4,000,000,000 My 7 year old daughter x * 2 = 4,000,000,000 In C# x * 2 = -294,967,296 //typed as int Or OverflowException //checked Or 4,000,000,000 //typed as long

static CallSite > _site = …; if (_site.Target(_site, x, 0)) { … } if (x == 0) { … } static bool _0(Site site, object x, int y) { return site.Update(site, x, y); //tailcall }

static CallSite > _site = …; if (_site.Target(_site, x, 0)) { … } if (x == 0) { … } static bool _1(Site site, object x, int y) { if (x is int) { return (int)x == y; } else { return site.Update(site, x, y); //tailcall }

static CallSite > _site = …; if (_site.Target(_site, x, 0)) { … } if (x == 0) { … } static bool _2(Site site, object x, int y) { if (x is int) { return (int)x == y; } else if (x is BigInteger) { return BigInteger.op_Equality((BigInteger)x, y); } else { return site.Update(site, x, y); //tailcall }

Generic Update Generic Update Target Test Parameter x Parameter x BinaryOp == BinaryOp == TypeIs int TypeIs int Cast int Cast int Parameter y Parameter y Parameter x Parameter x If Field Update Field Update MethodCall Invoke MethodCall Invoke Parameter site Parameter site Parameter x Parameter x Parameter y Parameter y

Parameter x Parameter x BinaryOp == BinaryOp == TypeIs int TypeIs int Cast int Cast int Parameter y Parameter y Parameter x Parameter x If Field Update Field Update MethodCall Invoke MethodCall Invoke Parameter site Parameter site Parameter x Parameter x Parameter y Parameter y Parameter x Parameter x MethodCall Op_Equality MethodCall Op_Equality TypeIs BigInteger TypeIs BigInteger Cast BigInteger Cast BigInteger Parameter y Parameter y Parameter x Parameter x If

MetaObject Target Test Parameter x Parameter x BinaryOp == BinaryOp == TypeIs int TypeIs int Cast int Cast int Parameter y Parameter y Parameter x Parameter x

Test Parameter x Parameter x TypeIs List TypeIs List Target Property Count Property Count Cast List Cast List Parameter x Parameter x Test Parameter x Parameter x TypeIs DynamicObject TypeIs DynamicObject Target MethodCall GetMember MethodCall GetMember Cast DynamicObject Cast DynamicObject Constant GetMemberBinder(“Count”) Constant GetMemberBinder(“Count”) Parameter x Parameter x

Target Test Parameter x Parameter x Property Slot0 Property Slot0 TypeIs FastBag TypeIs FastBag Cast FastBag Cast FastBag Parameter x Parameter x

public abstract class MetaObject { public Restrictions Restrictions { get; } public Expression Expression { get; } public virtual MetaObject BindGetMember(GetMemberBinder info){…} public virtual MetaObject BindSetMember(SetMemberBinder info, MetaObject value){…} public virtual MetaObject BindDeleteMember(DeleteMemberBinder info){…} public virtual MetaObject BindUnaryOperation(UnaryOperationBinder info){…} public virtual MetaObject BindBinaryOperation(BinaryOperationBinder info, MetaObject arg){…} public virtual MetaObject BindConvert(ConvertBinder info){…} public virtual MetaObject BindInvoke(InvokeBinder info, MetaObject[] args){…} public virtual MetaObject BindInvokeMember(InvokeMemberBinder info, MetaObject[] args){…} public virtual MetaObject BindCreateInstance(CreateInstanceBinder info, MetaObject[] args){…} public virtual MetaObject BindGetIndex(GetIndexBinder info, MetaObject[] indices){…} public virtual MetaObject BindSetIndex(SetIndexBinder, MetaObject[] inds, MetaObject value){…} public virtual MetaObject BindDeleteIndex(DeleteIndexBinder info, MetaObject[] indices){…} }

Parameter z Parameter z BinaryOp == BinaryOp == TypeIs int[] TypeIs int[] Constant Map Function Constant Map Function Parameter x Parameter x AndAlso Parameter y Parameter y TypeIs Func TypeIs Func map(f, my_ints)

Python Binder Ruby Binder COM Binder JavaScript Binder Object Binder Dynamic Language Runtime Expression Trees Dynamic Dispatch Call Site Caching IronPython IronRuby C# VB.NET Others…

Please fill out your evaluation for this session at: This session will be available as a recording at:

© 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.