PreviewAntril and Larva are in active development

Build fast software,
your way.

Antril is a compiled language with a modern syntax. Larva turns it into native executables, WebAssembly or portable libraries, and every project chooses how its memory is managed.

curl -fsSL https://www.antril.org/install.sh | sh

For Windows, Linux and macOS · Other ways to install

People.ant
import System;

into namespace People
{
    public record class Person
    {
        public:
            str Name;
            i32 Age;
            new(str Name, i32 Age);
    }

    Main()
    {
        Person ana = new Person("Ana", 31);
        Person older = ana with { Age = 32 };
        Console.WriteLine(ana);
        Console.WriteLine(ana == new Person("Ana", 31));
        if (ana is Person(var name, > 30))
            Console.WriteLine(name + " is over 30");
    }
}
Terminal
larva run
Person { Name = Ana, Age = 31 }
true
Ana is over 30
Latest Larva
Soon
Hive packages
0
Languages in the registry
0
Forum threads
0
Registered developers
0

The language

Modern syntax. No surprises at run time.

Every program below is complete, compiles with the current Larva, and prints what you see. Pick an idea:

Shapes.ant
import System;

into namespace Shapes
{
    public interface IShape
    {
        Area() : f64;
        Describe() : str => "a shape of area " + Area();
    }

    public base class Shape : IShape
    {
        public:
            Area() : f64;
            virtual Name() : str => "shape";
    }

    public class Circle : Shape
    {
        f64 radius;

        public:
            new(f64 radius) { this.radius = radius; }
            override Area() : f64 => 3.14 * radius * radius;
            override Name() : str => "circle";
    }

    public final class Square : Shape
    {
        f64 side;

        public:
            new(f64 side) { this.side = side; }
            override Area() : f64 => side * side;
    }

    Main()
    {
        List<Shape> shapes = new List<Shape>();
        shapes.Add(new Circle(1));
        shapes.Add(new Square(2));
        loop (Shape s in shapes)
            Console.WriteLine(s.Name() + ": " + s.Area());

        IShape i = new Square(3);
        Console.WriteLine(i.Describe());
    }
}
Output
larva run
circle: 3.14
shape: 4
a shape of area 9
Read about it in the docs

Memory your way

One language. Four ways to manage memory.

Each project picks its collector with one line of its .queen file. The same source compiles in every mode, and libraries built for different modes still work together.

gc: default

Tracing

A tracing collector finds unreachable objects and frees them. Nothing to think about.

gc: refcount

Reference counting

Objects are freed the moment their last reference goes, and destructors run right then.

gc: arena

Regions

Everything a region { } made is freed together when it closes. Escapes are build errors.

gc: manual

Manual

You free each object with delete, in unsafe code, when you know best.

Program.ant
import System;

into namespace Mem
{
    public class Resource
    {
        str name;

        public:
            new(str name) { this.name = name; }
            destroy() { Console.WriteLine("close " + name); }
    }

    Main()
    {
        region
        {
            Resource a = new Resource("a");
            Resource b = new Resource("b");
            Console.WriteLine("leaving the region");
        }
        Console.WriteLine("end");
    }
}
Mem.queen
queen 1.0;

chunk PROJ:
   name: Mem,
   type: exe

chunk BUILD:
   gc: arena
Output
larva run
leaving the region
close b
close a
end
  • &T and &mut T references with an optional borrow checker
  • Destructors that run when the object stops existing
  • Fixed buffers and objects that keep their arrays in place
Memory in the Antril book

One toolchain, many targets

From one source to every place your code runs.

Larva compiles through one intermediate form, Larva HIR, to the back end you choose.

The Larva pipeline Antril source and other languages compile to Larva HIR, then to LLVM, Larva’s own x64 back end, WebAssembly or the Larva virtual machine, which produce executables, WebAssembly modules and Larva libraries. Antril (.ant) Other languages Larva HIR types · borrow check LLVM Larva x64 WebAssembly Larva VM optimized .exe fast-build .exe .wasm + .js .dll libraries

Native, optimized

LLVM at -O3: optimized native executables for your machine.

Native, fast builds

--backend x64: Larva’s own back end compiles faster while you iterate.

WebAssembly

--target wasm or wasm-llvm: the same program in the browser.

Larva libraries

larva lib writes a .dll that any language on Larva can use.

Terminal
larva build -o hello.exe hello.ant
larva build --backend x64 -o hello.exe hello.ant
larva build --target wasm-llvm -o hello.js hello.ant
larva lib -o Geo.dll geo.ant

Native libraries in minutes

Call C directly. Or let Larva write the binding.

Declare a function with [Import] and call it. For a whole library, larva bind reads its exports and a C header or a short description, and writes a typed binding.

  • C headers through the preprocessor, structs, unions and packed layouts
  • Binding profiles written as code, for large APIs
  • Works with .dll, .so and .dylib
Terminal
larva bind kernel32.dll kernel32.bind --source Kernel32.ant
Kernel32Bindings.dll: Kernel32 with 4 function(s) of kernel32.dll
Kernel32.ant: Antril source
Native bindings
Native.ant
import System;
import System.Runtime.InteropServices;

into namespace Native
{
    [Import("kernel32.dll")]
    GetCurrentProcessId() : u32;

    [Import("kernel32.dll", "lstrlenW")]
    WideLength(String<u16> text) : i32;

    Main()
    {
        Console.WriteLine(GetCurrentProcessId() > 0);
        Console.WriteLine(WideLength(new String<u16>(Unicode.ToUtf16("hello"))));
    }
}

A package ecosystem

Hive: signed packages, one command away.

Every package is hashed and can be signed by its author. larva hive add Author/Name adds one to your project.

Latest packages

No package is published yet. Yours could be the first.

Publish a package

Most depended on

When packages start depending on each other, the most used ones show up here.

Using packages

Built for editors

A language server that knows your whole project.

The VS Code extensions bring Larva’s language server to your editor: the same compiler, as you type.

  • Completion with automatic imports, and go to definition
  • Diagnostics and borrow checking on every change
  • Readable, navigable views of compiled libraries
  • .queen project files that apply as you save

Languages on Larva

Antril is the first. It doesn’t have to be the only one.

Larva compiles any language that has a language pack. Packs are signed by their authors and by the registry, and share the standard library, the back ends and Hive.

From the community

What people say

These spaces are placeholders until the first community quotes are in. Building something with Antril? Tell us in the forum.

Placeholder
A quote from someone building with Antril, Larva or Hive will appear here.
Community member 1Their project
Placeholder
A quote from someone building with Antril, Larva or Hive will appear here.
Community member 2Their project
Placeholder
A quote from someone building with Antril, Larva or Hive will appear here.
Community member 3Their project

Start building with Antril

Install Larva, create a project and run it in under a minute.

larva new Console-App Hello --lang antril
Esc