SlideShare uma empresa Scribd logo
1 de 28
by @AntyaDev
DYNAMIC C#
STATIC VS DYNAMIC
The many faces of “dynamic”
Generate code
at runtime
Changing types
at runtime
No types
at all
Simplified
deployment
• Trend on non-schematized data
• Remember WSDL, SOAP, XSD?
• How about REST, JSON?
• The next browser war
• JavaScript on the web
• Optimized scripting engines
• Towards metaprogramming?
• Ruby community
• Code as data
IT’S A DYNAMIC WORLD
Dynamic
Languages
Simple and succinct
Implicitly typed
Meta-programming
No compilation
Static
Languages
Robust
Performant
Intelligent tools
Better scaling
STATIC VS DYNAMIC
DLR Hero
• Jim Hugunin
Co-designer ASpectJ
Jython implementation
• Python on the JVM
IronRuby implementation
• Python on the .NET
DLR Hero
• John Lam
RubyCLR
bridge between the Ruby
interpreter and the CLR
IronRuby
Ruby on the .NET
DLR Hero
Martin Maly
Common Language
Runtime
Dynamic Language
Runtime
C# compiler team
Chris Burrow, Sam Ng
Action Python Ruby C# VB.NET
GetMember x.Foo x.Foo x.Foo x.Foo
SetMember x.Foo = y x.Foo = y x.Foo = y x.Foo = y
DeleteMember del d.Foo
x.send
:remove_instance_variable
:@foo
No syntax No syntax
UnaryOperation -x -x -x -x
BinaryOperation x + y x + y x + y x + y
Convert No syntax No syntax (Foo)x CType(x,Foo)
InvokeMember x.Foo(a,b) x.Foo(a,b) x.Foo(a,b) x.Foo(a,b)
Invoke x(a,b) x.call(a,b) x(a,b) x(a,b)
CreateInstance X(a,b) X.new(a,b) No syntax No syntax
GetIndex x[a,b] x[a,b] x[a,b] x(a,b)
SetIndex x[a,b] = y x[a,b] = y x[a,b] = y X(a,b) = y
DeleteIndex del x[a,b] No syntax No syntax No syntax
Common actions
IDynamicMetaObjectProvider
public interface IDynamicMetaObjectProvider
{
DynamicMetaObject GetMetaObject(Expression parameter);
}
DynamicMetaObject
public class DynamicMetaObject
{
public BindingRestrictions Restrictions { get; }
public Expression Expression { get; }
public bool HasValue { get; }
public object Value { get; }
public Type RuntimeType { get; }
public virtual DynamicMetaObject BindGetMember(GetMemberBinder b);
public virtual DynamicMetaObject BindSetMember(SetMemberBinder b,
DynamicMetaObject value);
public virtual DynamicMetaObject BindDeleteMember(DeleteMemberBinder b);
// Other bind operations…
}
System.Dynamic.DynamicObject
public class DynamicObject : IDynamicMetaObjectProvider
{
public virtual bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out
object result);
public virtual bool TryConvert(ConvertBinder binder, out object result);
public virtual bool TryCreateInstance(CreateInstanceBinder binder, object[] args, out
object result);
public virtual bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object
result);
public virtual bool TryGetMember(GetMemberBinder binder, out object result);
public virtual bool TryInvoke(InvokeBinder binder, object[] args, out object result);
public virtual bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out
object result);
public virtual bool TrySetIndex(SetIndexBinder binder, object[] indexes, object
value);
public virtual bool TrySetMember(SetMemberBinder binder, object value);
}
Python
Binder
Ruby
Binder
COM
Binder
JavaScript
Binder
Object
Binder
DYNAMIC LANGUAGE RUNTIME (DLR)
Dynamic Language Runtime
DLR Trees Dynamic Dispatch Call Site Caching
IronPython IronRuby C# VB.NET Others…
CALL SITES
• Old Idea: Polymorphic Inline Cache
• Implemented with delegates and generics
• No changes in CLR runtime engine (today)
• Major Addition: Multiple languages on CLR
• Interop for sharing objects across languages
• Customization to work for each language
• Customization for library writers
• System.Runtime.CompilerServices
CLR
Compile Run
Bind call
Expression
Tree
DLR
Cache
COM Binder
IronPython
Binder
C# Runtime
Binder
…
HOW DYNAMIC WORKS
CALLSITE<T>
static CallSite<Func<CallSite, object, int, bool>> _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
}
As strongly
typed as
possible
Cache is learning
CALLSITE<T>
static CallSite<Func<CallSite, object, int, bool>> _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
}
}
DynamicMetaObject
public class DynamicMetaObject
{
public BindingRestrictions Restrictions { get; }
public Expression Expression { get; }
public bool HasValue { get; }
public object Value { get; }
public Type RuntimeType { get; }
public virtual DynamicMetaObject BindGetMember(GetMemberBinder b);
public virtual DynamicMetaObject BindSetMember(SetMemberBinder b,
DynamicMetaObject value);
public virtual DynamicMetaObject BindDeleteMember(DeleteMemberBinder b);
// Other bind operations…
}
Show me Dynamic C#
Ruby’s Markup Builder is an example of
what can be achieved with
method missing
b = Builder::XmlMarkup.new
html = b.html {
b.head {
b.title "XML Builder Test"
}
b.body {
b.h1 "Title of Page“
b.p "Sample paragraph text“
b.p "Sample paragraph text“
}
}
<head>
<title>XML Builder Test</title>
- <body>
<h1>Title of Page</h1>
<p>Sample paragraph text</p>
<p>Sample paragraph text</p>
</body>
</head>
class User < ActiveRecord::Base; end
users = User.find_all_by_state("TX")
user = User.find_or_create_by_email("foo@bar.com")
by @AntyaDev
Oak
Frictionless development
for ASP.NET MVC single
page web apps.
Prototypical and dynamic
capabilities brought to C#.
STATIC TYPING WHERE POSSIBLE,
DYNAMIC TYPING WHEN NEEDED
LINKS
• KingAOP: https://github.com/AntyaDev/KingAOP
• Simple.Data: https://github.com/markrendle/Simple.Data
• Massive: https://github.com/robconery/massive
• CarealBox: https://github.com/JonCanning/CerealBox
• Oak: http://amirrajan.github.io/Oak/
https://twitter.com/AntyaDev
https://github.com/AntyaDev
http://antyadev.blogspot.com/
THANK YOU!

Mais conteúdo relacionado

Mais procurados

Laporan pembuatan Final Project (Java - Netbeans) "Rental CD"
Laporan pembuatan Final Project (Java - Netbeans) "Rental CD"Laporan pembuatan Final Project (Java - Netbeans) "Rental CD"
Laporan pembuatan Final Project (Java - Netbeans) "Rental CD"Melina Krisnawati
 
Tugrik: A new persistence option for Pharo
Tugrik: A new persistence option for PharoTugrik: A new persistence option for Pharo
Tugrik: A new persistence option for PharoESUG
 
Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Johan Thelin
 
OpenStack und Containers
OpenStack und ContainersOpenStack und Containers
OpenStack und Containersinovex GmbH
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt CommunicationAndreas Jakl
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and GraphicsAndreas Jakl
 
Your First Gutenberg Block
Your First Gutenberg BlockYour First Gutenberg Block
Your First Gutenberg BlockYoav Farhi
 
Smart contracts in Solidity
Smart contracts in SoliditySmart contracts in Solidity
Smart contracts in SolidityFelix Crisan
 
HexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easierHexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easierAlex Matrosov
 
Voyage Reloaded - New features and backends in the document-database
Voyage Reloaded - New features and backends in the document-databaseVoyage Reloaded - New features and backends in the document-database
Voyage Reloaded - New features and backends in the document-databaseESUG
 

Mais procurados (12)

