dynamic: don’t be afraid - goto conferencegotocon.com/.../hadihariri_dynamicdontbeafraid.pdf ·...
TRANSCRIPT
![Page 1: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/1.jpg)
DYNAMIC: DON’T BE AFRAID
Hadi Hariri
JetBrains
![Page 2: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/2.jpg)
The What, the Why, the How
Agenda
![Page 3: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/3.jpg)
A tale as old as time…
A Tale as Old as Time...
![Page 4: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/4.jpg)
Static vs Dynamic
Static vs Dynamic
![Page 5: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/5.jpg)
Blog
Posts
Discussion
Threads
Blog Posts
and more blog
posts
![Page 6: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/6.jpg)
• Types can be implicit or explicit (var)
• Compiler Safety
• Early Binding
In the Static World
![Page 7: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/7.jpg)
• Types defined at runtime
• No Compiler (Usually)
• Late Binding
• Interpreted (Not always)
In a Dynamic World
![Page 8: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/8.jpg)
What Dynamic Developers think of Static Developers…
![Page 9: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/9.jpg)
I need my compiler!
![Page 10: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/10.jpg)
What Static Developers think of Dynamic Developers…
![Page 11: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/11.jpg)
http://nimblepros.com/products/software-craftsmanship-2012-calendar.aspx
![Page 12: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/12.jpg)
"You cannot build serious business applications in
dynamic languages"
![Page 13: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/13.jpg)
![Page 14: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/14.jpg)
![Page 15: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/15.jpg)
![Page 16: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/16.jpg)
They both have Good and Bad Things
![Page 17: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/17.jpg)
DLR & C# 4
![Page 18: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/18.jpg)
• dynamic keyword
• Classes/Binders and interfaces to work with
dynamic types
C# added...
![Page 19: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/19.jpg)
Hosting API Debugging API
Interop Binders Dynamic
Objects
Call-Site
Caching Expressions
Expression Compiler
/ Interpreter IL Code Generator
DLR added…
![Page 20: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/20.jpg)
DLR
IronRuby IronPython C# VB.NET
Bindings
.NET Ruby Python Office
The Big Picture
![Page 21: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/21.jpg)
http://www.flickr.com/photos/bitjungle
![Page 22: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/22.jpg)
GET YOUR STINKING
DYNAMIC TYPES OFF
OF MY STATIC
LANGUAGE
![Page 23: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/23.jpg)
IS THERE A NEED?
![Page 24: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/24.jpg)
Readability
![Page 25: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/25.jpg)
![Page 26: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/26.jpg)
Interoperability
![Page 27: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/27.jpg)
Interoperability with other languages
• IronPython
• Interpreted
• Can be compiled
• IronRuby
• Interpreted
• Your own language
![Page 28: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/28.jpg)
![Page 29: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/29.jpg)
![Page 30: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/30.jpg)
![Page 31: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/31.jpg)
DEMO
TALKING RUBY
![Page 32: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/32.jpg)
Interoperability
• Talking to COM
• Need a type-library beforehand
• Use Method Invocation
![Page 33: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/33.jpg)
DEMO
TALKING COM
![Page 34: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/34.jpg)
The Case of the DTO
![Page 35: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/35.jpg)
Creating Dynamic Objects in C#
![Page 36: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/36.jpg)
Options
• ExpandObject
• DynamicObject
• IDynamicMetaObjectProvider
![Page 37: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/37.jpg)
Expando Object
• Built-in Dynamic Object. Works out of the box
• Benefits over Dictionary
• More Fluent
• Support for Methods
• Supports Hierarchies
• Implements INotifyPropertyChanged
• Limitations • Index Access
![Page 38: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/38.jpg)
DEMO
ON THE FLY: BASICS OF DYNAMIC
![Page 39: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/39.jpg)
DEMO
EXPANDOS
![Page 40: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/40.jpg)
DynamicObject
• Moving Beyond an Expando
• Built-in class which implements IDynamicMetaObjectProvider
• Allows easy creation of Dynamic types
![Page 41: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/41.jpg)
DEMO
MVC – V IEWBAG, DYNAMICOBJECTSIMPLE
![Page 42: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/42.jpg)
IDynamicMetaObjectProvider
• Meta Object that performs binding
• Allows decoupling from class
• Uses DLR Expressions
• Returns DynamicObject
![Page 43: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/43.jpg)
DEMO
DYNAMICPROVIDER
![Page 44: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/44.jpg)
Undetermined API
![Page 45: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/45.jpg)
Aspects of MetaProgramming
• Adding / Removing Methods
• Creating Instance Methods
• Creating Static / Class Methods
• Query Classes
![Page 46: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/46.jpg)
![Page 47: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/47.jpg)
DEMO
DYNAMICMETHODMISSING – S IMPLE DATA
![Page 48: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/48.jpg)
Consuming the ever-changing
![Page 49: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/49.jpg)
DEMO
CONSUMINGJSON
![Page 50: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/50.jpg)
DSL's and Fluent API's
![Page 51: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/51.jpg)
A QUICK LOOK UNDER THE HOOD…
![Page 52: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/52.jpg)
The backbone of dynamic support
DLR
Language Semantics
via DLR EXpression
Define Late Binding
Logic
![Page 53: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/53.jpg)
DLR Expression
• Superset of Linq.Expression
• Common to multiple Languages
• DLR Expression is to DLR Languages what IL is to CLR languages
C# VB.NET
IL
CLR
IronPython IronRuby
DLR Expression
DLR Runtime
![Page 54: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/54.jpg)
Late Binding
• We only know the types at runtime
• We have to figure out how to call those methods at runtime
• It’s not embedded in the “IL”
• It’s potentially slower
![Page 55: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/55.jpg)
Late Binding
• Using Binders and Call Sites
• Using Dynamic Expression (uses former internally)
![Page 56: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/56.jpg)
Late Binding
![Page 57: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/57.jpg)
DEMO
DYNAMICCONVERSION
![Page 58: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/58.jpg)
SUMMING UP…
![Page 59: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/59.jpg)
The Disadvantages
• There is no compile type-checking*
• Potentially slower (even with caching)
• There is no Intellisense*
* Partially incorrect – It’s about the tooling
![Page 60: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/60.jpg)
Reasons to not not use dynamic
![Page 61: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/61.jpg)
Reasons to not not use dynamic
• There’s no compiler
• There’s no intellisense (Emphasis on Unit Tests)
• You shouldn’t mix dynamic and static languages
![Page 62: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/62.jpg)
Reasons to use dynamic
![Page 63: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/63.jpg)
Reasons to use Dynamic
• Interoperability • COM
• Consuming Dynamic Languages • Ruby
• JavaScript
• Fluent API’s and DSL
• Consuming the *unknown*
• Dynamic Structures
• Avoiding unnecessary “class explosion”
![Page 64: DYNAMIC: DON’T BE AFRAID - GOTO Conferencegotocon.com/.../HadiHariri_DynamicDontBeAfraid.pdf · DEMO ON THE FLY: BASICS OF DYNAMIC . DEMO EXPANDOS . DynamicObject •Moving Beyond](https://reader035.vdocuments.us/reader035/viewer/2022071020/5fd3d4e618e06b753e273b17/html5/thumbnails/64.jpg)
Thank you