SlideShare una empresa de Scribd logo
1 de 14
F# R TYPE
PROVIDER
Howard Mansell
6th September 2012
DISCLAIMER
F# R TYPE PROVIDER
 F# vs. R
 What are Type Providers?
 The R Provider
 Challenges
 Type Provider Growing Pains
 Was it worth it?
F# VS R

F#                                   R
 Functional + OO                     Functional-ish + Crazy-OO
 Compiled                            Interpreted
 Statically typed                    Dynamically typed
 OK for Exploratory Analysis         Strong for Exploratory Analysis
 Well-suited for building systems    Unsuitable for building systems
 Weak math/stats libraries           Strong stats libraries
 Basic visualization tools           Rich visualization tools
 Good for data acquisition           Poor for data acquisition
 Good for data processing            Decent for data processing
 Scalable                            Not particularly scalable
MIXING THEM
 WHY?
   Functionality from .NET libraries
   Data acquisition & transformation in F#
   Stats/graphics functionality from R libraries
   Build robust systems

 HOW?
   RDotNet provides .NET OO wrapper around R.DLL (in-process)
   RCOM provides cross-process access to R session via DCOM
   Rserve provides client-server socket-server access to R session
F# TYPE PROVIDERS
 A mechanism for “dynamically” providing types to the IDE +
  compiler
 Provided at compile/edit time, based on:
    Static parameters (in code)
    Access to external resources (database, WSDL, odata)

 Downstream code is then statically typed
 Good Intellisense experience
 Code fragments are generated at compile-time and injected
    “Schema” baked into client code

 Addresses a significant issue that drives people to dynamic
  languages
TYPE PROVIDERS VS CODE GEN
 Generally equivalent, except…
 Some problems don‟t scale with codegen (e.g. Freebase provider)
 Simpler process-wise (no additional tool to know/run)
 Uniform mechanism for access
 Somewhat simpler/less error-prone to write type provider
THE R PROVIDER
 Type Providers can be used for inter-language interop / meta-
  programming
 The “external resource”/schema in this case is the R environment
 Make R packages available as .NET namespaces
 Make R functions & values available as .NET members
 Uses RDotNet
    Lightweight, in-process
    Results kept in R environment unless explicitly marshaled back
    Objects can be explicitly saved and loaded into a real R session if desired.

 Available at
  http://github.com/BlueMountainCapital/FSharpRProvider
CHALLENGES
 How do we bridge dynamic <-> static typing?
 Dynamic typing basically just has one static type – Any/Obj/…
 .NET-base statically-typed languages still have a dynamic typing
  system
 Dynamic languages have lightweight syntax for dynamic method
  dispatch
 But R eshews dotted notation for method dispatch
 Do the obvious thing – use the “one static type”
    All arguments are of type object
    Results are of type RDotNet.SymbolicExpression – keeps result inside R
      engine
    Arguments can be native .NET types or SymbolicExpression
ARGUMENT PASSING
CONVENTIONS
 R has named and positional passing styles
 R has … argument (params/varargs)
 R allows arguments to have default values
    Function will be invoked even if no value supplied and no default
    Make all arguments optional

 These map pretty well onto F# named/optional arguments
    Need to expose functions as static members.
    Always exposed as RProvider.packagename.R.functionname

 Exceptions:
    In R, … argument can come before named arguments.
    In R, … arguments can be passed using an identifying name.
ARGUMENT CONVERSION
 Obvious basic type conversions are built in:
    Seq<double> -> numeric vector
    Double -> numeric vector
    Etc.

 Lists can be constructed using R.list()
 How do we support implicit conversion of bespoke classes?
    E.g. we have our own .NET DataFrame type, should convert to R data.frame
    Avoid forking the Open Source project

 Support plug-ins via Managed Extensibility Framework
    Plug-ins can use the type provider to call R functions, or talk to REngine
      directly
