Functions and linguistic style

Posted: November 30th, 2009 | Author: Mars | Filed under: Design | 4 Comments »

The goal of the Radian project is to provide the concurrency benefits of a pure functional language inside the syntax and conceptual style of a high-level imperative language. This suggests two questions: what is it about a pure functional language that makes it useful for developing concurrent software, and what is it about an imperative syntax that makes the marriage of these two divergent linguistic styles worth the effort?

A pure functional language is one where functions cannot have side-effects. That is, a function can accept parameter values, perform some computation, and return a value – but it cannot make any change to the state of the machine outside itself. The value returned may be an arbitrarily complex data structure, but everything the function accomplishes must be somehow expressed in it. There is no such thing as a “side effect”, because all potential effects must be part of the function’s explicit interface.

This restriction, onerous as it may seem, has a great deal of value for concurrent programming. Problems of concurrency are all about coordination of access to shared state. In an imperative language, any function may have side effects which alter any piece of shared state at any time. In a functional language, however, pure functions can only touch what you give them, so it is possible to confidently compose pieces of a program without worrying that they will conflict with each other in some hidden way.

This is not an original observation; the combination of pure functions, immutable objects, and transactions has been tried and found useful in several functional languages. My goal with Radian is to present this set of tools in a clean, clear, accessible package suitable for general programming by non-specialists. In syntax, in nomenclature, and in style, therefore, I am trying to create something that will feel clear, straightforward, and familiar. I am not trying to change the way people write software; I am trying to develop a practical tool which will automate away the rat’s nest of difficult problems currently facing anyone trying to write concurrent software.


4 Comments on “Functions and linguistic style”

  1. 1 charles said at 15:17 on December 1st, 2009:

    Do you plan to answer the second question you posed?

  2. 2 mars said at 15:57 on December 1st, 2009:

    That was the thought behind my last paragraph. It could stand a good deal of elaboration, I admit.

  3. 3 Radian Programming Language » Blog Archive » Why imperative style? said at 15:01 on December 4th, 2009:

    [...] raised two questions in my last post, and I’d like to expand on the second: what is it about the imperative style that makes its [...]

  4. 4 Joe Huber said at 15:50 on December 4th, 2009:

    Fascinating! I’m looking forward to following your progress…