ark-lang.org

What is Ark?

Ark is a systems programming language focused on being practical and pragmatic. We want a language that is simple, easy to write, yet powerful enough to create readable, performant and concise code for any problem. Ark aims to adopt various features that complement one another, working together in perfect harmony:

  • Pattern Matching
  • Implicit Interfaces
  • Generics
  • Native UTF-8 support
  • Option Types
  • Automatic Reference Counting
  • Macro System
  • Directory Based Modules
  • Slices
  • Named Types
And more!

Hello, World!

// these wont be necessary when
// we have a standard library
[c] func printf(fmt: ^u8, ...) -> int;
[c] func scanf(fmt: ^u8, ...);

func factorial(n: int) -> int {
    if n == 0 {
        return 1;
    }
    return n * factorial(n - 1);
}

pub func main() -> int {
    number: int = 1;
    C::printf(c"Enter a number: \n");
    C::scanf("%d", &number);

    if number < 0 {
        C::printf(c"No negatives please\n");
        return -1;
    }

    result := factorial(number);
    C::printf(c"%d! = %d\n", number, result);
    return 0;
}

Example

On the left is a simple program that renders a rotating triangle using OpenGL. Currently the language is an ongoing work in progress, but this is a taste of what Ark is capable of doing.

There are few programs written in Ark currently, this website itself is actually using a simple "web framework" written in Ark to send HTML to the web server (Nginx) via. the FastCGI protocol.

You can find the code for the graphics example here, and the code for the websites framework here.

Contribute

Ark is completely Open Source, including this website! If you want to help in any way, go check out our GitHub. You can contribute in various ways, including (but not limited to):

  • Code contributions to the compiler, arkade, this website (or any other project on the GitHub)
  • Testing the compiler to find and report bugs on the issue handler
  • Writing documentation
  • Your voice on Request For Comments (RFCs), or on IRC/SubReddit!

Why Ark?

Before you write a language it's a good idea to look at existing languages and see if they are suitable for your needs. I've gone over a few languages, and pointed out why they don't really suit:

C++
Within C++, there is a much smaller and cleaner language struggling to get out.
— Bjarne Stroustrup

C++ is notorious for being a very complicated language, that when used correctly is very powerful. It was designed to be backwards compatible with C, though this was a key in C++ becoming the widely used language that it is today, it means that it inherits a lot of problems from the C language. In addition to this, when adopting the modern language features (i.e. smart pointers or auto declarations), you are still encumbered by all the cruft present in the language. I do think that you can write a small subset of C++ (see the quote) for the language to be somewhat pleasant to write software in, though I think at this point you may as well stick to C.

Go

Go is quite a strong language, they do a lot right and have a fantastic engineering team behind the language e.g. Rob Pike, Brian Kernighan, etc. Though the main flaw is the garbage collection, which I understand their reason of adopting this (the language was intended for server-side applications where programs have a very long lifespan and can't leak memory), I prefer being able to manage the memory myself. Also there's a few nitpicks like the package manager, access specified by the case of the identifier of a declaration, etc.

Rust

Rust is very interesting, though the ownership model poses too much of a mental hurdle when writing software.

Reading any amount of Rust code evokes the joke "friends don't let friends skip leg day"
— Andrei Alexandrescu

In other words, Rust has focused a lot on security and this takes precedence over anything else.

D

D has actually been one of my favourite languages recently, I particularly enjoy writing it, though I still think it has it's flaws. Mainly that it takes too much after C++, though it's nicer to write than C++, and there are lot of cases where there are multiple ways of doing the same thing. Furthermore, it also has garbage collection and though this can be disabled, a lot of the standard library and the languages features tie into the garbage collection.