Sunday, 21 November 2010

OCaml on the iPad

The OCaml Example app in the iPad store lets you write and run OCaml programs on your iPad:

Friday, 6 August 2010

Data structures: Heaps

The OCaml Journal just published an article about data structures:

"A min-heap is a tree-based data structure that satisfies the constraint that the children at any given branch are always larger than their parent and, consequently, the minimum element is at the root. Heaps are most notable as an efficient way to implement priority queues which, in turn, underpin a variety of algorithms including some seen in previous OCaml Journal articles. This article examines skew heaps, leftist heaps, pairing heaps and binomial heaps. Higher-order modules are used to create reusable implementations..."

To read this article and more, subscribe to The OCaml Journal today!

Monday, 2 August 2010

OCaml 3.12 released!

A new version of the OCaml distribution was released today, OCaml 3.12.0. This release includes many exciting developments to the language as well as a multitude of other improvements:

  • Improved record patterns.
  • Explicit method override.
  • Local open.
  • Direct polymorphic recursion via type annotations.
  • First-class modules.
  • Named types as parameters to functions.

Friday, 30 July 2010

Rigid body dynamics

The OCaml Journal just published an article about game physics:

"A common technique to simulate the dynamics of objects is to model them as interacting rigid components. This article describes the design and implementation of a simple OCaml program that uses rigid body dynamics to simulate balls bouncing around in 2D, using OpenGL for 2D visualization..."

To read this article and more, subscribe to The OCaml Journal today!

Thursday, 8 July 2010

The diff tool

The OCaml Journal just published an article about sequence algorithms:

"The unix program diff identifies differences between text files, line by line. This tool is most useful for comparing two versions of a program. This article develops a simple implementation of the diff tool based upon the longest common subsequence (LCS) algorithm and examines the output from it..."

To read this article and more, subscribe to The OCaml Journal today!

Friday, 25 June 2010

Tuning the OCaml memory allocator for large data processing jobs

Michael Ekstrand has published an interesting blog article about tuning the OCaml garbage collector for large-scale computations.

Quicksort

The OCaml Journal just published an article about sorting:

"The quicksort algorithm was invented by Tony Hoare in 1960 and remains one of the most celebrated algorithms and is still of great practical value. Implementing some of the many variations of the quicksort algorithm serves as an excellent introduction to programming in OCaml..."

To read this article and more, subscribe to The OCaml Journal today!

Monday, 14 June 2010

Visualizing the 2D Fourier Transform

The OCaml Journal just published an article about the visualization of numerical methods:

"The Fourier transform is one of the most important numerical methods and underpins most forms of spectral analysis. This article describes a simple image compression technique that uses the 2D Fast Fourier Transform (FFT) to remove the high-frequency components of an image, visualizing the result using GTK..."

To read this article and more, subscribe to The OCaml Journal today!

Tuesday, 8 June 2010

ICFP draft from Citrix

Citrix have published a draft of a report due to appear at ICFP describing their use of OCaml in industry, specifically the Management Tools Team (MTT) responsible for the 130kLOC of OCaml code that runs XenServer. The free and commercial editions of the product are deployed in over 40,000 companies worldwide.

Interestingly, none of the perceived risks associated with using a non-mainstream programming language turned out to be a problem. Good OCaml programmers were in abundance. XenSource was acquired by Citrix without any concern about the use of OCaml. Other teams within the company had no problem contributing to the OCaml code base. The OCaml tool chain turned out to be mature enough to support the project.

Sunday, 6 June 2010

OCaml in industry 2007-2010

Looking back, there have been a number of significant advances in the use of OCaml in industry over the past few years:

And, of course, Microsoft released the world's first mainstream functional programming language F# in April 2010 and it is a close relative of OCaml. That had the knock-on effect of boosting interest in OCaml considerably.

Sunday, 23 May 2010

Sliding Median

The OCaml Journal just published an article about sliding window algorithms:

"Sliding window algorithms are a class of algorithms that treat streams of data by computing a statistic across a window for each position of the window within the data stream. Moving averages are sliding window algorithms that compute an average over each window. This article examines the moving median algorithm that tracks the median value in a window as it slides across a stream of data. Several possible solutions are examined and their performance is studied on an example data set..."

To read this article and more, subscribe to The OCaml Journal today!

Thursday, 13 May 2010

Artificial Intelligence: Neural Networks

The OCaml Journal just published an article about artificial intelligence:

"Artificial neural networks are a relatively simple and early form of artificial intelligence modelled directly on the structure of an organic brain. A neural network is composed of many interconnected neurons. Each neuron acts as a simple linear classifier by summing its weighted inputs and firing an output accordingly. The functions involved are essentially ad-hoc but are usually modelled on those of real neurons. This article describes the design and implementation of a neural network that uses an unconventional functional approach to handle vector-matrix operations that allows temporary data structures to be avoided..."

