The state of OCaml, 2012 Xavier Leroy INRIA Paris-Rocquencourt - - PowerPoint PPT Presentation

the state of ocaml 2012
SMART_READER_LITE
LIVE PREVIEW

The state of OCaml, 2012 Xavier Leroy INRIA Paris-Rocquencourt - - PowerPoint PPT Presentation

The state of OCaml, 2012 Xavier Leroy INRIA Paris-Rocquencourt OCaml Users and Developers Workshop, 2012-09-14 X. Leroy (INRIA) The state of OCaml, 2012 OUD 2012 1 / 17 Outline OCaml development news 1 OCaml community news 2 X. Leroy


slide-1
SLIDE 1

The state of OCaml, 2012

Xavier Leroy

INRIA Paris-Rocquencourt

OCaml Users and Developers Workshop, 2012-09-14

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 1 / 17

slide-2
SLIDE 2

Outline

1

OCaml development news

2

OCaml community news

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 2 / 17

slide-3
SLIDE 3

The new major release: OCaml 4.00

95 96 97 98 99 00 01 02 03 04 05 06 07 08 09 10 11 12 13 CSL OCaml1 OCaml2 OCaml 3 OCaml 4 O b j e c t s a n d c l a s s e s C l a s s e s , t a k e 2 P

  • l

y m

  • r

p h i c v a r i a n t s l a b e l e d a r g u m e n t s P

  • l

y m

  • r

p h i c r e c

  • r

d fi e l d s R e c u r s i v e m

  • d

u l e s L a z y p a t t e r n s F i r s t

  • c

l a s s m

  • d

u l e s G A D T s

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 3 / 17

slide-4
SLIDE 4

What’s new

Language features: Generalized Algebraic Data Types More lightweight support for modules packed as first-class values. Implementation features: Exposing rich typed ASTs and compiler internals (for IDEs and more) Lots of new warnings Revamped ARM code generator Improvements in marshaling and generic hashing. Development process: More external contributions 160 issues fixed, 50 feature wishes granted More rigorous (but slow) release process.

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 4 / 17

slide-5
SLIDE 5

Zoom #1: Generalized Algebraic Data Types (GADTs)

  • J. Garrigue, J. Le Normand (U. Nagoya)

A (seemingly minor) extension to the declaration of variant data types that enables programmers to

1 express properties of data structures via type equalities; 2 have the type-checker enforce these properties.

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 5 / 17

slide-6
SLIDE 6

Without GADTs: tagged interpreters

type expr = | Lit of string | Pair of expr * expr | Fst of expr | Snd of expr and value = (* results of evaluation *) | VString of string (* ‘‘tagged’’ with their types *) | VPair of value * value let rec eval : expr -> value = function (* produces a tagged value *) | Lit s -> VString s | Pair(e1, e2) -> VPair(eval e1, eval e2) | Fst e1 -> (match eval e1 with VPair(v1, v2) -> v1 | _ -> raise Error) | Snd e1 -> (match eval e1 with VPair(v1, v2) -> v2 | _ -> raise Error) (* dynamic typing during evaluation *)

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 6 / 17

slide-7
SLIDE 7

With GADTs: tagless interpreters

Can define τ expr as the type of symbolic expressions that safely evaluate to a Caml value of type τ.

type _ expr = | Lit: string -> string expr | Pair: ’a expr * ’b expr -> (’a * ’b) expr | Fst: (’a * ’b) expr -> ’a expr | Snd: (’a * ’b) expr -> ’b expr

The evaluator, then, needs not tag result values, and cannot fail.

let rec eval : type v. v expr -> v = function | Lit s -> s (* v = string here *) | Pair(e1, e2) -> (eval e1, eval e2) (* v = v1 * v2 here *) | Fst e -> fst (eval e) (* statically safe *) | Snd e -> snd (eval e)

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 7 / 17

slide-8
SLIDE 8

Zoom #2: working with typed ASTs

  • T. Turpin, F. Le Fessant, T. Gazagnaire (OCamlPro)

A new compiler option, -bin-annot, causing the production of a .cmt file containing a rich Abstract Syntax Tree annotated with Source file locations Scoping and binding information for identifiers Types inferred by the typechecker. (Generalizes the -annot option, which generated only a subset of this information, in an Emacs-specific format.)

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 8 / 17

slide-9
SLIDE 9

The OCaml compilation chain, before 4.00

