100 likes | 410 Views
OCaml. What is OCaml ?. OCaml : Objective Caml Caml : Categorical Abstract Macine Language on CAM ML: meta-language Derived Languages: F#( ms ), SML, MetaOCaml , AtomCaml. OCaml Simple Examples. print_endline "Hello World!". OCaml Imperative. let rec gcd a b =
E N D
What is OCaml? OCaml: Objective Caml Caml : Categorical Abstract Macine Language on CAM ML: meta-language Derived Languages: F#(ms), SML, MetaOCaml, AtomCaml
OCaml Simple Examples print_endline"Hello World!" OCaml Imperative let rec gcd a b = if a=0 then b else if a>b then gcd b a else gcd (b mod a) a Python defgcd(a,b): if a == 0: return b if a > b: return gcd(b,a) return gcd(b % a, a) OCaml functional let rec gcd a b = match a with 0 -> b | x when x > b -> gcd b a | _ -> gcd (b mod a) a
OCaml • Inventors: Xavier Leroy, JérômeVouillon, Damien Doligez, Didier Rémy and others • Maintainer: INRIA (法国国立计算机及自动化研究院) • Type: Static, Strong, Inferred • Paradigm: imperative, functional, object-oriented • OCaml is not a pure functional language • OCaml does have for and while loops, but I won’t show them here
Features, Supports & Libraries? The goal of the OCaml-Java project is to…Objective Camlis an excellent language but it sometimes lacks the library for a given task. On the other hand, Java is a weaker language but benefits from a tremendous community, and this manpower is able to deliver libraries for almost any task… • Interpreter & Compiler • Camlp4: parser. Extend Ocaml • ocamllex, ocamlyacc • debugger • doc generator • profiler
Multithread • OCamlbytecode and native code programs can be written in a multithreaded style, with preemptive context switching. However, because the garbage collector of the INRIA OCaml system (which is the only currently available full implementation of the language) is not designed for concurrency, symmetric multiprocessing is not supported.OCamlthreads in the same process execute by time sharing only. There are however several libraries for distributed computing such as Functory and ocamlnet/Plasma (blog).
Who use Ocaml? • Unikernels: Library Operating Systems for the Cloud (ASPLOS 2013)