Will.Whim

A weblog by Will Fitzgerald

PROGN considered harmful

Guy Steele in DDJ, Thoughts on Language Design: discusses going beyond the structured programming constructs of loops, if-then-else, and sequential operation:

What might a language look like in which parallelism is the default? How about data-parallel languages, in which you operate, at least conceptually, on all the elements of an array at the same time? These go back to APL in the 1960s, and there was a revival of interest in the 1980s when data-parallel computer architectures were in vogue. But they were not entirely satisfactory. I’m talking about a more general sort of language in which there are control structures, but designed for parallelism, rather than the sequential mindset of conventional structured programming. What if do loops and for loops were normally parallel, and you had to use a special declaration or keyword to indicate sequential execution? That might change your mindset a little bit.

The programming language I work on, Apex (as well as its predecessor, the RAP System), has parallelism turned off on by default, so that, for example, in

(procedure (do something)
  (step (do this))
  (step (do that)))

the “do this” step and the “do that” steps are executed in parallel. This does, in fact, turn out to require a change in mindset, especially when the individual steps are themselves composed of substeps executing in parallel. The RAP system also had an interesting approach to the if-then-else: procedures can have various methods which are tried in different cases; for example:

(procedure (open door)
  (method (is-automatic door))
    (step (walk up to door)))
  (method (has-knob door))
    (step (turn knob))))

I think that the syntax for both Apex and the Rap System turns out to be a bit heavy on keywords (method, step, etc.), which are, in turn due to their roots in Lisp. (There are some advantages to the ‘everything looks like data’ approach though). Neither the Rap System nor Apex really handle looping very well, though we’re working on some new looping constructs for Apex.

In addition to the breakthroughs with respect to ‘structured programming’ constructs, both Apex and the Rap System have other important features, which like default parallelism, require some ‘changes in mindet.’ For example, conditions (such as in the methods above) can be much more richly expressed than boolean queries, but can stream bindings. Anyway, it is nice to think that Steele is working on making some of these ideas find their way into the mainstream. Here’s the latest spec for his new language Fortress, which also includes support for Unicode-based operators, for example: “A × B” instead of the traditional ASCII “A * B” to indicate multiplcation.

(via lambda the ultimate).

Advertisements

2 responses to “PROGN considered harmful

  1. Daniel Lemire December 31, 2005 at 2:04 am

    You wrote “Apex has parallelism turned off by default”, you probably mean “turned on”!!!

    As for “Unicode-based operators”, what about this old thing:
    http://en.wikipedia.org/wiki/APL_programming_language

    Seems to me that unicode-based (as opposed to ASCII-based) programming is nothing new. But having to buy a new keyboard just to use a programming language is simply not convenient!!! And honestly, I fail to see how it can be really important.

  2. Will December 31, 2005 at 9:23 am

    Thanks Daniel–I did mean “turned on.”

    You’ll notice that APL is mentioned in the paragraph I quoted. The big difference between the APL of the ’60s and Fortress with respect to using Unicode-based characters is the obvious fact that Unicode is a well accepted standard, and the APL character encodings were not (the Wikipedia article suggests current APL implementations use Unicode now).

    I think the main interesting reason using a richer character set is just that it increases the transparency of the semantics; θ ∉ Θ might more transparently mean θ ∉ Θ than not(elmentOf(t,T)).

    And you probably don’t need to buy a new keyboard. I assume you didn’t have to buy a new keyboard to create LaTeX documents?

%d bloggers like this: