Friday, 28 September 2007

Ray tracer language comparison ported to Scala

Derek Young has kindly ported the first Java implementation of our ray tracer language comparison to two alternative languages that both also target the JVM.

  • Scala: a statically-typed functional programming language.
  • Groovy: a dynamic programming language.

Interestingly, the Scala translation is not only shorter than the equivalent Java but also slightly faster. The same correlation is seen on .NET, where F# is often slightly faster than C# because it can perform valuable high-level optimizations not exposed by lower-level languages like C#, e.g. optimizing pattern matches.

Interest in Scala continues to grow and we are considering writing a Scala for Scientists book, following our OCaml for Scientists and F# for Scientists books. If you would like to learn about technical computing using Scala then please show your support by commenting on this blog post.

Wednesday, 19 September 2007

Functional programming in industry

Microsoft's recent decision to make F# one of its mainstream programming languages for Visual Studio will increase the acceptance of modern functional programming languages for ordinary industrial development. In the mean time, it is interesting to see where functional programming languages are already being used in industry.

Perhaps the most common functional programming language in industry is JavaScript, used to power many of the world's websites.

Flying Frog Consultancy are a consultancy, book and software company specializing in the ML family of languages, primarily OCaml and F#. We have product lines including books and on-line magazines teaching OCaml and F# as well as software written in or for these languages.

Microsoft have a considerable investment in the CAML family of functional programming languages. Specifically the OCaml language and Microsoft's own CAML-derivative for .NET called F#. Microsoft's driver verification software is written in OCaml. Microsoft trust the $2bn advertising market on MSN Live to F# code. Microsoft's XBox group write F# programs to analyze the statistics of on-line XBox Live players. Many Microsoft Research projects are written in OCaml and F#, such as the Stochastic Pi Machine (SPiM).

Intel use high-level modelling and verification tools called reFLect written in OCaml for the hardware verification of their integrated circuits, part of their Forte environment.

IBM sell a Migration Toolkit written in OCaml. This is designed to help with the static analysis and conversion of databases.

MATLAB from The MathWorks uses the FFTW library to provide its FFT implementation. FFTW is written in OCaml.

XenSource's value-add over the free edition of Xen is largely a distributed, cross-platform, multi-programming-language management tool stack written in OCaml. XenSource recently sold to Citrix for $500M.

Jane St. Capital have over 20 functional programmers working in offices around the world on finance using OCaml. They recently expanded with a new office in London. Several other financial houses use functional programming languages extensively. Outside ML, Haskell is also popular in the financial sector following a seminal paper by Simon Peyton-Jones.

LexiFi use OCaml extensively for the modeling of financial products (swaps, options etc). Their solution includes software for modeling the life cycle of a product, as well as pricing them. It is closely related to the solution described in the paper by Jean-Marc Eber and Simon Peyton-Jones.

Dassault Systemes sell a computer-aided manufacturing environment called Delmia that contains a domain-specific language implemented in OCaml called CellControl for programming assembly-line automata and robots.

Astree is a static analyzer to remove large classes of important bugs from mission critical code used by Airbus.

Coherent Graphics Ltd. distribute libraries, tools and services for manipulating PDF documents, written in OCaml.

Wink Technologies provide a people search engine written largely in OCaml.

SkyDeck create products for the mobile phone industry using software written in OCaml.

Credit Suisse First Boston use Haskell in finance.

Linspire is a commercial Linux distribution written partly in Haskell.

Erlang is used extensively by Ericsson for handling telecoms and has recently become trendy in industry.

The future is bright for functional programming

Given the recent surge in interest, several companies have expressed a desire to create product lines centered around various functional programming languages. Although there are still a relatively small number of companies generating revenue from functional programming, we have found it remarkably easy to create successful products in this area. Naturally, Flying Frog have many fingers in many pies and we find it very encouraging that the functional pies have turned out to be the most efficient at creating money time after time.

OCaml remains our most profitable functional programming language, with our book OCaml for Scientists and The OCaml Journal currently accounting for 67% of our revenue from product sales.

F# is our second most profitable language, with sales of The F#.NET Journal and F# for Visualization accounting for 28% of our current sales.

However, the growth of functional programming languages is most interesting. Following a four-fold increase in sales of all OCaml-related products over the year to April 2007, we are now seeing a plateau. Although development of the OCaml language itself has slowed, we believe this will not deter industry from continuing to adopt the OCaml programming language. Indeed, XenSource are one of the largest commercial users of OCaml and the company recently sold for $500M.

Interest in F# is now exploding. Our F#-related products are all new so we cannot derive long-term trends from sales but we have seen a four fold increase in search engine referrals from searches for F# over the past six months alone. We believe that interest in F# will grow even faster because we are predicting the imminent productization of this language by Microsoft.

Overall, functional programming in industry is clearly going from strength to strength. The oft-cited advantages of functional languages no doubt underpin this but the advent of multicore computing is an unquestionable driving force that tips the balance for many talented startups wanting to create future-proof solutions for their customers.

The future is bright for functional programming languages on all platforms. We shall certainly continue work related to OCaml and F# and may even diversify into other functional languages such as Scala or Haskell.