RESULT CONVERSION
 Results always come back as SymbolicExpression
    RDotNet wrapper around the R C datatype SEXPREC

 RProvider adds a Value property as extension
    Returns the default .NET representation of the SymbolicExpression
    Obvious default conversions are built-in – can add/override using MEF plug-in

 We also add GetValue<„ResType> : unit -> „ResType
    Allows caller to specify the type they want
    Supports things like NumericVector->double when vector is length 1
    Can also augment/override using MEF plug-in
TYPE PROVIDER GROWING PAINS
 Type providers are an awesome idea
 Current implementation has some kinks:
    Cannot compile Type Provider while binary is in use by VS (VS keeps it
     locked)
    If Type Providers are dependent on other assemblies they may not get
     resolved
    Accessing slow external resources can slow down your machine
    Buggy type providers can crash the IDE or compiler
    Builds may fail because of machine configuration:
        E.g. you don‟t have R
        You don‟t have the same packages installed in R
        Best to put external resources or schema files in source control
WAS IT WORTH IT?
 Having integrated, slightly-type-safe access to R from F#
  interactive is extremely powerful.
 This problem can be solved using code generation
 Using the type provider is much more “fluid” – no process
 Issues from previous slide detract from that somewhat
 Type providers have lots of interesting applications outside data
  access:
    COM interop
    WinRT interop
    Intra-language meta-programming (if static parameters were more flexible)

Más contenido relacionado

La actualidad más candente

The D Programming Language - Why I love it!
The D Programming Language - Why I love it!The D Programming Language - Why I love it!
The D Programming Language - Why I love it!ryutenchi
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of ScalaMartin Odersky
 
A Field Guide to DSL Design in Scala
A Field Guide to DSL Design in ScalaA Field Guide to DSL Design in Scala
A Field Guide to DSL Design in ScalaTomer Gabel
 
Domain specific languages and Scala
Domain specific languages and ScalaDomain specific languages and Scala
Domain specific languages and ScalaFilip Krikava
 
R Programming: Introduction To R Packages
R Programming: Introduction To R PackagesR Programming: Introduction To R Packages
R Programming: Introduction To R PackagesRsquared Academy
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scalafanf42
 
Beauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScriptBeauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScriptHendrik Ebbers
 
WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaKatrien Verbert
 
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache AiravataRESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache Airavatasmarru
 
Structured web programming
Structured web programmingStructured web programming
Structured web programmingahfast
 
Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)Kiran Jonnalagadda
 
Semantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialSemantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialAdonisDamian
 
Apache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesApache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesJimmy Lai
 

La actualidad más candente (20)

Dart workshop
Dart workshopDart workshop
Dart workshop
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
 
D programming language
D programming languageD programming language
D programming language
 
The D Programming Language - Why I love it!
The D Programming Language - Why I love it!The D Programming Language - Why I love it!
The D Programming Language - Why I love it!
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
Jena Programming
Jena ProgrammingJena Programming
Jena Programming
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
A Field Guide to DSL Design in Scala
A Field Guide to DSL Design in ScalaA Field Guide to DSL Design in Scala
A Field Guide to DSL Design in Scala
 
Perl Programming - 02 Regular Expression
Perl Programming - 02 Regular ExpressionPerl Programming - 02 Regular Expression
Perl Programming - 02 Regular Expression
 
Domain specific languages and Scala
Domain specific languages and ScalaDomain specific languages and Scala
Domain specific languages and Scala
 
Google Dart
Google DartGoogle Dart
Google Dart
 
R Programming: Introduction To R Packages
R Programming: Introduction To R PackagesR Programming: Introduction To R Packages
R Programming: Introduction To R Packages
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
 
Beauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScriptBeauty & the Beast - Java VS TypeScript
Beauty & the Beast - Java VS TypeScript
 
WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPedia
 
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache AiravataRESTLess Design with Apache Thrift: Experiences from Apache Airavata
RESTLess Design with Apache Thrift: Experiences from Apache Airavata
 
Structured web programming
Structured web programmingStructured web programming
Structured web programming
 
Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)
 
Semantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialSemantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorial
 
Apache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesApache thrift-RPC service cross languages
Apache thrift-RPC service cross languages
 

Destacado

Building Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software DevelopersBuilding Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software DevelopersAnthony Brown
 
Writing a Search Engine. How hard could it be?
Writing a Search Engine. How hard could it be?Writing a Search Engine. How hard could it be?
Writing a Search Engine. How hard could it be?Anthony Brown
 
Streaming ETL With Akka.NET
Streaming ETL With Akka.NETStreaming ETL With Akka.NET
Streaming ETL With Akka.NETpetabridge
 
Building applications with akka.net
Building applications with akka.netBuilding applications with akka.net
Building applications with akka.netAnthony Brown
 
Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015Anthony Brown
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!David Hoerster
 
Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Sergey Tihon
 
Creating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetCreating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetDavid Hoerster
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleansBill Tulloch
 
Data Workflows for Machine Learning - Seattle DAML
Data Workflows for Machine Learning - Seattle DAMLData Workflows for Machine Learning - Seattle DAML
Data Workflows for Machine Learning - Seattle DAMLPaco Nathan
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented ProgrammingScott Wlaschin
 

Destacado (13)

MBrace: Cloud Computing with F#
MBrace: Cloud Computing with F#MBrace: Cloud Computing with F#
MBrace: Cloud Computing with F#
 
Building Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software DevelopersBuilding Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software Developers
 
Writing a Search Engine. How hard could it be?
Writing a Search Engine. How hard could it be?Writing a Search Engine. How hard could it be?
Writing a Search Engine. How hard could it be?
 
Drm and the web
Drm and the webDrm and the web
Drm and the web
 
Streaming ETL With Akka.NET
Streaming ETL With Akka.NETStreaming ETL With Akka.NET
Streaming ETL With Akka.NET
 
Building applications with akka.net
Building applications with akka.netBuilding applications with akka.net
Building applications with akka.net
 
Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015Reactive applications with Akka.Net - DDD East Anglia 2015
Reactive applications with Akka.Net - DDD East Anglia 2015
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...
 
Creating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetCreating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnet
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleans
 
Data Workflows for Machine Learning - Seattle DAML
Data Workflows for Machine Learning - Seattle DAMLData Workflows for Machine Learning - Seattle DAML
Data Workflows for Machine Learning - Seattle DAML
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
 

Similar a F# Type Provider for R Statistical Platform

Data Science - Part II - Working with R & R studio
Data Science - Part II -  Working with R & R studioData Science - Part II -  Working with R & R studio
Data Science - Part II - Working with R & R studioDerek Kane
 
Reproducible research (and literate programming) in R
Reproducible research (and literate programming) in RReproducible research (and literate programming) in R
Reproducible research (and literate programming) in Rliz__is
 
Consuming Data with F# Type Providers
Consuming Data with F# Type ProvidersConsuming Data with F# Type Providers
Consuming Data with F# Type ProvidersRachel Reese
 
R programming language
R programming languageR programming language
R programming languageKeerti Verma
 
Architecting Domain-Specific Languages
Architecting Domain-Specific LanguagesArchitecting Domain-Specific Languages
Architecting Domain-Specific LanguagesMarkus Voelter
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchAndrew Lowe
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
APIs And SDKs  Breaking Into And Succeeding In A Specialty MarketAPIs And SDKs  Breaking Into And Succeeding In A Specialty Market
APIs And SDKs Breaking Into And Succeeding In A Specialty MarketBill Dubie
 
R as supporting tool for analytics and simulation
R as supporting tool for analytics and simulationR as supporting tool for analytics and simulation
R as supporting tool for analytics and simulationAlvaro Gil
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...Maarten Balliauw
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programminghemasri56
 
JetBrains MPS: Projectional Editing in Domain-Specific Languages
JetBrains MPS: Projectional Editing in Domain-Specific LanguagesJetBrains MPS: Projectional Editing in Domain-Specific Languages
JetBrains MPS: Projectional Editing in Domain-Specific LanguagesOscar Rodriguez
 
Evolutionary Design Solid
Evolutionary Design SolidEvolutionary Design Solid
Evolutionary Design SolidSai Venkat
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Maarten Balliauw
 
Chapter One
Chapter OneChapter One
Chapter Onebolovv
 
Project_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalProject_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalJerin John
 
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...PROIDEA
 

Similar a F# Type Provider for R Statistical Platform (20)

Data Science - Part II - Working with R & R studio
Data Science - Part II -  Working with R & R studioData Science - Part II -  Working with R & R studio
Data Science - Part II - Working with R & R studio
 
Reproducible research (and literate programming) in R
Reproducible research (and literate programming) in RReproducible research (and literate programming) in R
Reproducible research (and literate programming) in R
 
Consuming Data with F# Type Providers
Consuming Data with F# Type ProvidersConsuming Data with F# Type Providers
Consuming Data with F# Type Providers
 
R programming language
R programming languageR programming language
R programming language
 
Architecting Domain-Specific Languages
Architecting Domain-Specific LanguagesArchitecting Domain-Specific Languages
Architecting Domain-Specific Languages
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible research
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
APIs And SDKs  Breaking Into And Succeeding In A Specialty MarketAPIs And SDKs  Breaking Into And Succeeding In A Specialty Market
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
 
R as supporting tool for analytics and simulation
R as supporting tool for analytics and simulationR as supporting tool for analytics and simulation
R as supporting tool for analytics and simulation
 
R programming Language
R programming LanguageR programming Language
R programming Language
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
 
JetBrains MPS: Projectional Editing in Domain-Specific Languages
JetBrains MPS: Projectional Editing in Domain-Specific LanguagesJetBrains MPS: Projectional Editing in Domain-Specific Languages
JetBrains MPS: Projectional Editing in Domain-Specific Languages
 
Evolutionary Design Solid
Evolutionary Design SolidEvolutionary Design Solid
Evolutionary Design Solid
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 
Evolutionary Design Solid
Evolutionary Design SolidEvolutionary Design Solid
Evolutionary Design Solid
 
Chapter One
Chapter OneChapter One
Chapter One
 
R programming
R programmingR programming
R programming
 
Project_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalProject_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_final
 
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
 

Último

Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 

Último (20)

Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 

F# Type Provider for R Statistical Platform

  • 1. F# R TYPE PROVIDER Howard Mansell 6th September 2012
  • 3. F# R TYPE PROVIDER  F# vs. R  What are Type Providers?  The R Provider  Challenges  Type Provider Growing Pains  Was it worth it?
  • 4. F# VS R F# R  Functional + OO  Functional-ish + Crazy-OO  Compiled  Interpreted  Statically typed  Dynamically typed  OK for Exploratory Analysis  Strong for Exploratory Analysis  Well-suited for building systems  Unsuitable for building systems  Weak math/stats libraries  Strong stats libraries  Basic visualization tools  Rich visualization tools  Good for data acquisition  Poor for data acquisition  Good for data processing  Decent for data processing  Scalable  Not particularly scalable
  • 5. MIXING THEM  WHY?  Functionality from .NET libraries  Data acquisition & transformation in F#  Stats/graphics functionality from R libraries  Build robust systems  HOW?  RDotNet provides .NET OO wrapper around R.DLL (in-process)  RCOM provides cross-process access to R session via DCOM  Rserve provides client-server socket-server access to R session
  • 6. F# TYPE PROVIDERS  A mechanism for “dynamically” providing types to the IDE + compiler  Provided at compile/edit time, based on:  Static parameters (in code)  Access to external resources (database, WSDL, odata)  Downstream code is then statically typed  Good Intellisense experience  Code fragments are generated at compile-time and injected  “Schema” baked into client code  Addresses a significant issue that drives people to dynamic languages
  • 7. TYPE PROVIDERS VS CODE GEN  Generally equivalent, except…  Some problems don‟t scale with codegen (e.g. Freebase provider)  Simpler process-wise (no additional tool to know/run)  Uniform mechanism for access  Somewhat simpler/less error-prone to write type provider
  • 8. THE R PROVIDER  Type Providers can be used for inter-language interop / meta- programming  The “external resource”/schema in this case is the R environment  Make R packages available as .NET namespaces  Make R functions & values available as .NET members  Uses RDotNet  Lightweight, in-process  Results kept in R environment unless explicitly marshaled back  Objects can be explicitly saved and loaded into a real R session if desired.  Available at http://github.com/BlueMountainCapital/FSharpRProvider
  • 9. CHALLENGES  How do we bridge dynamic <-> static typing?  Dynamic typing basically just has one static type – Any/Obj/…  .NET-base statically-typed languages still have a dynamic typing system  Dynamic languages have lightweight syntax for dynamic method dispatch  But R eshews dotted notation for method dispatch  Do the obvious thing – use the “one static type”  All arguments are of type object  Results are of type RDotNet.SymbolicExpression – keeps result inside R engine  Arguments can be native .NET types or SymbolicExpression
  • 10. ARGUMENT PASSING CONVENTIONS  R has named and positional passing styles  R has … argument (params/varargs)  R allows arguments to have default values  Function will be invoked even if no value supplied and no default  Make all arguments optional  These map pretty well onto F# named/optional arguments  Need to expose functions as static members.  Always exposed as RProvider.packagename.R.functionname  Exceptions:  In R, … argument can come before named arguments.  In R, … arguments can be passed using an identifying name.
  • 11. ARGUMENT CONVERSION  Obvious basic type conversions are built in:  Seq<double> -> numeric vector  Double -> numeric vector  Etc.  Lists can be constructed using R.list()  How do we support implicit conversion of bespoke classes?  E.g. we have our own .NET DataFrame type, should convert to R data.frame  Avoid forking the Open Source project  Support plug-ins via Managed Extensibility Framework  Plug-ins can use the type provider to call R functions, or talk to REngine directly
  • 12. RESULT CONVERSION  Results always come back as SymbolicExpression  RDotNet wrapper around the R C datatype SEXPREC  RProvider adds a Value property as extension  Returns the default .NET representation of the SymbolicExpression  Obvious default conversions are built-in – can add/override using MEF plug-in  We also add GetValue<„ResType> : unit -> „ResType  Allows caller to specify the type they want  Supports things like NumericVector->double when vector is length 1  Can also augment/override using MEF plug-in
  • 13. TYPE PROVIDER GROWING PAINS  Type providers are an awesome idea  Current implementation has some kinks:  Cannot compile Type Provider while binary is in use by VS (VS keeps it locked)  If Type Providers are dependent on other assemblies they may not get resolved  Accessing slow external resources can slow down your machine  Buggy type providers can crash the IDE or compiler  Builds may fail because of machine configuration:  E.g. you don‟t have R  You don‟t have the same packages installed in R  Best to put external resources or schema files in source control
  • 14. WAS IT WORTH IT?  Having integrated, slightly-type-safe access to R from F# interactive is extremely powerful.  This problem can be solved using code generation  Using the type provider is much more “fluid” – no process  Issues from previous slide detract from that somewhat  Type providers have lots of interesting applications outside data access:  COM interop  WinRT interop  Intra-language meta-programming (if static parameters were more flexible)

Notas del editor

  1. Demo: R-studio; 1+2x = 3xs = c(1,2,3) (both are vectors)Xs + xXs &gt; 1F = function(x) x + 1Look at fLook at cDf = data.frame(A=c(1,2,3), B=(c,4,5,6))Class(df)Unclass(df)Print(df)PrintPrint.data.frame
  2. Show RDotNet sample program.
  3. Examples: SQL provider, XML provider, Regex provider, CSV provider, Odata provider, file system provider
  4. Demo of F# type provider.#load script that provides getStockPrices as CSV (save files on disk)Call getStockPrices on MSFT and show results in visualizerCall R.log |&gt; R.diff on result – show resultlet data =[for t in tickers -&gt; t,getStockPrices t 255 |&gt;R.log|&gt;R.diff]Call R.data_frame on the resultShow pairs plotPick a pair – plot against each otherBuild lm.
  5. Take a look at the Rprovider.fs code
  6. Look at Rinterop.fs
  7. Show FactorVector and DataFrameConverter