To read this article and more, subscribe to The OCaml Journal today!

Saturday, 24 April 2010

Compiler development: part 3

The OCaml Journal just published an article about HLVM:

"This article continues our series on compiler development using HLVM. An example is provided that breaks the current compiler. The bug is investigated using different techniques and a well-known solution is implemented. The resulting compiler is then tested on a substantially more complicated symbolic computation and is found to obtain the correct result. Moreover, the time taken to perform this symbolic computation using HLVM is found to be very competitive despite the fact that HLVM was not at all designed for this purpose...."

To read this article and more, subscribe to The OCaml Journal today!

OCaml meeting 2010 debriefing

Members of the OCaml community met with the core developers at this year's OCaml Meeting 2010 on April 16th. Attendance was up to the maximum capacity of 80 people this year! The meeting was funded by the 11 corporate members of the CAML Consortium that now includes MLState as a new addition this year.

Slides and references for the lectures given by Xavier Leroy, Sylvain Le Gall, Stefano Zacchiroli, Julien Robert, Guillaume Von Tokarski, Sylvain Conchon, Jean-Christophe Filliâtre, Fabrice Le Fessant, Gerd Stolpmann, Dario Teixeira, Daniel Bünzli, David Rajchenbach-Teller, Philippe Wang, Jérémie Dimino, William Le Ferrand and Anil Madhavapeddy are available here.

Of particular interest was the keynote speech by Xavier Leroy (read the slides) about the forthcoming OCaml 3.12 release that introduces lots of exciting new features to the OCaml programming language such as first-class modules.

Saturday, 10 April 2010

The A* algorithm

The OCaml Journal just published an article about path finding:

"The A* algorithm is often used for route finding in game AI and is a generalization of Dijkstra's shortest-path algorithm from graph theory. This article describes a simple implementation of the A* algorithm written in OCaml that makes extensive use of the module system including higher-order modules (functors) in order to provide a reusable implementation of this algorithm that is generic over the kinds of graphs that it can handle. Finally, an example application is provided that finds a route around a hill...."

To read this article and more, subscribe to The OCaml Journal today!

Thursday, 8 April 2010

Unix systems programming in OCaml

The English translation of the introductory book Unix systems programming in OCaml by Xavier Leroy and Didier Rémy was just completed and is now freely available on-line.

This book is an excellent complement to our own OCaml for Scientists book.

Monday, 29 March 2010

Compiler development: part 2

The OCaml Journal just published an article about HLVM:

"This article is the second in a series describing the design and implementation of a complete compiler using the freely-available HLVM project described in previous articles. This article extends the compiler implemented in part 1 of the series with support for variant types and basic pattern matching. This requires changes to the representation of the compiler's input, the lexer, the parser, the compiler and the REPL. The language implemented by the resulting compiler is substantially more expressive than the previous version and allows monomorphic ML-style programs to be compiled and executed..."

To read this article and more, subscribe to The OCaml Journal today!

Monday, 15 March 2010

Word games

The OCaml Journal just published an article about string-based algorithms:

"String manipulation is a common task in programming and, in particular, when scripting. Solving word puzzles is an excellent way to learn how these kinds of problems can be approached. This article uses the example of word games to develop a series of program that manipulate strings using different techniques in OCaml, including sorting and searching..."

To read this article and more, subscribe to The OCaml Journal today!

Saturday, 6 March 2010

Implementing Hindley-Milner type inference

The OCaml Journal just published an article about type checking:

"This article walks through the design and implementation of the Hindley-Milner type inference algorithm written in OCaml. This algorithm is the foundation of type inference most modern functional programming languages including OCaml. The algorithm acts upon expressions and types using type scheme, substitutions and type environments to infer the type of a given expression..."

To read this article and more, subscribe to The OCaml Journal today!

Sunday, 7 February 2010

Recursive descent parsing with OCaml's streams

The OCaml distribution includes a mutable stream type that allows sequences to be dissected efficiently. The camlp4 syntax for OCaml includes support for pattern matching over streams.

The following example uses the camlp4 stream-parsing syntax extension to implement a recursive descent parser for a simple calculator:

