Write software in your favorite language for real Systems Hiwi-jobs and Theses available http://www6.in.tum.de/Main/Weissmam only From Technische Universität München Introduction to Programming lecture with OCaml Then, Bachelor Thesis: OCaml Now, Master Thesis: OCaml 1
module system Fast in the average case Strict Easy to learn Quick native and byte code compilers Wide variety of platforms supported One single language (not 70 language extensions) Macro system Good backwards compatibility 3
names 0install Pfft Flow Hack Haxe Rust (previously) CompCert Frama-C FFTW Unison MLDonkey Coq Alt-Ergo Opalang Grenchman OCaml is a popular language for writing compilers and verification tools. 9
more experienced developers Broad amount of topics covered: functional programming object orientation, runtime Uses Jane Street’s Core Standard library Freely available online 12
Eclipse OCaml Development Tools Merlin Helper that understands OCaml code. Offers sensible completion, type inference, renaming, definition location. Vim Emacs Sublime Text 16
Compiled C implementations .cmo/.cmi: Compiled modules .cma/.cmax: Compiled module archives, native archives .cmt/.cmti: Type information annotation ocamlc, ocamlc.opt ocamlopt, ocamlopt.opt ocamldep … Need to compile each module, specify them in the proper order. 20
tool by Gerd Stolpman ocamlfind finds packages Wrapper around commandline tools, ocamlfind ocamlopt Adds a -package option Reads information from META file Universally established tool Package/dependency problem solved. 21
jenga, GNU Make. OCaml 3.12 came with ocamlbuild Ships with default rules to invoke compiler toolchain _tags file for customization Quite alright for small to medium projects Popular but not ubiquitous 22
test_commutative test_ctx = assert_equal (1+2) (2+1) let suite = ”Example” >::: [ ”addition” >:: test_commutative; ] let _ = run_test_tt_main suite pa_ounit syntax extension for less overhead. 28
QCheck let test = mk_test ~name:”commutative” Arbitrary.(pair small_int small_int) (fun (a, b) -> a + b = b + a) let _ = ignore @@ run test The Kaputt package supports also enumeration-based testing 29
independently on Travis CI. Add this to your .travis.yml, ocaml-travisci-skeleton will take care of the rest (as long as your package is OPAMized). language: c install: wget https://…/.travis-opam.sh script: bash -ex .travis-opam.sh env: - OCAML_VERSION=4.02 - OCAML_VERSION=4.01 - OCAML_VERSION=4.00 - OCAML_VERSION=3.12 30
compiler and packages Uses community-maintained Git repo with build recipes Describes packages: Version, source tarball, hash Dependencies, conflicts Installation scripts & patches SAT solver to solve requests Does not enforce any build system, project structure Handles updates and removals 33
with the compiler. (** Documentation of function @param arg1 What the param is for @param arg2 More documentation *) Best to be used on .mli (module interface) files. Uses custom documentation markup format. Future: OPAM-Doc to generate documentation of every installed package. 36
works, but no definite timeframe. Libraries to parallelize execution to multiple processes exist. Who cares about threads, right? Async evented I/O! Monadic concurrency libraries. 1. Lwt 2. Async 39
channel_id = id_of_channel token channel in endpoint ”channels.history” |> definitely_add ”token” token |> definitely_add ”channel” channel_id |> optionally_add ”count” @@ maybe string_of_int count |> query >|= function | ‘Json_response d -> d |> history_obj_of_yojson | #history_result as res -> res | _ -> ‘Unknown_error let%lwt is processed by a macro to work like bind. 40
typed ML. It’s a serious effort by Microsoft. JVM users have… Yeti? Scala? OCaml-Java generates JVM bytecode based on OCaml 4.01 faster than byte code slower than native code early effort 41