Bodil Stokke

Pure Script (Maybe This Time We Get Java Script Right)

Pure Script (Maybe This Time We Get Java Script Right)

The web browser is the world’s most ubiquitous user interface. Sadly, this means we’re all basically stuck in an abusive relationship with JavaScript. Obviously not a desirable position to find ourselves in, we’ve tried breaking out of the JS trap in a variety of ways: JS dialects (solving no design flaws but at least looking prettier) and JS as a compilation target (resulting, mostly, in unappealingly large output to support the emulated runtimes).

So when I found myself having to build a system with real deliverable size constraints, my only options seemed to be JS itself, or TypeScript, which doesn’t add much to JS but at least provides a modicum of type checking. After a few months of fighting TypeScript, though, I’d had enough. Happily, my frustration coincided with the advent of PureScript.

At first glance, PureScript looks and feels like Haskell, but there’s hardly any extraneous machinery. The PureScript compiler generates very concise JS, and the language itself is designed with the platform’s constraints in mind. Yet it offers things like higher-kinded polymorphism, type classes and similar deep Haskell magic. More appealingly, it comes with a growing number of libraries for coping with the browser as a platform: functional DOM manipulation, reactive programming, and more.

It turned out to be a delight, getting out of my tangled mess of JavaScript and rebuilding it all in PureScript, and I’d like to show you how and why.

About Bodil

Bodil is a a bishop of the Greater London diocese of the Church of Emacs, and a compulsive conference speaker in the fields of functional programming and internets technologies, and is a co-organiser of multiple developer conferences in Scandinavia and the UK, mostly because she’s still learning how to stop. Her favourite pony is Pinkie Pie.

 

Github: bodil

Twitter: @bodil

Back to conference page