Staff Services Student Enterprise

Effect Handlers

Project contact
Curious to learn more?
Contact our Business Development and Consultancy teams
edinburgh.innovations@ed.ac.uk

Researchers from the University of Edinburgh’s School of Informatics are responsible for inventing the Effect Handler, a programming construct that has since been adopted by companies worldwide to benefit billions of end-users.

Effect Handlers provide a computation construct that allows programmers to define, customise, and compose more expressive and flexible computer programs. Their numerous applications include the Web’s most popular user-interface framework, React, which runs daily for billions of users on multiple platforms such as Instagram, WhatsApp and BBC News.

Decades of research

Professor Gordon Plotkin, co-founder of the Laboratory for the Foundations of Computer Sciences (LFCS) within the School of Informatics (SoI), is a theoretical computer scientist and a leading light in the field of programming semantics. His work has had a lasting impact on both the principles and design of programming languages, due in no small part to the ground-breaking paper that he and his PhD student Matija Pretnar published in 2009.

‘Handlers of Algebraic Effects’ was seminal in that it presented an algebraic treatment of exception handlers (planned coding responses to programming anomalies) and introduced handlers for other computational effects representable by an algebraic theory. In this formalism, programmers can define effects and invoke them to interrupt the program’s execution and invoke appropriate handler code. However, unlike exception handlers, an Effect Handler can resume the original point of execution, sometimes repeatedly, promising a highly modular and expressive programming style. Plotkin and Pretnar’s paper gave a theoretical demonstration of Effect Handlers’ versatility.

Making connections

LFCS colleagues Dr Sam Lindley, Dr Nicolas Oury, and Dr Ohad Kammar took Plotkin and Pretnar’s work to the next level, popularising Effect Handlers by giving simpler descriptions for them and demonstrating how to incorporate them into existing programming languages. Whereas Plotkin and Pretnar had originally presented Effect Handlers in a style that required considerable mathematical sophistication to understand, Lindley, Kammar and Oury gave an operational description using a high-level state machine. They also implemented Effect Handlers in existing programming languages, which gave programmers and programming language researchers a hands-on opportunity to learn about and experiment with them for the first time.

Tech companies who are engaged with the programming languages research community were made aware of what Plotkin, Lindley, Kammar and colleagues had developed, and several global companies including Meta (formerly Facebook), GitHub and Uber wasted no time in adopting Effect Handlers as vital elements of their respective software.

Global reach

Today, the Effect Handlers invented and developed at the University of Edinburgh underpin technologies used by companies across the software industry worldwide, and bring commercial benefits ranging from improved developer productivity to more cost-effective working practices and increased product performance.

Multinational technology conglomerate Meta is just one adopter of Effect Handlers. Meta's React JavaScript library used Effect Handlers in the design of its Application Programming Interface (API), to make its user-interface code simpler and cheaper to develop and extend, and the user interface more reactive. React is also a popular library beyond Meta, used by millions of active developers for billions of end-users, with adoptions across diverse business sectors by companies such as Twitter, Airbnb, Uber and Microsoft Office.

The React team at Meta relies on the expressivity and compositionality of Effect Handlers to future-proof their API design, and they credit Effect Handlers with enabling improvements to React’s compositionality. They state:

Effect Handlers are an expressive concept based on rigorous mathematical models. These properties give us further assurance that they will continue to deliver flexible designs and utilise resources efficiently as our needs develop, allowing us to make more informed strategic decisions today. ”

Related Links

Work with the School of Informatics

Laboratory for the Foundations of Computer Sciences

Header Image: deanmitchell/istock.com