<?xml version="1.0" ?>
<rss version="2.0">
<channel>
	<title>Phil Dawes Stuff: ocaml</title>
	<link>http://phildawes.net/blog//tag/ocaml/</link>
	<description>Entries of Phil Dawes Stuff tagged with 'ocaml'</description>


	<item>
		<title>Why Objective Caml?</title>
		<description><![CDATA[
<p>The previous posts may have given the impression that I'm learning various languages for the sake of higher academic enlightenment. Actually the core reason is much simpler: I've got some performance intensive code to write, python just didn't cut it, and in the <a href="http://shootout.alioth.debian.org/">computer language shootout benchmarks</a> <a href="http://caml.inria.fr/ocaml/index.en.html">OCaml</a> consistently kicks the collective butts of all the other popular language implementations I'm familiar with, including <a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&amp;lang=ocaml&amp;lang2=python">python</a>, <a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&amp;lang=ocaml&amp;lang2=chicken">scheme</a>, <a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&amp;lang=ocaml&amp;lang2=perl">perl</a>, <a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&amp;lang=ocaml&amp;lang2=ruby">ruby</a> and <a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&amp;lang=ocaml&amp;lang2=javaclient">java</a>. </p>

<p>That's not a good enough reason on its own, but from first impressions Objective Caml appears to tick enough other boxes to be a real 'primary language' contender.</p>
]]></description>
		<link>http://phildawes.net/blog/2006/08/29/why-objective-caml/</link>
		<guid>http://phildawes.net/blog/2006/08/29/why-objective-caml/</guid>
	</item>

	<item>
		<title>Currying</title>
		<description><![CDATA[
<p>I've been playing around with the <a href="http://en.wikipedia.org/wiki/ML_programming_language">ML language</a> recently, using the <a href="http://caml.inria.fr/">OCaml</a> implementation.</p>

<p>Picking up ML illustrates to me why it's useful to learn a number of different languages in order to experience various styles of programming - it's sometimes not enough that a language merely 'supports' a particular style; sometimes the language must <em>live</em> that style for the user to fully get it.</p>

<p>For example, lots of languages support '<a href="http://en.wikipedia.org/wiki/Currying">currying</a>' of functions by allowing the user to return anonymous closures. However ML is the first language I've used that embraces currying as the basis for implementing multi-argument functions - i.e. in ML, multi-argument functions are literally just nested single argument functions. </p>

<p>For example, in the following expression:</p>

<pre><code>
let sum = fun i j -> i + j
</code></pre>

<p>the type of 'sum' is:</p>

<pre><code>
int -> int -> int 
</code></pre>

<p>..meaning that 'sum' is a function that takes an integer and returns a function which takes an integer and returns an integer.</p>

<p>In addition OCaml's function-call syntax doesn't use brackets, which allows the call to be considered by the user as both as a multiple-arg function call or as a bunch of nested calls.
E.g. in </p>

<pre><code>
sum 3 4
</code></pre>

<p>the above could be read either as 'invoke the 'sum' function with the arguments 3 and 4', or alternatively as 'invoke the 'sum' function with an argument 3, and then invoke the result of that with the argument 4'.</p>
]]></description>
		<link>http://phildawes.net/blog/2006/08/29/currying/</link>
		<guid>http://phildawes.net/blog/2006/08/29/currying/</guid>
	</item>


</channel></rss>
