Menu

Title page

Trilirium

{{Infobox programming language
|name = AWL
|paradigm = [[multi-paradigm programming language|multi-paradigm]]: [[functional programming|functional]], [[procedural programming|procedural]], [[object-oriented programming language|object-oriented]]
|year = 2006
|designer = [[Gaev D.G.]]
|typing = Typeless
|influenced_by = [[LISP]], [[Scheme]], [[Perl]], [[Ruby (programming language)|Ruby]], [[APL]]
}}

AWL (Alternative Web Language) is a new experimental multi-purpose programming language. It is intended to be usable not only as a scripting and application programming tool, but also as a substitute for a wide set of World Wide Web technologies. Complete with standard extensions and libraries, AWL is capable of formatted text mark-up (like [[HTML]]), structured data definition ([[XML]]), complex styles and macro definitions ([[CSS]]), embedded vector graphics ([[SVG]]) and page scripting/behavior programming ([[JScript]]/[[JavaScript]]).

=== Brief description ===

AWL can be described as a multi-paradigm language, containing many [[functional]], [[procedural]] and [[object-oriented]] features. Most principal ancestors of AWL include [[LISP]] and [[Scheme]], [[Perl]], [[Ruby (programming language)|Ruby]] and some other programming languages, including even [[APL]] (multi-dimensional arrays) and [[SNOBOL]] (regular expressions/patterns). As in LISP and many modern functional languages, lists serve as a most important tool of data integration. Primary evaluation mechanism is ''functors'': functional primitives combining semantics of built-in functions, operators and statements of the traditional languages. AWL runs as an interpreter, although code is precompiled, and all name bindings are compile-time, which makes program execution relatively efficient. Being a ''weakly typed language'', AWL requires no type declarations (but most built-ins have a strictly defined type(s) of their arguments, with run-time conversions performed on demand).

AWL has a rich syntax: there is a lot of unary and binary operators dealing with scalars (numeric and string) and lists, most of them are internally translated to built-in functor calls. For example, expression

XY + YZ + Z*X;

is internally represented as:

add(add(mul(X, Y), mul(Y, Z)), mul(Z, X));

Conditional operations, like

A < B? (B - A) : (A - B);

are just a replacement for:

if(lt(A, B), sub(B, A), sub(A, B));

and so on.

There is no keywords in AWL, only a names of standard functors. (In this sense, AWL is completely international language, which easily can be "localized" by providing alternative names for them.)

Defining new functors is a main method of language extension. Here, for example, is definitions of factorial:

! fact(n) = n ? n*fact(n-1) : 1;

and Ackermann function:

! ack(m n) = m ? (ack(m-1, n ? ack(m, n-1) : 1)) : n+1;

Here is a bit more complicated example: solving Towers of Hanoi problem:

! hanoi_solve(N) = {
! move_disks(n from to via) =
n ? {
count = move_disks(n-1, [from via to]);
<: ["\t#" n ": " from " => " to "\n"];
++ count;
count + move_disks(n-1, [via to from])
} : 0;
<: ["\nTotal: " N " disks...\n\n"];
count = move_disks(N, ['A' 'B' 'C']);
<: ["\nProblem solved in: " count " steps.\n"]
};

''Objects'' provide another way of structuring data: any AWL object is instance of certain class.
Class definitions have much in common with functor definitions:

!! Vector3D (x y z) {
! length = sqr(xx + yy + zz),
! product (A B) = Vector3D(A.y
B.z – B.yA.z, A.zB.x – B.zA.x, A.xB.y- B.x*A.y)
};

As obvious for this example, class name is a kind of functor itself, providing a "standard" way to create new instance of the class. Less trivial class definitions may include ancestor class (single one, although multiple inheritance is considered), constructors and destructors to handle objects creation and destruction, and virtual functors to implement polymorphism. One unusual feature of AWL object system is a temporary class-instance binding: this means, what expressions like:

myvector.(x+y+z);

are prefectly valid.

Other data structures include multi-dimensional arrays, hashes with arbitrary set of keys and values, and regular expressions (or patterns).

== External link ==
*[http://www.awl-project.narod.ru AWL project official page]

[[Category:Programming languages]]
[[Category:Functional languages]]
[[Category:Object-oriented programming languages]]


MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.
Try Free →