Functional Programming eXchange experience report

I attend­ed the Func­tion­al Pro­gram­ming eXchange 15 last Thurs­day and it was a thor­ough­ly enjoy­able day.

Don’t wor­ry if you weren’t one of the lucky 100 or so that made it, most of the talks are avail­able online on SkillsMatter’s web­site, and here’s a high lev­el sum­ma­ry of a cou­ple of the talks.


Games and 3D Graphics in Arcadia

Tim Gard­ner start­ed the con­fer­ence with an awe­some talk on Arca­dia, a live cod­ing envi­ron­ment for Clo­jure tar­get­ing Unity3D.

Through­out the talk, Tim demoed the pow­er of Arca­dia – being able to inter­ac­tive­ly mod­i­fy a vir­tu­al world in Unity3D live, by writ­ing Clo­jure code in a REPL (which is then com­piled to MSIL using Clo­jure­CLR).

And just to show how far you can push it, Tim did the entire demo in an Emacs win­dow inside the Unity3D world it’s manip­u­lat­ing, which is pro­ject­ed onto an Ocu­lus Rift head­set. Why? Because you could! 

Jokes aside, it is rather impres­sive, and as Clau­dia men­tioned in a con­ver­sa­tion with Tim after­wards, the abil­i­ty to script the scene itself is very valu­able. Being able to drag-and-drop and click a few box­es here and there to edit things is great but very soon you realise you need automa­tion as the num­ber of objects in the scene grows, and that could be the gate­way drug that gets Arca­dia through the door.

Anoth­er inter­est­ing fea­ture of Arca­dia is the abil­i­ty to seri­al­ize and save the cur­rent state of the scene, though Tim didn’t demo this so I don’t know how it works in prac­tice. One caveat (that has caught many peo­ple out includ­ing myself..) with Unity3D is that whilst in play mode, changes you make to the scene are lost when you go back to edit mode.

Which is frus­trat­ing, because even though you’re able to learn and dis­cov­er about the vir­tu­al world you’re build­ing by being inside it and inter­act with and mod­i­fy it as we go, we’re not able to keep the result of our tin­ker­ing and exper­i­men­ta­tion. You could painstak­ing­ly note down or remem­ber every change you have made and then reap­ply them back in the edit mode, but remem­ber we can only keep around 7 items in our head at a time.

As things stand, the play mode is more of a tool for val­i­dat­ing your grand design, but it’s capa­ble of being so much more. If there’s one thing I’ve learnt from Bret Vic­tor, is that, cre­ators need to see rapid feed­backs from their ideas. So if Arca­dia is able to save and load the cur­rent state of a world then that’d a mas­sive deal for me.  


Watch the talk here.


The lazy programmer’s guide to writing 1000’s of tests : An introduction to property based testing

This is a new talk from Scott Wlaschin on prop­er­ty-based test­ing with FsCheck. As ever, you can expect Scott’s usu­al blend of great humour and insight­ful­ness.

In this talk, Scott gave a gen­tle intro­duc­tion to prop­er­ty-based test­ing, and then out­lined some tech­niques for choos­ing prop­er­ties to test (which is usu­al­ly the hard part when you first start writ­ing prop­er­ty-based tests), and fin­ished off by intro­duc­ing mod­el-based test­ing too.

I strong­ly rec­om­mend this talk, and you might also be inter­est­ed in check­ing out these two posts by Scott too:

 A col­league of mine was so inspired by this talk, that he told me after­wards he plans to rewrite all of his unit tests for our pay­ment gate­way with Python’s adap­ta­tion of QuackCheck — Hypoth­e­sis!  


Watch the talk here.


Build your own effects

In this talk Jere­my Yal­lop demon­strat­ed a way to man­age side-effects using a new fea­ture in OCaml (which should be avail­able in the next major ver­sion) called effects. In tra­di­tion­al stack-based mod­el, when an excep­tion occurs the rest of the stacks are thrown away as the excep­tion is cap­tured and bub­bled up: fpx15 This is the same with CPS (con­tin­u­a­tion pass­ing style) code too.

Essen­tial­ly excep­tions is a way to short cir­cuit pro­gram exe­cu­tion (either inten­tion­al­ly or unin­ten­tion­al­ly). All excep­tion can tell you is that ‘some­thing has gone wrong’, it’s a very lim­it­ed one-way con­ver­sa­tion.

With effects, you not only get the infor­ma­tion about the effect, but also the rest of the stack as a con­tin­u­a­tion, so we can instead mod­el resum­able excep­tions like the fol­low­ing:

(the above is con­struct­ed based on my rec­ol­lec­tion and syn­tax from this paper, so it’s like­ly not accu­rate, but should still give you a flavour of what you can do)

You can also eas­i­ly mod­el oth­er effects, such as:

  • dynam­ic bind­ing, e.g. when you detect an unbound vari­able, per­form an effect whose han­dler would
    • binds a default val­ue for the vari­able in the cur­rent con­text and;
    • invoke the con­tin­u­a­tion
  • yield and con­cur­ren­cy as described in this paper
  • state mon­ad where state updates are per­formed as an effect

The big advan­tage of this approach is that it sim­pli­fies com­po­si­tion of dif­fer­ent effects.

With Haskell’s mon­ads for instance, this is done through mon­ad trans­form­ers which is lim­it­ed to a spe­cif­ic pair of mon­ads and adds anoth­er lay­er of com­plex­i­ty.

With effects, you just add a clause in your match…with state­ment to han­dle a new effect along­side oth­er effects and you’re done!


Unfor­tu­nate­ly this talk was not record­ed, but you can still get a flavour by look­ing at some of the exam­ples in this paper.


Due to oth­er com­mit­ments this week­end, I’m not able to cov­er the oth­er talks here, but you can still watch them here.

All the talks were pret­ty good and worth watch­ing, and if you’re look­ing to cham­pi­on the adop­tion of func­tion­al pro­gram­ming in your orga­ni­za­tion then you should def­i­nite­ly watch Michael Newton’s talk — Func­tion­al Pro­gram­ming in an Imper­a­tive World. Michael pre­sent­ed lots of anec­dotes from his expe­ri­ence pro­mot­ing F# at 15Below. I saw anoth­er good talk on the top­ic by Jay Fields at QCon Lon­don this year on how he pushed the adop­tion of Clo­jure at DRW Trad­ing, which is sad­ly not avail­able on InfoQ yet but you can watch an old­er ver­sion of the talk here.


Next stop : NDC Oslo this week where I’ll be doing two talks on Wednes­day:

  • A tour of the lan­guage land­scape — a whirl­wind tour through some of the lan­guages on the fringe of main­stream and look at inter­est­ing ideas I have learnt from them, includ­ing Go, Rust, Erlang, F#, Elm, Clo­jure and maybe Idris
  • Mod­el­ling com­plex game econ­o­my with Neo4j — a case study of how we used Neo4j at Gamesys Social to mod­el our MMORPG game Here Be Mon­sters, and used this mod­el to help auto­mate the process of bal­anc­ing the game econ­o­my