Wiki

Clone wiki

amber / Home

Amber Programming Language

Amber is a language in the C-family, drifting slowly away from the immediate parent D (v1). Until the compiler can be bootstrapped with Amber, it is written in D.

It is fairly easy to add new backends, and we currently have two code generation backends, one using LLVM and one outputting C code.

The compiler has been developed in private for 3 and a half years, for reasons that are now pretty much outdated. Many have been involved, especially in the early days - most coming from Tango and LDC. What is now released is the code for our reference compiler via this repository, some additional repositories (see below) and some additional documentation in this wiki (it is incomplete, but will transition stuff from earlier systems over the next days).

Status

If we are nice to ourselves, we may call the compiler to be of alpha quality. This progress report page says a bit about what works and a few points on what's next. It is possible to compile and run simple programs, but as programs get more complex and uses more features, things will start to fail. A library such as Tango is quite far from being compilable.

We also still have some decisions to make before getting to a first proper release. You can find proposals here.

Governance

We practice a form of open governance where committers can vote on specification matters. If you wish to join in, please start with pull requests.

Non-affiliation

Since we decided on the name Amber back in 2009, others seems to have done the same, so this is just to make clear that we have nothing to do with the Ruby fork, nor the Smalltalk implementation, none of which appear to be actual languages/dialects.

We have a few auxilliary projects/repositories:

  • Amber specification - not complete
  • Amberstress - the stress test suite
  • System headers - posix, windows, etc system headers separated into its own project such that there should be little, if any need of duplication at any level.
  • Tango - Amber's standard library (sans runtime)

Documentation

Contact / discussion

Example

This is an example of what oac is capable of at this point (Nov, 2012). Siegelord posted this example of explicit duck typing to avoid code bloat. This is just a small sample of what oac can do, of course :)

T sum_arr(T)(T[] arr) {
    T ret = 0;
    foreach(e; arr)
        ret += e;
    return ret;
}
int sum1(int[] arr) {
    return sum_arr(arr);
}
struct Iterable(T) {
    T delegate() PopFront;
    bool delegate() Done;
}
T sum_itr(T)(Iterable!(T) itr) {
    T ret = 0;
    while(!itr.Done())
    {
        ret += itr.PopFront();
    }
    return ret;
}
int sum2(int[] arr) {
    Iterable!(int) arr_itr;
    scope d1 = delegate { int e = arr.ptr[0]; arr = arr[1..$]; return e; };
    scope d2 = delegate { return arr.length == 0; };
    arr_itr.PopFront = d1;
    arr_itr.Done = d2;
    return sum_itr(arr_itr);
}
int main(char[][] args) {
    auto arr = new int[](args.length);  // this works with oac now (June 2013)
    assert(args.length > 1, "Program needs one integer on the command line to work with (ie. progname 3)");
    arr.length = (args.length);
    arr[0] = args[0][0];
    arr[1] = args[1][0];
    console.emit(sum1(arr) + sum2(arr)).newline;
    return 0;
}

Wiki features

This wiki uses the Markdown syntax.

The wiki itself is actually a mercurial repository, which means you can clone it, edit it locally/offline, add images or any other file type, and push it back to us. It will be live immediately.

Go ahead and try:

$ hg clone https://bitbucket.org/larsivi/amber/wiki

Wiki pages are normal files, with the .md extension. You can edit them locally, as well as creating new ones.

Syntax highlighting

You can also highlight snippets of text, we use the excellent Pygments library.

Here's an example of some Python code:

def wiki_rocks(text):
    formatter = lambda t: "funky"+t
    return formatter(text)

You can check out the source of this page to see how that's done, and make sure to bookmark the vast library of Pygment lexers, we accept the 'short name' or the 'mimetype' of anything in there.

Have fun!

Updated