Coeffects: The next big programming language challenge

Programming language researcher and F# contributor Tomas Petricek believes that it's at least as important to track what applications require from the environment where they're executed as it is to understand how they affect that environment. He's made a convincing case that programming languages need to able to both understand and respond to the program's execution environment or context, for example in scenarios involving cross-platform apps, where different platform or versions of a platform make different API functions available; mobile apps, where different devices provide an app with different capabilities -- such as GPS; and data-intensive application development, where different users will have varying access to data.

Using the example of data-intensive applications, he writes:

A vast majority of applications accesses some data sources (like database) or resources (like GPS sensor on a phone). This is more tricky for client/server applications where a part of program runs on the server-side and another part runs on the client-side. I believe that these two parts should be written as a single program that is cross-compiled to two parts (and I tried to make that possible with F# Web Tools a long time ago; more recently WebSharper implemented a similar idea).

So, say we have a function  validateInputreadData, and displayMessage in my program. I want to look at their types and see what resources (or context) they require. For example, readDatarequires database (or perhaps a database with a specific name), displayMessage requires access touser interface and validateInput has no special requirements.

This means that I can call validateInput from both server-side and client-side code - it is safe to share this piece of code, because it has no special requirements. However, when I write a code that calls all three functions without any remote calls, it will only run on a thick client that has access to a database as well as user interface...

Get a demonstration of using annotated types to manage coeffects and create more responsive applications in "Coeffects: The next big programming challenge" ...

This story, "Coeffects: The next big programming language challenge" was originally published by Java Everywhere.