Check out my new course Learn you some Lambda best practice for great good! and learn the best practices for performance, cost, security, resilience, observability and scalability.
I attended the Functional Programming eXchange 15 last Thursday and it was a thoroughly enjoyable day.
Don’t worry if you weren’t one of the lucky 100 or so that made it, most of the talks are available online on SkillsMatter’s website, and here’s a high level summary of a couple of the talks.
Games and 3D Graphics in Arcadia
Throughout the talk, Tim demoed the power of Arcadia – being able to interactively modify a virtual world in Unity3D live, by writing Clojure code in a REPL (which is then compiled to MSIL using ClojureCLR).
And just to show how far you can push it, Tim did the entire demo in an Emacs window inside the Unity3D world it’s manipulating, which is projected onto an Oculus Rift headset. Why? Because you could!
— Yan Cui (@theburningmonk) June 11, 2015
Jokes aside, it is rather impressive, and as Claudia mentioned in a conversation with Tim afterwards, the ability to script the scene itself is very valuable. Being able to drag-and-drop and click a few boxes here and there to edit things is great but very soon you realise you need automation as the number of objects in the scene grows, and that could be the gateway drug that gets Arcadia through the door.
Another interesting feature of Arcadia is the ability to serialize and save the current state of the scene, though Tim didn’t demo this so I don’t know how it works in practice. One caveat (that has caught many people out including 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 frustrating, because even though you’re able to learn and discover about the virtual world you’re building by being inside it and interact with and modify it as we go, we’re not able to keep the result of our tinkering and experimentation. You could painstakingly note down or remember every change you have made and then reapply them back in the edit mode, but remember 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 validating your grand design, but it’s capable of being so much more. If there’s one thing I’ve learnt from Bret Victor, is that, creators need to see rapid feedbacks from their ideas. So if Arcadia is able to save and load the current state of a world then that’d a massive deal for me.
Watch the talk here.
The lazy programmer’s guide to writing 1000’s of tests : An introduction to property based testing
In this talk, Scott gave a gentle introduction to property-based testing, and then outlined some techniques for choosing properties to test (which is usually the hard part when you first start writing property-based tests), and finished off by introducing model-based testing too.
I strongly recommend this talk, and you might also be interested in checking out these two posts by Scott too:
A colleague of mine was so inspired by this talk, that he told me afterwards he plans to rewrite all of his unit tests for our payment gateway with Python’s adaptation of QuackCheck – Hypothesis!
Watch the talk here.
Build your own effects
In this talk Jeremy Yallop demonstrated a way to manage side-effects using a new feature in OCaml (which should be available in the next major version) called effects. In traditional stack-based model, when an exception occurs the rest of the stacks are thrown away as the exception is captured and bubbled up: This is the same with CPS (continuation passing style) code too.
Essentially exceptions is a way to short circuit program execution (either intentionally or unintentionally). All exception can tell you is that ‘something has gone wrong’, it’s a very limited one-way conversation.
With effects, you not only get the information about the effect, but also the rest of the stack as a continuation, so we can instead model resumable exceptions like the following:
(the above is constructed based on my recollection and syntax from this paper, so it’s likely not accurate, but should still give you a flavour of what you can do)
You can also easily model other effects, such as:
- dynamic binding, e.g. when you detect an unbound variable, perform an effect whose handler would
- binds a default value for the variable in the current context and;
- invoke the continuation
- yield and concurrency as described in this paper
- state monad where state updates are performed as an effect
The big advantage of this approach is that it simplifies composition of different effects.
With Haskell’s monads for instance, this is done through monad transformers which is limited to a specific pair of monads and adds another layer of complexity.
With effects, you just add a clause in your match…with statement to handle a new effect alongside other effects and you’re done!
Unfortunately this talk was not recorded, but you can still get a flavour by looking at some of the examples in this paper.
Due to other commitments this weekend, I’m not able to cover the other talks here, but you can still watch them here.
All the talks were pretty good and worth watching, and if you’re looking to champion the adoption of functional programming in your organization then you should definitely watch Michael Newton’s talk – Functional Programming in an Imperative World. Michael presented lots of anecdotes from his experience promoting F# at 15Below. I saw another good talk on the topic by Jay Fields at QCon London this year on how he pushed the adoption of Clojure at DRW Trading, which is sadly not available on InfoQ yet but you can watch an older version of the talk here.
Next stop : NDC Oslo this week where I’ll be doing two talks on Wednesday:
- A tour of the language landscape – a whirlwind tour through some of the languages on the fringe of mainstream and look at interesting ideas I have learnt from them, including Go, Rust, Erlang, F#, Elm, Clojure and maybe Idris
- Modelling complex game economy with Neo4j – a case study of how we used Neo4j at Gamesys Social to model our MMORPG game Here Be Monsters, and used this model to help automate the process of balancing the game economy
- Introduction to Property-based testing
- Choosing properties for Property-based testing
- Paper – Effective Concurrency through Algebraic Effects
- Jay Fields – Lessons learned from Adopting Clojure
I specialise in rapidly transitioning teams to serverless and building production-ready services on AWS.
Are you struggling with serverless or need guidance on best practices? Do you want someone to review your architecture and help you avoid costly mistakes down the line? Whatever the case, I’m here to help.
Check out my new course, Learn you some Lambda best practice for great good! In this course, you will learn best practices for working with AWS Lambda in terms of performance, cost, security, scalability, resilience and observability. Enrol now and enjoy a special preorder price of £9.99 (~$13).
Are you working with Serverless and looking for expert training to level-up your skills? Or are you looking for a solid foundation to start from? Look no further, register for my Production-Ready Serverless workshop to learn how to build production-grade Serverless applications!
Here is a complete list of all my posts on serverless and AWS Lambda. In the meantime, here are a few of my most popular blog posts.
- Lambda optimization tip – enable HTTP keep-alive
- You are thinking about serverless costs all wrong
- Many faced threats to Serverless security
- We can do better than percentile latencies
- I’m afraid you’re thinking about AWS Lambda cold starts all wrong
- Yubl’s road to Serverless
- AWS Lambda – should you have few monolithic functions or many single-purposed functions?
- AWS Lambda – compare coldstart time with different languages, memory and code sizes
- Guys, we’re doing pagination wrong