Better poly than sorry!

Avail and Articulate Programming

Last updated on:

NOTE: Avail - a new language focused on articulate programming

Avail is a very interesting language. I only started working on it this week, just to take a look. I read a couple of examples and I was generally pleasantly surprised by what I saw. So here are my first impressions.

There is a problem with Avail syntax highlighting. Well, not exactly a problem, it just doesn't exist; not on the project page, not in Emacs, not anywhere I looked.

This is a shame, because even simple highlighting would help beginners. On the other hand, the language is built up so that, when you get used to it, you don't need any syntax highlighting. This is - I think - the articulate thing Avail's page talks about.

As usual I started with trying to write some tiny piece of code. It's easier to show an example, so here goes (you can hover your mouse over words in the listing to see a short explanation):

Module "Hello World"
    "Greet Router"

Method "Greet Router" is [
    socket ::= a client socket;
    target ::= a socket address from <192, 168, 1, 1> and 80;
    http_request ::= "GET / HTTP/1.1\n\n"→code points;

    Connect socket to target;
    Write http_request to socket;
    resp_bytes ::= read at most 440 bytes from socket;

    Print: "Router says: " ++ resp_bytes→string ++ "\n";

The most important things you can see here are: relatively lightweight syntax and weird function names. Avail gives you full control over how your program is going to be parsed. When you declare a method you're building a piece of Avail's parser - this means that you can make your function application look however you wish. For example, to have your function be called like read at most... you do this:

Method "read at most _ bytes from _" is [

At this point Avail looks like a cross between Inform 7 and Perl - cute!

But Avail doesn't end there. It supports multiple dispatch of methods, for example; also a sophisticated module system for organizing code, multiple inheritance...

Oh, and did I mention that Avail is actually a statically typed language? One with a very sophisticated type system, which is both powerful and non-imposing. As you can see, when you write something script-like, you may do so without being bothered by types.

Avail runs on JVM and comes with a Workbench - simple graphical code runner. Once inside you can compile and load modules and evaluate arbitrary expressions using Availuator (simple REPL).

Avail standard library is not big, and mostly focused on Avail itself. From what I can see, Avail is mostly written in itself and many of its inner parts are normal modules you can load, import and manipulate (see RPN calculator example).

That's all I know for now, I will report back later.