<p>For me, programming is fun. I enjoy doing it, every single second. All the way
from designing over experimenting to debugging why it does not do what I want.
In the end, the computer is dumb and executes only what you (or code from
someone else which you rely on) tell it to do.</p>
<p>To abstract from assembly code, which is not portable, programming languages were
developed. Different flavoured languages vary in
expressive power and static guarantees. Many claim to be general purpose or
systems languages; depending on the choices of
the language designer and tooling around the language, it is a language which lets you conveniently develop programs in.</p>
<p>A language designer decides on the builtin abstraction mechanisms, each of which
is both a burden and a blessing: it might be interfering (which to use? <code>for</code> or <code>while</code>, <code>trait</code> or <code>object</code>),
orthogonal (one way to do it), or even synergistic (higher order functions and anonymous functions). Another choice is whether the language includes a type
system, and if the developer can cheat on it (by allowing arbitrary type casts, a <em>weak</em> type system). A strong static type system
allows a developer to encode invariants, without the need to defer to runtime
assertions. Type systems differ in their expressive power (<a href="https://en.wikipedia.org/wiki/Dependent_type">dependent typing</a> are the hot research area at the moment). Tooling depends purely
on the community size, natural selection will prevail the useful tools
(community size gives inertia to other factors: demand for libraries, package manager, activity on stack overflow, etc.).</p>
<p>As already mentioned in <a href="/Posts/About">other</a>
<a href="/Posts/OperatingSystem">articles</a> here, it is a
combination of sufficiently large community, runtime stability and performance, modularity,
carefully thought out abstraction mechanisms, maturity (OCaml recently turned 20), and functional features.</p>
<p>The latter is squishy, I'll try to explain it a bit: you define your concrete
<em>data types</em> as <em>products</em> (<code>int * int</code>, a tuple of integers), <em>records</em> (<code>{ foo : int ; bar : int }</code> to name fields), sums (<code>type state = Initial | WaitingForKEX | Established</code>, or variants, or tagged union in C).
These are called <a href="https://en.wikipedia.org/wiki/Algebraic_data_type"><em>algebraic data types</em></a>. Whenever you have a
state machine, you can encode the state as a variant and use a
pattern match to handle the different cases. The compiler checks whether your pattern match is complete
(contains a line for each member of the variant). Another important aspect of
functional programming is that you can pass functions to other functions
(<em>higher-order functions</em>). Also, <em>recursion</em> is fundamental for functional
programming: a function calls itself -- combined with a variant type (such as
<code>type 'a list = Nil | Cons of 'a * 'a list</code>) it is trivial to show termination.</p>
<p><em>Side effects</em> make the program interesting, because they
communicate with other systems or humans. Side effects should be isolated and
explicitly stated (in the type!). Algorithm and protocol
implementations should not deal with side effects internally, but leave this to an
effectful layer on top of it. The internal pure functions
(which receive arguments and return values, no other way of communication) inside
started with a new library. Editor integration (at least for emacs, vim, and
atom) is via <a href="https://github.com/the-lambda-church/merlin/wiki">merlin</a>
available.</p>
<p>A very good starting book is <a href="http://ocaml-book.com/">OCaml from the very
beginning</a> to learn the functional ideas in OCaml (also
its successor <a href="http://ocaml-book.com/more-ocaml-algorithms-methods-diversions/">More
OCaml</a>).
Another good book is <a href="https://realworldocaml.org">real world OCaml</a>, though it
is focussed around the "core" library (which I do not recommend due to its
huge size).</p>
<p>There are <a href="https://ocaml.org/learn/tutorials/guidelines.html">programming
guidelines</a>, best to re-read
on a regular schedule. Daniel wrote <a href="http://erratique.ch/software/rresult/doc/Rresult.html#usage">guidelines</a> how to handle with errors and results.</p>
<p><a href="https://opam.ocaml.org">Opam</a> is the OCaml package manager.
The <a href="https://opam.ocaml.org/packages/">opam repository</a> contains over 1000
libraries. The quality varies, I personally like the small libraries done by
<a href="http://erratique.ch/software">Daniel Bünzli</a>, as well as our
<p>A <a href="https://github.com/rudenoise/mirage-dashboard">dashboard</a> for MirageOS is
under development, which will hopefully ease tracking of what is being actively
developed within MirageOS. Because I'm impatient, I setup an <a href="https://github.com/miragebot.private.atom?token=ARh4hnusZ1kC_bQ_Q6_HUzQteEEGTqy8ks61Fm2LwA==">atom
feed</a>
which watches lots of MirageOS-related repositories.</p>
<p>I hope I gave some insight into OCaml, and why I currently enjoy it. A longer read on applicability of OCaml is our Usenix 2015 paper
<a href="https://www.usenix.org/conference/usenixsecurity15/technical-sessions/presentation/kaloper-mersinjak">Not-quite-so-broken TLS: lessons in re-engineering a security protocol
<li>Canopy now sends out appropriate <a href="https://github.com/Engil/Canopy/pull/23">content type</a> HTTP headers
</li>
<li><a href="https://github.com/mirage/mirage-http/releases/tag/v2.5.2">mirage-http 2.5.2</a> was released to <a href="https://opam.ocaml.org/packages/mirage-http/mirage-http.2.5.2/">opam</a> which fixes the resource leak
</li>
<li>regression in <a href="https://github.com/mirage/mirage-net-xen/issues/39">mirage-net-xen 1.6.0</a>, I'm back on 1.4.1
</li>
<li>I stumbled upon <a href="https://github.com/mirage/mirage/issues/396">too large crunch for MirageOS</a>, no solution apart from using a FAT image (<a href="https://github.com/mirage/mirage/issues/489">putting the data into an ELF section</a> would solve the issue, if anyone is interested in MirageOS, that'd be a great project to start with)
</li>
<li>unrelated, <a href="https://opam.ocaml.org/packages/x509/x509.0.5.2/">X.509 0.5.2</a> fixes <a href="https://github.com/mirleft/ocaml-x509/commit/1a1476308d24bdcc49d45c4cd9ef539ca57461d2">this bug</a> in certificate chain construction