<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Desk Checked &#187; Ocaml</title>
	<atom:link href="http://www.deskchecked.com/category/languages/ocaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.deskchecked.com</link>
	<description>Thomas Lee's programming blog</description>
	<lastBuildDate>Sun, 29 Nov 2009 13:01:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>GTK Hello World in Six Different Languages</title>
		<link>http://www.deskchecked.com/2008/01/23/gtk-hello-world-in-six-different-languages/</link>
		<comments>http://www.deskchecked.com/2008/01/23/gtk-hello-world-in-six-different-languages/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 11:19:17 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[GTK]]></category>
		<category><![CDATA[Ocaml]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.vector-seven.com/2008/01/23/gtk-hello-world-in-six-different-languages/</guid>
		<description><![CDATA[I&#8217;m still somewhat in holiday mode, so this entry is probably going to feel a little cheap for those of you following my more technical posts. I&#8217;m a big fan of GTK+ for user interfaces. If you don&#8217;t have the option or desire to use the Java platform and Swing, GTK+ is one of the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m still somewhat in holiday mode, so this entry is probably going to feel a little cheap for those of you following my more technical posts. I&#8217;m a big fan of <a href="http://www.gtk.org">GTK+</a> for user interfaces. If you don&#8217;t have the option or desire to use the Java platform and Swing, GTK+ is one of the better cross-platform user interface toolkits out there.</p>
<p>It&#8217;s high-level enough that it is easy to build quick, effective GUIs but low-level enough not to get in your way when you need to start messing around at the pixel level. GUIs can be built by hand using code, or designed using <a href="http://glade.gnome.com">Glade</a> and exported to an XML document to be loaded at runtime by any GTK+ binding. Currently it runs on Windows and Linux (the toolkit actually has its roots in GNOME) and has bindings for most popular programming languages. The only major downer is that Mac users are left out in the cold unless they go to the (herculean) effort of getting X11 up and running.</p>
<p>All the little differences between the various GTK+ bindings out there tend to get my goat when I move from one language to another. You would think that a GTK+ example in C could easily be translated to other languages without referencing documentation right? For one reason or another, the GTK+ bindings for other languages tend to diverge from the pleasant consistency of the C API to varying degrees. This post is all about those little differences that crop up even in the simplest applications: GTK&#8217;s take on &#8220;Hello World&#8221; in a few different languages.</p>
<p><strong>C</strong></p>
<p>C, being the language GTK+ is actually written in, is probably the most consistent with function naming across the different objects &#8230; the GTK_* and G_* macros are quite ugly though.</p>
<pre><code>#include &lt;gtk/gtk.h&gt;

int main (int argc, char **argv) {
  GtkWidget *window;
  gtk_init(&#038;argc, &#038;argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Hello, World");
  g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL);
  gtk_widget_show_all (window);

  gtk_main();
  return 0;
}
</code></pre>
<p><strong>C#/Mono</strong></p>
<p>GTK# adds stuff like the Application object and delegates to produce a &#8220;Hello World&#8221; example I had to go digging around in documentation for. Not too bad on the whole, though.</p>
<pre><code>using Gtk;
using GtkSharp;

public class HelloWorld {
  public static void Main(string[] args) {
    Gtk.Window window = new Gtk.Window();
    window.Title = "Hello, World";
    window.DeleteEvent += delegate { Application.Quit(); };
    window.ShowAll();
    Application.Run();
  }
}
</code></pre>
<p><strong>Ocaml</strong></p>
<p>The Ocaml bindings diverge from the original C API much more so than the other languages listed here, most likely due to design decisions that had to be made to provide a C binding to a functional language. My only real grumble is the inconsistency with window#event#connect vs window#connect. I&#8217;m guessing there was a technical reason for that, but it still irks me every time I see it.</p>
<pre><code>let delete_event evt = false

let destroy () = GMain.Main.quit ()

let main () =
  let window = GWindow.window in
  let _ = window#set_title "Hello, World" in
  let _ = window#event#connect#delete ~callback:delete_event in
  let _ = window#connect#destroy ~callback:destroy in
  let _ = window#show () in
  GMain.Main.main ()
;;

let _ = main () ;;
</code></pre>
<p><strong>Perl</strong></p>
<p>Although I find writing Perl to be painful for everything but processing text files in a terminal, I found the Perl GTK bindings to be relatively straightforward.</p>
<pre><code>use strict;
use Gtk2 '-init';

my $window = Gtk2::Window->new;
$window->set_title("Hello, World");
$window->signal_connect('delete-event', sub { Gtk2->main_quit; });
$window->show_all;
Gtk2->main;</code></pre>
<p><strong>Python</strong></p>
<p>I&#8217;m more familiar with PyGTK than with other bindings, so this was a snap. Why they chose GtkObject.connect over GtkObject.signal_connect is a mystery and the pygtk.require(&#8217;&#8230;&#8217;) crap is a little weird, but aside from that there should be nothing surprising here (this is a <em>good thing!</em>). </p>
<pre><code>import pygtk
pygtk.require('2.0')
import gtk

window = gtk.Window()
window.set_title('Hello, World')
window.connect('delete-event', gtk.main_quit)
window.show_all()
gtk.main()</code></pre>
<p><strong>Ruby</strong></p>
<p>RubyGNOME provides a GTK+ binding for Ruby. Take an almost 1:1 port of the C API, take away the ugly casting macros, mix in closures for handling signals and Ruby really is one of the nicest ways to get intimate with GTK+.</p>
<pre><code>require 'gtk2'

window = Gtk::Window.new
window.title = 'Hello, World'
window.signal_connect(:delete-event) { Gtk.main_quit }
window.show_all

Gtk.main</code></pre>
<p>That&#8217;s all for now. There are many more <a href="http://www.gtk.org/bindings.html">language bindings for GTK+</a> out in the wild for languages like Lisp/Scheme, C++, Haskell and Erlang. If you&#8217;re looking around for a GUI toolkit, be sure to give GTK a go. There&#8217;s plenty of documentation available for all the bindings listed here, often with some very detailed and easy to follow tutorials.</p>
<p><strong>UPDATE:</strong> Miguel and she suggested some changes to the C#/Mono and RubyGNOME examples.<br />
<strong>UPDATE 2:</strong> Aristotle suggested an easier way to initialize the Perl GTK bindings.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deskchecked.com/2008/01/23/gtk-hello-world-in-six-different-languages/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>The Many Humps of Ocaml, Part 2</title>
		<link>http://www.deskchecked.com/2007/10/03/the-many-humps-of-ocaml-part-2/</link>
		<comments>http://www.deskchecked.com/2007/10/03/the-many-humps-of-ocaml-part-2/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 11:02:03 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Ocaml]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[TMHOO]]></category>

		<guid isPermaLink="false">http://www.vector-seven.com/2007/10/03/the-many-humps-of-ocaml-part-2/</guid>
		<description><![CDATA[Welcome to part two in my series of Ocaml tutorials! There was an overwhelming response to the first tutorial in the series and I have taken plenty of suggestions on board for this and future tutorials. In this instalment I&#8217;ll be introducing the list data type and the very useful List.iter function from the Ocaml [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to part two in my series of Ocaml tutorials! There was an overwhelming response to the first tutorial in the series and I have taken plenty of suggestions on board for this and future tutorials. In this instalment I&#8217;ll be introducing the <em>list</em> data type and the very useful <em>List.iter</em> function from the Ocaml standard library.</p>
<p><strong>An Introduction to List Initialization and List.iter</strong></p>
<p>Here&#8217;s the source code we&#8217;re going to be breaking down:</p>
<pre><code>let main () =
    let seq = ["a"; "b"; "c"] in
    List.iter print_endline seq ;;

let _ = main ()</code></pre>
<p>Looks scary, doesn&#8217;t it? It&#8217;s actually quite simple, but we&#8217;ll get to the source code in a moment. First, let&#8217;s see the program&#8217;s output. Save this file as tmhoo02.ml and run it like so:</p>
<pre><code>$ ocaml tmhoo02.ml</code></pre>
<p>You should see the following:</p>
<pre><code>a
b
c</code></pre>
<p>Now, let&#8217;s take a look at the interesting bits of the source code:</p>
<pre><code>let seq = ["a"; "b"; "c"] in</code></pre>
<p>As you (hopefully!) learned in <a href="http://www.deskchecked.com/2007/07/06/the-many-humps-of-ocaml-part-1/">part 1</a>, the <em>let</em> syntax binds the variable <em>seq</em> to some expression. The <em>in</em> keyword indicates that this binding is a named local expression whose value to be discarded when the function exits (think &#8220;local variable&#8221;). But what exactly does that expression mean?</p>
<pre><code>["a"; "b"; "c"]</code></pre>
<p>This is the most direct way to initialize a <em>list</em> in Ocaml. Each element in a <em>list</em> is separated by a semi-colon. This particular list has three elements: the strings &#8220;a&#8221;, &#8220;b&#8221; and &#8220;c&#8221;. As our list comprises of string elements, we can say that this is a <em>string list</em>. Note that unlike some dynamically typed languages (e.g. Python and Ruby), every Ocaml list element must be of the same type: you have a list of string elements or a list of integer elements, but you simply can&#8217;t mix the two. Honestly, it won&#8217;t compile.</p>
<pre><code>List.iter print_endline seq ;;</code></pre>
<p>Here we&#8217;re calling the <em>iter</em> function of the <em>List</em> module &#8211; a module which is bundled as part of the Ocaml standard library. This function takes two parameters: the first is another function that accepts a single parameter, the second is a list.</p>
<p>As you might suspect, <em>List.iter</em> iterates over the list, passing each element in the list to the function one by one. To word it another way, inside <em>List.iter</em> we&#8217;re calling <em>print_endline</em> for each element in our list to the equivalent of: print_endline &#8220;a&#8221;, print_endline &#8220;b&#8221;, print_endline &#8220;c&#8221;. This explains the output of our example program.</p>
<p>Finally:</p>
<pre><code>let _ = main ()</code></pre>
<p><em>main</em> is evaluated here and its return value (the &lt;em&gt;unit&lt;/em&gt; value) is ignored by the underscore wildcard. You&#8217;ll notice in part 1 I omitted everything up to the equals operator but, at the behest of others who know better, I&#8217;ve included it here in part two. I&#8217;m not going to say anything more about it, other than the fact that the underscore wildcard is a simple but powerful construct you&#8217;ll likely become very familiar with at a later date. If you&#8217;d prefer to use the syntax from part 1, that should work too (but don&#8217;t come crawling to me when other Ocaml programmers come down on you like a ton of bricks <img src='http://www.deskchecked.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).</p>
<p><strong>Advanced Discussion of the Type System</strong></p>
<p>As a sneak preview into Ocaml&#8217;s type system, I can tell you that <em>List.iter</em> isn&#8217;t restricted to string lists. In fact, it can work with lists containing elements of any type. However, because each element of the list is passed to the function given to <em>List.iter</em> as the first parameter, that function must accept a parameter the same type as a single element in the list. Since print_endline accepts a string, we must use a string list. Or: since we&#8217;re passing in a string list as the second parameter to <em>List.iter</em>, the function passed as the first parameter must itself accept a string as its sole parameter.</p>
<p>Confused? Read that last paragraph again carefully. If you still don&#8217;t understand it, don&#8217;t worry too much: we&#8217;ll cover Ocaml&#8217;s type system more in the next few tutorials.</p>
<p><strong>Until Next Time &#8230;<br />
</strong></p>
<p>So that wraps up tutorial number two. I&#8217;ve already got parts three and four in the pipeline and I can tell you they introduce a fair bit of new material. Take your time trying to understand what was covered in this tutorial and post a comment or two if you have any suggestions, questions or improvements. <img src='http://www.deskchecked.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.deskchecked.com/2007/10/03/the-many-humps-of-ocaml-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>thumper: My Ugly Little Ocaml Web Server</title>
		<link>http://www.deskchecked.com/2007/07/17/thumper-my-ugly-little-ocaml-web-server/</link>
		<comments>http://www.deskchecked.com/2007/07/17/thumper-my-ugly-little-ocaml-web-server/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 05:31:55 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Ocaml]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.vector-seven.com/2007/07/17/thumper-my-ugly-little-ocaml-web-server/</guid>
		<description><![CDATA[Spent the afternoon cobbling together a simple Ocaml web server and &#8211; to spite my normally reclusive attitude when it comes to personal projects &#8211; I thought I&#8217;d share the results. The interesting stuff is in thumper.ml. Refer to line 215 if you&#8217;re interested in implementing your own handlers for primitive resources.
I&#8217;m sure there&#8217;s room [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.deskchecked.com/wp-content/uploads/2007/07/thumper-trunktar.gz" title="Thumper v0.1"></a>Spent the afternoon cobbling together a simple Ocaml web server and &#8211; to spite my normally reclusive attitude when it comes to personal projects &#8211; I thought I&#8217;d share the results. The interesting stuff is in thumper.ml. Refer to line 215 if you&#8217;re interested in implementing your own handlers for primitive resources.</p>
<p>I&#8217;m sure there&#8217;s room for improvement, so I&#8217;ve uploaded a tarball of the <a href="http://bazaar-vcs.org/" title="Bazaar-VCS">bzr</a> repository. You can get it here:Â <a href="http://www.deskchecked.com/wp-content/uploads/2007/07/thumper-trunktar.gz" title="Thumper v0.1">Thumper v0.1</a>. Any suggestions/patches?</p>
<p><strong>Note: </strong>This is not the next part of my series of Ocaml tutorials. That&#8217;s likely to come after I&#8217;ve finished moving. <img src='http://www.deskchecked.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.deskchecked.com/2007/07/17/thumper-my-ugly-little-ocaml-web-server/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Many Humps of Ocaml, Part 1</title>
		<link>http://www.deskchecked.com/2007/07/06/the-many-humps-of-ocaml-part-1/</link>
		<comments>http://www.deskchecked.com/2007/07/06/the-many-humps-of-ocaml-part-1/#comments</comments>
		<pubDate>Fri, 06 Jul 2007 05:08:09 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Ocaml]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[TMHOO]]></category>

		<guid isPermaLink="false">http://www.vector-seven.com/2007/07/06/the-many-humps-of-ocaml-part-1/</guid>
		<description><![CDATA[DRAFT: I&#8217;m still learning Ocaml myself, so some of what I say here may be plain wrong or misguided. I&#8217;m relying on those more experienced with Ocaml to correct my mistakes! If you have plenty of Ocaml experience, please correct my mistakes. By all means, be brutal!
Welcome to the very first part of my (hopefully [...]]]></description>
			<content:encoded><![CDATA[<p><strong>DRAFT:</strong> I&#8217;m still learning Ocaml myself, so some of what I say here may be plain wrong or misguided. I&#8217;m relying on those more experienced with Ocaml to correct my mistakes! If you have plenty of Ocaml experience, please correct my mistakes. By all means, be brutal!</p>
<p>Welcome to the very first part of my (hopefully enlightening) series of tutorials on the Ocaml programming language! In this tutorial we&#8217;ll be learning the Ocaml flavour  of everybody&#8217;s favourite program: Hello World.</p>
<p>Since those interested in Ocaml will likely be coming from such a background, please note that this tutorial is written under the assumption that readers will have experience with other, imperative languages such as Java or C++. Now, on with the code:</p>
<pre><code>let main () =
print_endline "Hello, World!" ;;

main () ;;</code></pre>
<p>Save this file as tmhoo01.ml. You can run this program from the command-line using the following:</p>
<pre><code>$ ocaml tmhoo01.ml</code></pre>
<p>Or compile it to native code:</p>
<pre><code>$ ocamlopt -o tmhoo01 tmhoo01.ml</code></pre>
<p>Predictably, running this program displays &#8220;Hello, World!&#8221; in the console window. It&#8217;s not the output we&#8217;re interested in, however: it&#8217;s Ocaml&#8217;s weird ass syntax! Let&#8217;s take this line by line:</p>
<pre><code>let main () =</code></pre>
<p>This declares a function called &#8220;main&#8221;. <em>let</em> is an Ocaml keyword which defines named expressions (sometimes called <em>let-bindings</em>). In this case, the name of our expression/let-binding is &#8220;main&#8221;.</p>
<p><em>main</em> takes a single parameter: the parentheses <em>()</em> represent what is known as the &#8220;unit value&#8221;. It is the only possible value for the <em>unit</em> type, and has a similar use and meaning to what <em>void</em> has in C/C++. In this case, it means the function <em>main</em> accepts no other parameters. This is necessary because Ocaml functions must always be applied to one or more parameters: thus, when we have no parameters to pass we must resort to using <em>()</em>. If we do not accept this <em>unit</em> parameter at a minimum, the expression in main is evaluated at the next double semi-colon <em>;;</em>. This is not our intention.</p>
<pre><code>  print_endline "Hello, World!" ;;</code></pre>
<p>The print_endline call does as you would expect. Similar to <em>System.out.println</em> or <em>printf</em>. <em>print_endline</em> returns the unit value. Implicitly, our <em>main</em> function has a <em>unit</em> type. This distinction may not completely make sense just yet, but the importance of this will make sense later once we start doing more work with different types.</p>
<p>The <em>;;</em> keyword is used to separate multiple top-level constructs (e.g. let-bindings and class definitions). Later, you will use <em>;</em> to separate expressions within other constructs.</p>
<pre><code>main () ;;</code></pre>
<p>As you would expect, this calls our <em>main</em> function.</p>
<p>So that&#8217;s our first Ocaml program dissected. Thanks for reading! If you have any questions or comments, please post them here: I&#8217;ll surely be revising this article based on your recommendations.</p>
<p><strong>UPDATE 1:</strong> Correction to the descriptions of <em>;</em> and <em>;;</em>. Thanks Paul!<br />
<strong>UPDATE 2:</strong> Removed my haughty claim that Ocaml references are more like C++ pointers than Java references. Cheers Chris!<br />
<strong>UPDATE 3:</strong> Tried to otherwise simplify the tutorial. Less &#8220;blah blah blah&#8221;!<br />
<strong>UPDATE 4:</strong> Remove introduction to references all together. Several people felt it was out of place to introduce a concept like references in the first tutorial. I happen to agree. <img src='http://www.deskchecked.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.deskchecked.com/2007/07/06/the-many-humps-of-ocaml-part-1/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>The Many Humps of Ocaml, Prelude</title>
		<link>http://www.deskchecked.com/2007/06/15/the-many-humps-of-ocaml-prelude/</link>
		<comments>http://www.deskchecked.com/2007/06/15/the-many-humps-of-ocaml-prelude/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 16:54:46 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Compilers]]></category>
		<category><![CDATA[Ocaml]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[TMHOO]]></category>

		<guid isPermaLink="false">http://www.vector-seven.com/2007/06/15/the-many-humps-of-ocaml-prelude/</guid>
		<description><![CDATA[My Introduction to Haskell
A few years ago when I was studying for my degree at university, I took a class on functional programming using the Haskell programming language. It was very instructional, if a little abrupt. I struggled with the language initially, despite being very comfortable with a number of other (imperative) languages. Once it [...]]]></description>
			<content:encoded><![CDATA[<p><strong>My Introduction to Haskell</strong></p>
<p>A few years ago when I was studying for my degree at university, I took a class on functional programming using the <a href="http://www.haskell.org">Haskell</a> programming language. It was very instructional, if a little abrupt. I struggled with the language initially, despite being very comfortable with a number of other (imperative) languages. Once it started to <em>click</em>, however, I started to get a glimpse of the power must inevitably draw many toward the functional paradigm.</p>
<p>The project we were given was to build on an existing compiler (written in Haskell) for a simple, strictly-typed programming language devised by the lecturer. Once the lexer &amp; parser had been extended with the new features, we also had to generate custom bytecode for the new features. Finally, we had to write an interpreter for the bytecode in C or <a href="http://java.sun.com">Java</a>. Compiler development was something I had always felt was out of my reach but the more I toyed with the code, the more comfortable I became with Haskell&#8217;s fairly alien syntax and &#8211; in turn &#8211; with extending the compiler itself.</p>
<p><strong>The Joy of the Functional Paradigm</strong></p>
<p>Within an hour or two, my extensions to the mini-language meant that I could now assign values to variables. Another few hours, and I had a for loop. Another, and I had enumerations and constants. The byte code generator, however, required me to step out of the mindset I had been in for half of the day: How do I now turn the <acronym title="Abstract Syntax Tree">AST</acronym> generated by the parser into bytecode?</p>
<p>By this stage I was becoming comfortable enough with Haskell that I was able to work out the basics from the code used for the original language constructs. I was beginning to get a rough idea by the end of the first day and another day or two later, the project was finished. Thinking about it now, this was perhaps the only university unit that I really, <em>really</em> enjoyed. It was fun. Haskell and the constructs of the parser framework we were using were powerful tools. I had achieved something <em>completely</em> new and exciting using a language I was almost totally unfamiliar with.</p>
<p><strong>The Return to Functional Languages: Ocaml</strong></p>
<p>Fast forward maybe three years. I haven&#8217;t really touched Haskell since. Sure, I tried &#8211; but without a practical application for it there was no real drive. The passion I that had grown for compilers led me to the <a href="http://www.python.org">Python</a> source code and, eventually, to <a href="http://python.org/dev/peps/pep-0341/">PEP 341</a> where I was able to scratch a long-standing itch in the form of the try/except, try/finally statements. Due to the recent introduction of an AST, the changes were generally limited to the grammar and the AST and &#8211; although satisfying &#8211; were relatively trivial to implement.</p>
<p>As far as code contributions for Python go, I&#8217;m sure that I just need more practice and experience with the source. However, I still long to test the waters with functional languages again. Haskell, while it proved to be powerful and fun, lacks the supporting libraries to make useful (in the short term, anyway) only to academics and those willing to slog it out writing their own support code. Scheme was intriguing, but I&#8217;m still not sure which implementation I should be using nor did it have a useful library. Then I started hearing about <a href="http://caml.inria.fr/ocaml/">Ocaml</a>. A powerful functional programming language with support for imperative and/or object-oriented programming, Ocaml also sports a decent (if a little bare and disorganized) framework for all the basics.</p>
<p><strong>A Lack of Tutorials</strong></p>
<p>Documentation for Ocaml&#8217;s libraries exist, but tutorials for learning Ocaml properly are few and far between. <a href="http://www.ocaml-tutorial.org">http://www.ocaml-tutorial.org</a> offers lots of information for those patient enough to read it, but I found it a little hard going.Further, there was little in the way of web, network/socket, graphics and UI programming.</p>
<p><strong>The Big Tutorial Idea</strong></p>
<p>I&#8217;m going to try and learn Ocaml myself using whatever resources I can find and hopefully distill the information and knowledge I come across in an easy-to-follow manner. Obviously I&#8217;ll be learning as I go, so the more jaded Ocaml and functional programmers should certainly point out the foolish errors of my ways.</p>
<p>Eventually I&#8217;d like to compile these posts into a proper tutorial for newcomers to Ocaml &#8211; although not necessarily newcomers to programming. From my limited experience with Ocaml, I can already see it&#8217;s a powerful language with much to offer. Keep an eye out for part 1 of TMHO later next week! Any suggestions/comments?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deskchecked.com/2007/06/15/the-many-humps-of-ocaml-prelude/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