let rec factor = parser | [< ''('; e = expr; '')' >] -> e | [< 'c >] -> int_of_string (String.make 1 c) and term = parser | [< e1 = factor; e = term_aux e1 >] -> e and term_aux e1 = parser | [< ''*'; e2 = term >] -> e1 * e2 | [< ''/'; e2 = term >] -> e1 / e2 | [< >] -> e1 and expr = parser | [< e1 = term; e = expr_aux e1 >] -> e and expr_aux e1 = parser | [< ''+'; e2 = expr >] -> e1 + e2 | [< ''-'; e2 = expr >] -> e1 - e2 | [< >] -> e1 let rec statement = parser | [< e = expr; '';'; ''.'; stream >] -> Printf.printf "= %d\n%!" e; statement stream let rec read() = match input_char stdin with | ' ' | '\t' | '\n' -> [< read() >] | c -> [< 'c; read() >] let () = statement (read())

This program may be compiled and run as follows:

$ ocamlc -g -dtypes -pp camlp4o parser.ml -o parser $ ./parser 1+2+3;. = 6 1+2*3;. = 7 1+2*3+4;. = 11

Force-based network visualization

The OCaml Journal just published an article about the interactive visualization of networks:

"Visualizing a graph or network of interconnected nodes is a fascinating and important challenge with a wide variety of practical applications. This article looks at a simple but effective force-based approach to the visualization of networks and uses OpenGL to display the results in real-time as they emerge and GTK+ to provide interactive user control. The result is a compelling interactive animation of the layout algorithm as it progresses..."

To read this article and more, subscribe to The OCaml Journal today!

Saturday, 30 January 2010

MLState release their first product: OPA

The One Pot Application (OPA) from MLState is a complete development platform for web applications and services:

Development in OPA requires no plumbing. Applications developed with OPA are automatically checked for safety and security before they are executed. Applications developed with OPA are automatically (and provably) immune to cross-site scripting, to SQL injections and to most existing forms of attacks. And OPA provides language support for storage, communication between client and server (Ajax and Comet), concurrency, distribution, mobility, etc.

Read more from MLState or watch the video.

Tuesday, 26 January 2010

High-performance parallel programming with HLVM

The OCaml Journal just published an article about HLVM:

"This article describes how a global adjustment of the calling convention brings the performance of the multicore-capable HLVM within 17% of its original single-threaded performance. A simple parallelization of the new ray tracer benchmark is then described that obtains a substantial 6.3× speedup on 8 cores, demonstrating the potential of the new design for high-performance parallel computing..."

To read this article and more, subscribe to The OCaml Journal today!

More OCaml jobs

The world's second largest OCaml employer (Citrix) have announced that they are hiring more OCaml programmers in the UK to maintain and develop their code base that has grown to hundreds of thousands of lines of OCaml code.

Martin Jambon also announced recently that MyLife (formerly Wink) are also looking for an OCaml developer.

Wednesday, 20 January 2010

Low-level optimization tips and tricks: part 4

The OCaml Journal just published an article about optimization:

"The OCaml programming language is unusually well suited to high-performance computing among functional programming languages because it provides a highly efficient code generator with a performant run-time and garbage collector. This makes it feasible to write high performance programs entirely in OCaml without having to drop to lower-level languages like C and Fortran for performance-critical sections of code. This article focuses on the internal representation of data structures. An overview of OCaml's data representation strategy is given. Tools to examine values in the heap, including OCaml's own Obj module, are described. Then several approaches to optimization that are related to data representations are covered, including closures, polymorphic variants, bounds checking, functors and integer arithmetic..."

To read this article and more, subscribe to The OCaml Journal today!

OCaml Batteries included 1.0.0 released

The Batteries Included project that has intended to provide an extensive defacto-standard library for OCaml for over two years has finally reached version 1!

This library includes a wealth of indispensable features with extensive documentation covering topics such as:

  • Mutable and immutable data structures (reusable AVL trees, bit sets, string buffers, extensible arrays, lazy lists, polymorphic sets and maps, ropes).
  • Mathematics (extensive complex number support).
  • Abstractions (enumerations).
  • File and IO related helper functions.
  • Pretty printers and functional unparsers.
  • Memory management helper functions.
  • Consistent interfaces/signatures.
  • Unicode support.

Download your copy here!

Sunday, 3 January 2010

Garbage collecting multithreaded programs

The OCaml Journal just published an article about HLVM:

"Executing threads in parallel is the cornerstone of efficient parallel programming on shared-memory machines including today's multicores. This article describes how a simple stop-the-world garbage collector can be implemented in HLVM, allowing code generated from an OCaml program to leverage multicores easily..."

To read this article and more, subscribe to The OCaml Journal today!

Parsing and visualizing binary Geographic Information System data

The OCaml Journal just published an article about parsing binary data:

"Detailed vector descriptions of worldwide geographical data are freely available in the Shapefile format. This article describes how polygonal data can be parsed from the binary Shapefile format and visualized using OpenGL and GLU easily and efficiently with OCaml. The result is a simple program that can be used as the basis for a wide variety of Geographic Information System (GIS) applications from cartography to climatology..."

To read this article and more, subscribe to The OCaml Journal today!