Phillip Trelford's Array

POKE 36879,255

Unboxing FP

How hard is it to get started in functional programming?

Let’s have a look at how quickly you can get started on a selection of simple expression-oriented programming languages.

Today let’s try Clojure, Elm, F#, Haskell and OCaml.

Online REPL

No install required just point your browser at a URL and you’re off:

Language Online REPL
Clojure http://tryclj.com/
F# http://www.tryfsharp.org/
Elm http://elm-lang.org/try
Haskell http://tryhaskell.org/
OCaml http://try.ocamlpro.com/

 

Each language has an easy to use online REPL with simple lessons to get you through the basics. Elm’s online offering lets you edit multi-line programs, as does Try F#, which also includes intellisense in the online editor.

Development environment

Now you’ve covered the basics you probably want to install a lightweight development environment and start building larger programs:

Clojure

I found LightTable very quick to install and setup. The editor comes with psychedelic colours to help you track opening and closing parenthesis:

FizzBuzz Clojure


I’ve been using Stuart Holloway’s Programming Clojure book as a guide.

Elm

Elm has a very usable online editor, a simple installable REPL, and a wonderful playground feature with Elm Reactor:


F#

If you’re on Windows and have Visual Studio installed then you’ve already got F#. From the file menu click New and select a new F# project or script file.

No Visual Studio, no problem, for Windows the Tsunami IDE is a fast 25MB download, which gives you the latest compiler and an editor with intellisense:

Tsunami IDE

On Mac I’d recommend Xamarin Studio and for Linux MonoDevelop or Emacs.

Functional Programming using F# and Dave Fancher’s recent Book of F# are both great introductory texts.

Haskell

The Haskell platform gives you a compiler and REPL from a simple 100MB install. A combination of a text editor along with the REPL gets you going in no time:

Haskell FizzBuzz

As a guide I’ve been using the Real World Haskell book. Learn you an Erlang some Haskell for great good! looks like a fun read too.

OCaml

Like Haskell, OCaml is bundled in a simple installer and includes the compiler and REPL. Choose your own editor and use the REPL to explore your programs.

I recently picked up OCaml from the Very Beginning and More OCaml, which are both nice concise introductions.

OCaml From The Very BeginningMore OCaml

Conclusions

Using an online REPL you can get started with any of these languages in seconds, and there are plenty of lightweight install options too. Combine that with a good selection of learning resources from books to online courses, and we can conclude that nowadays it’s really not that hard to get started with FP.

Comments (1) -

  • MBR

    10/8/2014 12:26:58 PM |

    When it comes to more than playing and having an actual ecosystem from advanced tooling to libraries to deployment, I can't see an option other than F#.
    I really want to like Clojure as I've always liked Lisp (F#'s meta-programming story not as compelling), but it makes me nervous that the Clojure web-site (including a link to a CLR version that seems dead enough), community, tools, etc. (with the exception of LightTable which is certainly cool FWICT) have not changed much since Clojure was first introduced. From a performance perspective there is certainly no contest (looks like Clojure still boxes all over the place too), and as  Javascript/ES6 is pretty much lisp with irregular syntax anyway (with the exception of statement orientated core control structs), it's hard not to just go with JS and the performant V8 if you want true late-bound/dynamic code.

Comments are closed