Source Parsetree Typedtree Lambda Bytecode ULambda C-- Mach Linear Assembly Parsetree: (produced by the parser) Very close to source text Annotated by source locations

(file name, line #, column #)

No types, no scoping information Typedtree: (produced by the typechecker) Annotated by (inferred) types Explicit scoping and binding of idents Some source constructs eliminated

(open, include, type constraints)

No source locations All source constructs represented Same location info as in Parsetree

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 9 / 17

slide-10
SLIDE 10

The OCaml compilation chain, in 4.00

Source Parsetree Typedtree Lambda Bytecode ULambda C-- Mach Linear Assembly .cmt file Parsetree: (produced by the parser) Very close to source text Annotated by source locations

(file name, line #, column #)

No types, no scoping information Typedtree: (produced by the typechecker) Annotated by (inferred) types Explicit scoping and binding of idents Some source constructs eliminated

(open, include, type constraints)

No source locations All source constructs represented Same location info as in Parsetree

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 9 / 17

slide-11
SLIDE 11

Using typed ASTs

Current use: for IDEs (e.g. TypeRex, OCamlSpotter) show inferred types; jump to definition; scoping-aware identifier renaming; type-aware completion; etc. Possible future use: for code generation Camlp4-style preprocessing that has access to type & scope info. Parsetree Typedtree Camlp* Caveat: currently, no stable API to work on typed ASTs; must use compiler internal modules.

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 10 / 17

slide-12
SLIDE 12

Using typed ASTs

Current use: for IDEs (e.g. TypeRex, OCamlSpotter) show inferred types; jump to definition; scoping-aware identifier renaming; type-aware completion; etc. Possible future use: for code generation Camlp4-style preprocessing that has access to type & scope info. Parsetree Typedtree Camlp* ??? Caveat: currently, no stable API to work on typed ASTs; must use compiler internal modules.

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 10 / 17

slide-13
SLIDE 13

This release brought to you by . . .

Damien Doligez

Alain Frisch Jacques Garrigue Xavier Leroy Fabrice Le Fessant Xavier Clerc J´ er´ emie Dimino Thomas Gazagnaire Jacques Le Normand Benedikt Meurer Jonathan Protzenko Gabriel Scherer Tiphaine Turpin Wojciech Meyer

(More help is welcome.)

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 11 / 17

slide-14
SLIDE 14

Future directions

A bug-fix release 4.00.1 this Fall. Work in progress on: Name space management Run-time representations of types. Performance improvements (native compiler, run-time system). Shedding more weight off the core system.

(By splitting off some libraries and tools as independent projects.)

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 12 / 17

slide-15
SLIDE 15

Outline

1

OCaml development news

2

OCaml community news

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 13 / 17

slide-16
SLIDE 16

News from the community

(not exhaustive)

Some new or recently open-sourced projects: TypeRex (OCamlPro’s IDE) OPAM (OCamlPro’s package manager) Opa (MLstate’s Web programming framework) Mirage (OCaml as a Xen guest OS) JS-of-OCaml (OCaml running in any browser) Functory and Parmap (parallel computation) ZArith (arbitrary-precision integers) Async (Jane Street’s lightweight cooperative threads)

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 14 / 17

slide-17
SLIDE 17

News from the community

(not exhaustive)

New releases of major libraries and frameworks, such as: Batteries and Core (comprehensive standard libraries) Frama-C (static analysis framework) Ocsigen (Web programming framework) OCaml “companion tools” ODT (Eclipse plug-in) OUnit (unit testing framework) Plasma (distributed file system and map-reduce)

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 15 / 17

slide-18
SLIDE 18

News from the community

(not exhaustive)

Cool factor: OCaml iPhone/iPad apps (psellos.com, M. Hayden, J. Kimmit) TryOCaml (toplevel in browser) Textbooks: Real-World OCaml (J. Hickey, A. Madhavepeddy, Y. Minsky) (soon?) Think OCaml: How to Think Like a Computer Scientist

(N. Monje and A .Downey)

Programmation de droite ` a gauche (et vice-versa) (P. Manoury)

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 16 / 17

slide-19
SLIDE 19

In closing. . .

A lively language; a lively implementation; a very lively community. Some growing pains. Many individual contributions, deserve better integration & accessibility. High hopes in a future OCaml Platform.

  • X. Leroy (INRIA)

The state of OCaml, 2012 OUD 2012 17 / 17