SlideShare a Scribd company logo
1 of 17
From OCaml to Javascript
      at Skydeck
   jake.donham@skydeck.com
What is Skydeck?

  o   a tool for managing your mobile phone

  o   reads your mobile phone call log

  o   presents it back to you in a useful way
        attach people to phone numbers
        view calls by person
        when did I last call Steve?
        who did I call yesterday?
        etc.
Where does the data come from?

  o   from your phone carrier's web site
         you give Skydeck your credentials
         we download bills and usage from carrier site
            with a Firefox extension
            with a standalone XULrunner app
            from our servers (a farm of XULrunners)

  o   via our web API
        3rd party can add new data sources
Where does OCaml come into this?

  o   most of our system is written in OCaml
        bill parsing, web servers, etc.

  o   but the web is Javascript
        Mozilla apps are Javascript
        Javascript is not my favorite programming language
            too forgiving
            heavy syntax for functional code

  o   sad programmers
OCamljs

 o   we wrote OCamljs
       Javascript back-end for OCaml compiler

 o   wrote our Mozilla app in OCaml

 o   we are happy
Really?

match referer with
  | None -> r#send body
  | Some re ->
  (* see http://developer.mozilla.org/en/docs/Setting_HTTP_req ...
  let os = XPCOM.getService_observer_service () in
  let observe (s : #XPCOM.supports) _ _ =
    let hc = s#_QueryInterface XPCOM.httpChannel in
    if hc == r#_get_channel#_QueryInterface XPCOM.httpChannel
    then hc#setRequestHeader "Referer" re false in
  let observer = Ocamljs.obj [
    "observe", Ocamljs.jsfun3 observe
  ] in
  os#addObserver observer "http-on-modify-request" false;
  r#send body;
  os#removeObserver observer "http-on-modify-request";
Benefits of OCaml for downloader

  o   types types types

  o   can give types to the complicated Mozilla API

  o   continuation passing style enforced by types

  o   transparent RPC to server

  o   tool support (Camlp4, ocamlbuild)
How does OCamljs work?

  o   ocamlc compiles to "lambda" intermediate language

  o   ocamljs translates lambda to Javascript

  o   almost everything in the front-end comes for free
        type checking
        module system
        Camlp4

  o   objects not free
        we want OCaml objects = JS objects
Example

OCaml:
 module Test =
 struct
   type foo = Bar of int | Baz of bool | Quux

   let   f = function
     |   Bar i -> "Bar " ^ string_of_int i
     |   Baz b -> "Baz " ^ (if b then "true" else "false")
     |   Quux -> "Quux"
 end
module Test =
                       struct
Example                  type foo = Bar of int | Baz of bool | Quux

                         let   f = function
                           |   Bar i -> "Bar " ^ string_of_int i
                           |   Baz b -> "Baz " ^ (if b then "true" else "false")
                           |   Quux -> "Quux"
                       end
Lambda:
(setglobal Test!
  (let
    (f/65
       (function param/73
         (switch* param/73
          case int 0: "Quux"
          case tag 0:
           (apply (field 15 (global Pervasives!)) "Bar "
             (apply (field 19 (global Pervasives!))
               (field 0 param/73)))
          case tag 1:
           (apply (field 15 (global Pervasives!)) "Baz "
             (if (field 0 param/73) "true" "false")))))
    (makeblock 0 f/65)))
(setglobal Test!
                               (let

 Example                         (f/65
                                    (function param/73
                                      (switch* param/73
                                       case int 0: "Quux"
                                       case tag 0:
                                        (apply (field 15 (global Pervasives!)) "Bar "
                                          (apply (field 19 (global Pervasives!))
                                            (field 0 param/73)))
                                       case tag 1:
Javascript:                             (apply (field 15 (global Pervasives!)) "Baz "
                                          (if (field 0 param/73) "true" "false")))))
                                 (makeblock 0 f/65)))
var oc$Test$ =
  function () {
    var f$65 =
       _f(function (param$73) {
            if (typeof param$73 == "number")
              switch (param$73) { case 0: return "Quux"; default: return ...
            else
              switch ($t(param$73)) {
              case 0:
                 return __(oc$Pervasives$[15],
                   ["Bar ", _(oc$Pervasives$[19], [param$73[0]])]);
              case 1:
                 return __(oc$Pervasives$[15],
                   ["Baz ", param$73[0] ? "true" : "false"]);
              default: return null;}
          });
    return $(f$65);
  }();
Gory details

  o   partial application / overapplication

  o   tail recursion via trampolines

  o   heap representation
        block -> array + tag
        int (nativeint, int32), float, char -> number
        bool -> number, bool
            since JS comparison ops return bool
        string -> string, number array
            support mutable strings
Interfacing with Javascript

  o   with "external" like with C
        naming convention for methods, accessors
        special externals for raw Javascript

  o   with object type
        naming convention for accessors

  o   OCamljs included libraries:
        some Mozilla API
        some built-in Javascript
        OCaml stdlib
Work in progress

  o   orpc for Javascript
        orpc generates RPC code from OCaml signatures
           works with Ocamlnet
        Javascript backend passes heap rep
           on client, just eval it
           on server, must check that it's valid for type

  o   jslib
         Camlp4 parser, pretty-printer, quotations for JS
Future work / dreams

  o   finish object support
         write Javascript objects in OCaml

  o   use jslib to support inline Javascript in OCaml code

  o   improve performance

  o   web programming
        like Google Web Toolkit
Using OCaml at a startup

  o   a good idea!

  o   better tools let you work faster

  o   static checking keeps you on course

  o   you get a clean slate

  o   you need to hire great people
        OCaml is fun!
Thanks!

  o   Skydeck is hiring
        http://skydeck.com/jobs

  o   http://code.google.com/p/ocamljs
  o   http://code.google.com/p/orpc2

More Related Content

What's hot

Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwiftSwift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwiftAaron Douglas
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogrammingdudarev
 
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)Sylvain Hallé
 
Learning To Love Java Script
Learning To Love Java ScriptLearning To Love Java Script
Learning To Love Java ScriptMichael Girouard
 
Learning To Love Java Script Color
Learning To Love Java Script ColorLearning To Love Java Script Color
Learning To Love Java Script ColorMichael Girouard
 
Go Containers
Go ContainersGo Containers
Go Containersjgrahamc
 
PHP in 2018 - Q1 - AFUP Limoges
PHP in 2018 - Q1 - AFUP LimogesPHP in 2018 - Q1 - AFUP Limoges
PHP in 2018 - Q1 - AFUP Limoges✅ William Pinaud
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowKrzysztof Szafranek
 
C++ hello world
C++ hello worldC++ hello world
C++ hello worldAL- AMIN
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS EngineChengHui Weng
 
SFO15-500: VIXL
SFO15-500: VIXLSFO15-500: VIXL
SFO15-500: VIXLLinaro
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6FITC
 

What's hot (20)

Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwiftSwift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
 
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
 
Learning To Love Java Script
Learning To Love Java ScriptLearning To Love Java Script
Learning To Love Java Script
 
Learning To Love Java Script Color
Learning To Love Java Script ColorLearning To Love Java Script Color
Learning To Love Java Script Color
 
JavaScript Looping Statements
JavaScript Looping StatementsJavaScript Looping Statements
JavaScript Looping Statements
 
Day 1
Day 1Day 1
Day 1
 
Go Containers
Go ContainersGo Containers
Go Containers
 
Golang Channels
Golang ChannelsGolang Channels
Golang Channels
 
PHP in 2018 - Q1 - AFUP Limoges
PHP in 2018 - Q1 - AFUP LimogesPHP in 2018 - Q1 - AFUP Limoges
PHP in 2018 - Q1 - AFUP Limoges
 
The Big Three
The Big ThreeThe Big Three
The Big Three
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
 
Exploiting vectorization with ISPC
Exploiting vectorization with ISPCExploiting vectorization with ISPC
Exploiting vectorization with ISPC
 
C++ hello world
C++ hello worldC++ hello world
C++ hello world
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine
 
Chapter9
Chapter9Chapter9
Chapter9
 
SFO15-500: VIXL
SFO15-500: VIXLSFO15-500: VIXL
SFO15-500: VIXL
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
 
MFC Message Handling
MFC Message HandlingMFC Message Handling
MFC Message Handling
 
dplyr
dplyrdplyr
dplyr
 

Viewers also liked

Viteee information brochure
Viteee information brochureViteee information brochure
Viteee information brochuremattcruiser
 
Retribución power point
Retribución power pointRetribución power point
Retribución power pointmanuleon
 
Nancy medina suarez
Nancy medina suarezNancy medina suarez
Nancy medina suarezlucio
 
La revolucion industrial
La revolucion industrialLa revolucion industrial
La revolucion industrialcasadelos
 
Descripcion alameda oriente, mexico df
Descripcion alameda oriente, mexico dfDescripcion alameda oriente, mexico df
Descripcion alameda oriente, mexico dfizrahernandez
 
Economy hajj packages 2016
Economy hajj packages 2016Economy hajj packages 2016
Economy hajj packages 2016Abdul Majeed
 
FeetApart: Cloud based employee engagement health & wellness platform
FeetApart: Cloud based employee engagement health & wellness platformFeetApart: Cloud based employee engagement health & wellness platform
FeetApart: Cloud based employee engagement health & wellness platformAbhishek Roy
 
Diseño aplicado al envase. Packaging vino.
Diseño aplicado al envase. Packaging vino.Diseño aplicado al envase. Packaging vino.
Diseño aplicado al envase. Packaging vino.Estefania Gomez
 
tribus urbanas .i.
tribus urbanas .i.tribus urbanas .i.
tribus urbanas .i.grupo201
 
innovacion 3 --innovacion disruptiva
innovacion 3 --innovacion disruptivainnovacion 3 --innovacion disruptiva
innovacion 3 --innovacion disruptivaJairo Rodriguez
 
Metamorfosis (III), d'Ovidi
Metamorfosis (III), d'OvidiMetamorfosis (III), d'Ovidi
Metamorfosis (III), d'Ovidiarsamatoria
 

Viewers also liked (20)

Manual open office.org calc
Manual  open office.org calcManual  open office.org calc
Manual open office.org calc
 
Viteee information brochure
Viteee information brochureViteee information brochure
Viteee information brochure
 
Retribución power point
Retribución power pointRetribución power point
Retribución power point
 
Bodas gitanas
Bodas gitanas Bodas gitanas
Bodas gitanas
 
21 04 taumaturgia www.gftaognosticaespiritual.org
21 04 taumaturgia www.gftaognosticaespiritual.org21 04 taumaturgia www.gftaognosticaespiritual.org
21 04 taumaturgia www.gftaognosticaespiritual.org
 
Esto lo arreglamos si se escucha a todos
Esto lo arreglamos si se escucha a todosEsto lo arreglamos si se escucha a todos
Esto lo arreglamos si se escucha a todos
 
Nancy medina suarez
Nancy medina suarezNancy medina suarez
Nancy medina suarez
 
La revolucion industrial
La revolucion industrialLa revolucion industrial
La revolucion industrial
 
Imperia h20 call 09958959555.
Imperia h20 call 09958959555.Imperia h20 call 09958959555.
Imperia h20 call 09958959555.
 
Actitudes Ganadoras
Actitudes GanadorasActitudes Ganadoras
Actitudes Ganadoras
 
Descripcion alameda oriente, mexico df
Descripcion alameda oriente, mexico dfDescripcion alameda oriente, mexico df
Descripcion alameda oriente, mexico df
 
Economy hajj packages 2016
Economy hajj packages 2016Economy hajj packages 2016
Economy hajj packages 2016
 
27 grammar i
27 grammar i27 grammar i
27 grammar i
 
FeetApart: Cloud based employee engagement health & wellness platform
FeetApart: Cloud based employee engagement health & wellness platformFeetApart: Cloud based employee engagement health & wellness platform
FeetApart: Cloud based employee engagement health & wellness platform
 
El Principio Del Vacio
El Principio Del VacioEl Principio Del Vacio
El Principio Del Vacio
 
Llanto numero 2
Llanto numero 2Llanto numero 2
Llanto numero 2
 
Diseño aplicado al envase. Packaging vino.
Diseño aplicado al envase. Packaging vino.Diseño aplicado al envase. Packaging vino.
Diseño aplicado al envase. Packaging vino.
 
tribus urbanas .i.
tribus urbanas .i.tribus urbanas .i.
tribus urbanas .i.
 
innovacion 3 --innovacion disruptiva
innovacion 3 --innovacion disruptivainnovacion 3 --innovacion disruptiva
innovacion 3 --innovacion disruptiva
 
Metamorfosis (III), d'Ovidi
Metamorfosis (III), d'OvidiMetamorfosis (III), d'Ovidi
Metamorfosis (III), d'Ovidi
 

Similar to From OCaml To Javascript At Skydeck

Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvmArnaud Giuliani
 
Spring RTS Engine Checkup
Spring RTS Engine CheckupSpring RTS Engine Checkup
Spring RTS Engine CheckupPVS-Studio
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgePVS-Studio
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2PVS-Studio
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerAndrey Karpov
 
An Introduction to Property Based Testing
An Introduction to Property Based TestingAn Introduction to Property Based Testing
An Introduction to Property Based TestingC4Media
 
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...PVS-Studio
 
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...Andrey Karpov
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기NAVER D2
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomyDongmin Yu
 
No dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldNo dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldtcurdt
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects Andrey Karpov
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
Java best practices
Java best practicesJava best practices
Java best practicesRay Toal
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for CassandraEdward Capriolo
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"DataStax Academy
 
Philipp Krenn "Make Your Data FABulous"
Philipp Krenn "Make Your Data FABulous"Philipp Krenn "Make Your Data FABulous"
Philipp Krenn "Make Your Data FABulous"Fwdays
 
A Spin-off: Firebird Checked by PVS-Studio
A Spin-off: Firebird Checked by PVS-StudioA Spin-off: Firebird Checked by PVS-Studio
A Spin-off: Firebird Checked by PVS-StudioAndrey Karpov
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1PVS-Studio
 

Similar to From OCaml To Javascript At Skydeck (20)

Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvm
 
Spring RTS Engine Checkup
Spring RTS Engine CheckupSpring RTS Engine Checkup
Spring RTS Engine Checkup
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
An Introduction to Property Based Testing
An Introduction to Property Based TestingAn Introduction to Property Based Testing
An Introduction to Property Based Testing
 
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
 
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
No dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldNo dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real world
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Java best practices
Java best practicesJava best practices
Java best practices
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
 
Philipp Krenn "Make Your Data FABulous"
Philipp Krenn "Make Your Data FABulous"Philipp Krenn "Make Your Data FABulous"
Philipp Krenn "Make Your Data FABulous"
 
A Spin-off: Firebird Checked by PVS-Studio
A Spin-off: Firebird Checked by PVS-StudioA Spin-off: Firebird Checked by PVS-Studio
A Spin-off: Firebird Checked by PVS-Studio
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
 

Recently uploaded

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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
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
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
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
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
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...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

From OCaml To Javascript At Skydeck

  • 1. From OCaml to Javascript at Skydeck jake.donham@skydeck.com
  • 2. What is Skydeck? o a tool for managing your mobile phone o reads your mobile phone call log o presents it back to you in a useful way  attach people to phone numbers  view calls by person  when did I last call Steve?  who did I call yesterday?  etc.
  • 3. Where does the data come from? o from your phone carrier's web site  you give Skydeck your credentials  we download bills and usage from carrier site  with a Firefox extension  with a standalone XULrunner app  from our servers (a farm of XULrunners) o via our web API  3rd party can add new data sources
  • 4. Where does OCaml come into this? o most of our system is written in OCaml  bill parsing, web servers, etc. o but the web is Javascript  Mozilla apps are Javascript  Javascript is not my favorite programming language  too forgiving  heavy syntax for functional code o sad programmers
  • 5. OCamljs o we wrote OCamljs  Javascript back-end for OCaml compiler o wrote our Mozilla app in OCaml o we are happy
  • 6. Really? match referer with | None -> r#send body | Some re -> (* see http://developer.mozilla.org/en/docs/Setting_HTTP_req ... let os = XPCOM.getService_observer_service () in let observe (s : #XPCOM.supports) _ _ = let hc = s#_QueryInterface XPCOM.httpChannel in if hc == r#_get_channel#_QueryInterface XPCOM.httpChannel then hc#setRequestHeader "Referer" re false in let observer = Ocamljs.obj [ "observe", Ocamljs.jsfun3 observe ] in os#addObserver observer "http-on-modify-request" false; r#send body; os#removeObserver observer "http-on-modify-request";
  • 7. Benefits of OCaml for downloader o types types types o can give types to the complicated Mozilla API o continuation passing style enforced by types o transparent RPC to server o tool support (Camlp4, ocamlbuild)
  • 8. How does OCamljs work? o ocamlc compiles to "lambda" intermediate language o ocamljs translates lambda to Javascript o almost everything in the front-end comes for free  type checking  module system  Camlp4 o objects not free  we want OCaml objects = JS objects
  • 9. Example OCaml: module Test = struct type foo = Bar of int | Baz of bool | Quux let f = function | Bar i -> "Bar " ^ string_of_int i | Baz b -> "Baz " ^ (if b then "true" else "false") | Quux -> "Quux" end
  • 10. module Test = struct Example type foo = Bar of int | Baz of bool | Quux let f = function | Bar i -> "Bar " ^ string_of_int i | Baz b -> "Baz " ^ (if b then "true" else "false") | Quux -> "Quux" end Lambda: (setglobal Test! (let (f/65 (function param/73 (switch* param/73 case int 0: "Quux" case tag 0: (apply (field 15 (global Pervasives!)) "Bar " (apply (field 19 (global Pervasives!)) (field 0 param/73))) case tag 1: (apply (field 15 (global Pervasives!)) "Baz " (if (field 0 param/73) "true" "false"))))) (makeblock 0 f/65)))
  • 11. (setglobal Test! (let Example (f/65 (function param/73 (switch* param/73 case int 0: "Quux" case tag 0: (apply (field 15 (global Pervasives!)) "Bar " (apply (field 19 (global Pervasives!)) (field 0 param/73))) case tag 1: Javascript: (apply (field 15 (global Pervasives!)) "Baz " (if (field 0 param/73) "true" "false"))))) (makeblock 0 f/65))) var oc$Test$ = function () { var f$65 = _f(function (param$73) { if (typeof param$73 == "number") switch (param$73) { case 0: return "Quux"; default: return ... else switch ($t(param$73)) { case 0: return __(oc$Pervasives$[15], ["Bar ", _(oc$Pervasives$[19], [param$73[0]])]); case 1: return __(oc$Pervasives$[15], ["Baz ", param$73[0] ? "true" : "false"]); default: return null;} }); return $(f$65); }();
  • 12. Gory details o partial application / overapplication o tail recursion via trampolines o heap representation  block -> array + tag  int (nativeint, int32), float, char -> number  bool -> number, bool  since JS comparison ops return bool  string -> string, number array  support mutable strings
  • 13. Interfacing with Javascript o with "external" like with C  naming convention for methods, accessors  special externals for raw Javascript o with object type  naming convention for accessors o OCamljs included libraries:  some Mozilla API  some built-in Javascript  OCaml stdlib
  • 14. Work in progress o orpc for Javascript  orpc generates RPC code from OCaml signatures  works with Ocamlnet  Javascript backend passes heap rep  on client, just eval it  on server, must check that it's valid for type o jslib  Camlp4 parser, pretty-printer, quotations for JS
  • 15. Future work / dreams o finish object support  write Javascript objects in OCaml o use jslib to support inline Javascript in OCaml code o improve performance o web programming  like Google Web Toolkit
  • 16. Using OCaml at a startup o a good idea! o better tools let you work faster o static checking keeps you on course o you get a clean slate o you need to hire great people  OCaml is fun!
  • 17. Thanks! o Skydeck is hiring  http://skydeck.com/jobs o http://code.google.com/p/ocamljs o http://code.google.com/p/orpc2