≡ Menu

Repost: Avail, a language for ‘articulate programming,’ released

The Avail team has announced the first release of Avail, an “articulate programming language,” which attempts to offer a somewhat natural expression form for solving programming problems. While other languages, such as Perl, have tried to do some of the same things in providing an English-like parsing structure, Avail uses a very human-readable syntax to allow developers to express problems in the problems’ own natural expressions.

A simple example can be found in an RPN expression evaluator. Many developers would see it as a lexing problem; how do you read numbers, groupings, operators? Where does the “current calculated value” reside, and of what type is it?

Avail, however, sees RPN not as a lexing concern, but as what it is at a higher level: a means by which mathematical expressions are expressed, such that an operator follows its operands. Therefore, an RPN expression evaluator creates aliases for mathematical operators ("_+_ → "__+"), and provides a simple method body that prints a number. Therefore, the input (“2 2 +“) simply maps to an alias of the operations, and exists as a number in Avail’s natural type system.

This stretches farther. A guessing game’s primary body of code looks like this:

Private method "Play guess a number between_and_" is
[
        minimum : integer,
        maximum : integer
|
        rng ::= a pRNG;
        theRange ::= [minimum..maximum];
        theNumber ::= rng's next value in theRange;
        guessCount ::= tries to guess theNumber from range theRange;
        comment ::= comment for guessCount tries given a range of theRange;
        Print: comment;
];

Semantic restriction "Play guess a number between_and_" is
[
        minimumType : integer's type,
        maximumType : integer's type
|
        If ⎣minimumType⎦ ≥ ⎡maximumType⎤ then
        [
                Reject parse, expected:
                        "the minimum value to be smaller than the maximum value"
        ];
        ⊤
];

The invocation of this program is simple: “Play guess a number between 1 and 10“. This maps to the method, with syntactic restrictions; the method itself doesn’t have to worry about the actual syntax, because it’s not actually important to the method itself.

It’s not an entirely new way of thinking – most people think this way anyway. “Buy me a can of soup, but not potato soup” has a primary focus of actually purchasing a can of soup, with potato soup not being relevant to the purchase; it’s only something that shouldn’t be considered as an option. Oddly enough, Avail could use that phrase as a method invocation. Avail therefore exists almost as a language whose purpose is creating a DSL for a wide variety of domains, whereas many other languages provide easy facilities for creating a DSL. (A language can either make DSLs easy – as Scala does, for example – or it can view DSLs as the natural way to express a problem, as Avail does.)

However, one effect of articulate programming is that the developers can (and do) have a goal of being able to build ontological maps of other languages, and then running programs written in those languages through the Avail compiler. (As Avail currently runs on the JVM, this means that there’s a potential to create an ontological map for a Java program’s source, translating it into Avail via the compiler, then running it in the Avail workbench, which runs on the Java Virtual Machine. There’s turtles all the way down…)

Avail is open source, released under the “new BSD license,” which allows for unlimited redistribution for any purpose as long as its copyright notices and the license’s disclaimers of warranty are maintained.

Avail uses the JVM as a runtime virtual machine, although plans are in place for a native environment. Java’s type system is included, much as other JVM-based languages use Java’s standard runtime, although the inclusion of Java’s paradigms into Avail would be slightly jarring.

It’s a fascinating language, although new; the development team is actively seeking involvement and investigation.

{ 0 comments… add one }

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.