Laporan pembuatan Final Project (Java - Netbeans) "Rental CD"
Laporan pembuatan Final Project (Java - Netbeans) "Rental CD"Laporan pembuatan Final Project (Java - Netbeans) "Rental CD"
Laporan pembuatan Final Project (Java - Netbeans) "Rental CD"
 
Tugrik: A new persistence option for Pharo
Tugrik: A new persistence option for PharoTugrik: A new persistence option for Pharo
Tugrik: A new persistence option for Pharo
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 
Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011
 
Cross Platform Qt
Cross Platform QtCross Platform Qt
Cross Platform Qt
 
OpenStack und Containers
OpenStack und ContainersOpenStack und Containers
OpenStack und Containers
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt Communication
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics
 
Your First Gutenberg Block
Your First Gutenberg BlockYour First Gutenberg Block
Your First Gutenberg Block
 
Smart contracts in Solidity
Smart contracts in SoliditySmart contracts in Solidity
Smart contracts in Solidity
 
HexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easierHexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easier
 
Voyage Reloaded - New features and backends in the document-database
Voyage Reloaded - New features and backends in the document-databaseVoyage Reloaded - New features and backends in the document-database
Voyage Reloaded - New features and backends in the document-database
 

Destaque

Csharp ebook
Csharp ebookCsharp ebook
Csharp ebook988633
 
Configuring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversConfiguring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversAxilis
 
NuGet Must Haves for LINQ
NuGet Must Haves for LINQNuGet Must Haves for LINQ
NuGet Must Haves for LINQAxilis
 
C# features through examples
C# features through examplesC# features through examples
C# features through examplesZayen Chagra
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegantalenttransform
 
C# 6.0 - DotNetNotts
C# 6.0 - DotNetNottsC# 6.0 - DotNetNotts
C# 6.0 - DotNetNottscitizenmatt
 
Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#Alfonso Garcia-Caro
 
코드의 품질 (Code Quality)
코드의 품질 (Code Quality)코드의 품질 (Code Quality)
코드의 품질 (Code Quality)ChulHui Lee
 
C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0Buu Nguyen
 
Антон Молдован "Building data intensive stateful services with Orleans"
Антон Молдован "Building data intensive stateful services with Orleans"Антон Молдован "Building data intensive stateful services with Orleans"
Антон Молдован "Building data intensive stateful services with Orleans"Fwdays
 
게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴예림 임
 
C#으로 게임 엔진 만들기(2)
C#으로 게임 엔진 만들기(2)C#으로 게임 엔진 만들기(2)
C#으로 게임 엔진 만들기(2)지환 김
 
C#으로 게임 엔진 만들기(1)
C#으로 게임 엔진 만들기(1)C#으로 게임 엔진 만들기(1)
C#으로 게임 엔진 만들기(1)지환 김
 

Destaque (18)

C# 4.0 dynamic
C# 4.0 dynamicC# 4.0 dynamic
C# 4.0 dynamic
 
New features in C# 6
New features in C# 6New features in C# 6
New features in C# 6
 
Csharp ebook
Csharp ebookCsharp ebook
Csharp ebook
 
Configuring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversConfiguring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky servers
 
NuGet Must Haves for LINQ
NuGet Must Haves for LINQNuGet Must Haves for LINQ
NuGet Must Haves for LINQ
 
C# features through examples
C# features through examplesC# features through examples
C# features through examples
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
 
C# 6.0 - DotNetNotts
C# 6.0 - DotNetNottsC# 6.0 - DotNetNotts
C# 6.0 - DotNetNotts
 
Functional Programming with C#
Functional Programming with C#Functional Programming with C#
Functional Programming with C#
 
Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#
 
코드의 품질 (Code Quality)
코드의 품질 (Code Quality)코드의 품질 (Code Quality)
코드의 품질 (Code Quality)
 
C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0
 
Антон Молдован "Building data intensive stateful services with Orleans"
Антон Молдован "Building data intensive stateful services with Orleans"Антон Молдован "Building data intensive stateful services with Orleans"
Антон Молдован "Building data intensive stateful services with Orleans"
 
게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴
 
C#으로 게임 엔진 만들기(2)
C#으로 게임 엔진 만들기(2)C#으로 게임 엔진 만들기(2)
C#으로 게임 엔진 만들기(2)
 
C#으로 게임 엔진 만들기(1)
C#으로 게임 엔진 만들기(1)C#으로 게임 엔진 만들기(1)
C#으로 게임 엔진 만들기(1)
 
Easyloggingpp
EasyloggingppEasyloggingpp
Easyloggingpp
 
C# 4.0 - Whats New
C# 4.0 - Whats NewC# 4.0 - Whats New
C# 4.0 - Whats New
 

Semelhante a DYNAMIC C# - Explore the dynamic capabilities of C# and the DLR

Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationIvan Dolgushin
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo Ali Parmaksiz
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureAlexey Buzdin
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureC.T.Co
 
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15Murat Yener
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EEAlexis Hassler
 
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012Amazon Web Services
 
Google Cloud Functions: try { Kotlin } instead of JavaScript
Google Cloud Functions: try { Kotlin } instead of JavaScriptGoogle Cloud Functions: try { Kotlin } instead of JavaScript
Google Cloud Functions: try { Kotlin } instead of JavaScriptOmar Miatello
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9Marcus Lagergren
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIsJulian Viereck
 
Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805LearningTech
 
Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805LearningTech
 

Semelhante a DYNAMIC C# - Explore the dynamic capabilities of C# and the DLR (20)

Dlr
DlrDlr
Dlr
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
From Java to Python
From Java to PythonFrom Java to Python
From Java to Python
 
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code Generation
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Annotation processing tool
Annotation processing toolAnnotation processing tool
Annotation processing tool
 
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
 
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
 
Google Cloud Functions: try { Kotlin } instead of JavaScript
Google Cloud Functions: try { Kotlin } instead of JavaScriptGoogle Cloud Functions: try { Kotlin } instead of JavaScript
Google Cloud Functions: try { Kotlin } instead of JavaScript
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9
 
