SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Kürzlich hochgeladen (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

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