The XL Programming Language

XL stands for "Extensible Language". It's a programming language designed to address the challenges faced by programmers today. It addresses these challenges not by adding language features, but by making it easy and safe for any programmer to add features themselves.

To illustrate its flexibility, XL currently exists in two main dialects:

Both languages share the same syntax and meta-programming model.

XL Design Objectives

Some of the key objectives for XL are:

  1. Easy to read. Observations have shown that code is read several times more often than it is written.
  2. Easy to write. Making code easy to read should not come at the expense of the programmers writing it.
  3. Simple. Only what is necessary to achieve the objectives belongs to the language.
  4. Powerful. Programmers need power tools, not gimmicky toys.
  5. Extensible. Programmers, not language designers, know best what tools they need.

The last objective is so important that it gives its name to the language. The philosophy is to build as much as possible using a very small number of rules. The rationale behind this approach is that what we can do, programmers can do. In other words, if it's easy to add a basic construct such as if-then-else to the language, it will also be easy to add more advanced constructs such as tasking or support for SIMD computations.

XL Language Design

To achieve these objectives, XL is built around a few key ideas:

  1. A syntax that centers on how humans read things, rather than the needs of compilers. For example, humans are sensitive to indentation and spacing, but do not care much about parentheses and other punctuation.
  2. Enabling familiar and powerful notations in code, rather than language-imposed notations. For example, humans think of a linear transform as A*B+C rather than Linear(A,B,C).
  3. A core language definition based on a simple code rewrite rule.
  4. Implement as extensions many of the language features considered as "advanced" today, for example generics, overloading, higher-order functions, closures, ...
  5. Putting meta-programming at the center of the language. The XL parse tree is very simple, clearly documented, and allows arbitrary code manipulations with ease.

XL2 - The imperative flavor of XL

use XL.UI.CONSOLE
WriteLn "Hello World"

Hello World in XL2

XL2 is the imperative flavor of XL. It is intended to feel familiar to programmers who used languages such as C, C++, Pascal or Ada.

Key properties of XL2

XL2 offers the following features:

Meta-programming in XL2

translation Simplify
  when
    'X' * 2
  then
    return parse_tree('X'+'X')

Simple plug-in in XL2

XL2 is based on XL, so it also offers advanced innovative meta-programming capabilities:


  1. Support for object-oriented programming in XL2 is currently relatively weak. 

XLR - The functional flavor of XL

0! -> 1
N! -> N * (N-1)!

Factorial in XLR

XLR is the functional variant of XL. It is intended to feel familiar to programmers who used languages such as Lisp, Scheme, Haskell, and to a certain extent Python or Ruby.

Key properties

XLR has the following standard features:

Meta-programming in XLR

if true then X else Y -> do X
if false then X else Y -> do Y

Adding "If-then-else" in XLR

XLR is based on XL, so it also offers advanced meta-programming capabilities:

XLR Language Reference Draft

Attached is the current draft of the XLR language reference. This is work in progress.

A major update of this document has been posted here for review in January, 2012, and should be updated on a regular basis. It describes not the state of XLR as it is currently implemented, but where we are trying to go.

Here are some of the major changes in this draft:

  • The "context", which is currently a C++ class (two, actually, "Context" for -O0 and -O3, and "Symbols" for -O1) referencing a few other classes (notably "Rewrite"), is now defined entirely in terms of XLR nodes. I intend to modify the XLR compiler so that all symbol management can be done entirely with XLR data structures.

  • The document finally contains a description of the XLR type system. Types identify shapes of trees, and they can do pretty fancy stuff. I still need to see if I can make this compatible with the type inference we have, which is critical to performance.

AttachmentSize
XLRef.pdf473.49 KB