Implementing New Web
Implementing New WebImplementing New Web
Implementing New Web
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIs
 
Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805
 
Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Último (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

DYNAMIC C# - Explore the dynamic capabilities of C# and the DLR

  • 3. The many faces of “dynamic” Generate code at runtime Changing types at runtime No types at all Simplified deployment
  • 4. • Trend on non-schematized data • Remember WSDL, SOAP, XSD? • How about REST, JSON? • The next browser war • JavaScript on the web • Optimized scripting engines • Towards metaprogramming? • Ruby community • Code as data IT’S A DYNAMIC WORLD
  • 5. Dynamic Languages Simple and succinct Implicitly typed Meta-programming No compilation Static Languages Robust Performant Intelligent tools Better scaling STATIC VS DYNAMIC
  • 6. DLR Hero • Jim Hugunin Co-designer ASpectJ Jython implementation • Python on the JVM IronRuby implementation • Python on the .NET
  • 7. DLR Hero • John Lam RubyCLR bridge between the Ruby interpreter and the CLR IronRuby Ruby on the .NET
  • 8. DLR Hero Martin Maly Common Language Runtime Dynamic Language Runtime
  • 9. C# compiler team Chris Burrow, Sam Ng
  • 10. Action Python Ruby C# VB.NET GetMember x.Foo x.Foo x.Foo x.Foo SetMember x.Foo = y x.Foo = y x.Foo = y x.Foo = y DeleteMember del d.Foo x.send :remove_instance_variable :@foo No syntax No syntax UnaryOperation -x -x -x -x BinaryOperation x + y x + y x + y x + y Convert No syntax No syntax (Foo)x CType(x,Foo) InvokeMember x.Foo(a,b) x.Foo(a,b) x.Foo(a,b) x.Foo(a,b) Invoke x(a,b) x.call(a,b) x(a,b) x(a,b) CreateInstance X(a,b) X.new(a,b) No syntax No syntax GetIndex x[a,b] x[a,b] x[a,b] x(a,b) SetIndex x[a,b] = y x[a,b] = y x[a,b] = y X(a,b) = y DeleteIndex del x[a,b] No syntax No syntax No syntax Common actions
  • 12. DynamicMetaObject public class DynamicMetaObject { public BindingRestrictions Restrictions { get; } public Expression Expression { get; } public bool HasValue { get; } public object Value { get; } public Type RuntimeType { get; } public virtual DynamicMetaObject BindGetMember(GetMemberBinder b); public virtual DynamicMetaObject BindSetMember(SetMemberBinder b, DynamicMetaObject value); public virtual DynamicMetaObject BindDeleteMember(DeleteMemberBinder b); // Other bind operations… }
  • 13. System.Dynamic.DynamicObject public class DynamicObject : IDynamicMetaObjectProvider { public virtual bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result); public virtual bool TryConvert(ConvertBinder binder, out object result); public virtual bool TryCreateInstance(CreateInstanceBinder binder, object[] args, out object result); public virtual bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result); public virtual bool TryGetMember(GetMemberBinder binder, out object result); public virtual bool TryInvoke(InvokeBinder binder, object[] args, out object result); public virtual bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result); public virtual bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value); public virtual bool TrySetMember(SetMemberBinder binder, object value); }
  • 14. Python Binder Ruby Binder COM Binder JavaScript Binder Object Binder DYNAMIC LANGUAGE RUNTIME (DLR) Dynamic Language Runtime DLR Trees Dynamic Dispatch Call Site Caching IronPython IronRuby C# VB.NET Others…
  • 15. CALL SITES • Old Idea: Polymorphic Inline Cache • Implemented with delegates and generics • No changes in CLR runtime engine (today) • Major Addition: Multiple languages on CLR • Interop for sharing objects across languages • Customization to work for each language • Customization for library writers • System.Runtime.CompilerServices
  • 16. CLR Compile Run Bind call Expression Tree DLR Cache COM Binder IronPython Binder C# Runtime Binder … HOW DYNAMIC WORKS
  • 17. CALLSITE<T> static CallSite<Func<CallSite, object, int, bool>> _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 } As strongly typed as possible Cache is learning
  • 18. CALLSITE<T> static CallSite<Func<CallSite, object, int, bool>> _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 } }
  • 19. DynamicMetaObject public class DynamicMetaObject { public BindingRestrictions Restrictions { get; } public Expression Expression { get; } public bool HasValue { get; } public object Value { get; } public Type RuntimeType { get; } public virtual DynamicMetaObject BindGetMember(GetMemberBinder b); public virtual DynamicMetaObject BindSetMember(SetMemberBinder b, DynamicMetaObject value); public virtual DynamicMetaObject BindDeleteMember(DeleteMemberBinder b); // Other bind operations… }
  • 21. Ruby’s Markup Builder is an example of what can be achieved with method missing b = Builder::XmlMarkup.new html = b.html { b.head { b.title "XML Builder Test" } b.body { b.h1 "Title of Page“ b.p "Sample paragraph text“ b.p "Sample paragraph text“ } } <head> <title>XML Builder Test</title> - <body> <h1>Title of Page</h1> <p>Sample paragraph text</p> <p>Sample paragraph text</p> </body> </head>
  • 22. class User < ActiveRecord::Base; end users = User.find_all_by_state("TX") user = User.find_or_create_by_email("foo@bar.com")
  • 23.
  • 25. Oak Frictionless development for ASP.NET MVC single page web apps. Prototypical and dynamic capabilities brought to C#.
  • 26. STATIC TYPING WHERE POSSIBLE, DYNAMIC TYPING WHEN NEEDED
  • 27. LINKS • KingAOP: https://github.com/AntyaDev/KingAOP • Simple.Data: https://github.com/markrendle/Simple.Data • Massive: https://github.com/robconery/massive • CarealBox: https://github.com/JonCanning/CerealBox • Oak: http://amirrajan.github.io/Oak/