

GitHub - austral/austral: Systems language with linear types
source link: https://github.com/austral/austral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Austral
Not done yet.
Austral is a new language.
Features:
-
Linear types: linear types allow resources to be handled in a provably-safe manner. Memory can be managed safely and without runtime overhead, avoiding double
free()
, use-after-free
errors, and double fetch errors. Other resources like file or database handles can also be handled safely. -
Capabilities: linear capabilities enable fine-grained permissioned access to low-level facilities. Third-party dependencies can be constrained in what types of resources they can access. This makes the language less vulnerable to supply chain attacks.
-
Typeclasses: typeclasses, borrowed from Haskell, allow for bounded ad-hoc polymorphism.
-
Safe Arithmetic: Austral has well-defined semantics for all arithmetic operations on numeric types. There are distinct operations for trap-on-overflow arithmetic and modular arithmetic, as in Ada.
-
Algebraic Data Types: algebraic data types, as in ML or Haskell, with exhaustiveness checking.
Anti-features:
- No garbage collection.
- No destructors.
- No exceptions (and no surprise control flow).
- No implicit function calls.
- No implicit type conversions.
- No global state.
- No macros.
- No reflection.
- No Java-style @Annotations.
- No type inference, type information flows in one direction.
- No uninitialized variables.
- No pre/post increment/decrement (
x++
in C). - No first-class async.
- No function overloading (except through typeclasses, where it is bounded).
- No arithmetic precedence.
Examples
Fibonacci
function Fibonacci(n: Natural_64): Natural_64 is
if n < 2 then
return n;
else
return Fibonacci(n - 1) + Fibonacci(n - 2);
end if;
end;
Building
Building the austral
compiler requires make
and the dune
build system for
OCaml, and a C++ compiler for building the resulting output.
First, install opam.
Then:
$ git clone [email protected]:austral/austral.git $ cd austral $ opam install dune ppx_deriving ounit2 menhir $ make
To run the tests:
$ ./run-tests.sh
Usage
Suppose you have a program with modules A
, B
, and C
, in the following
files:
src/A.aui
src/A.aum
src/B.aui
src/B.aum
src/C.aui
src/C.aum
To compile this, run:
$ austral compile \
--module=src/A.aui,src/A.aum \
--module=src/B.aui,src/B.aum \
--module=src/C.aui,src/C.aum \
--entrypoint=C:Main \
--output=program.cpp
This is the most general invocation. Where module interface and module body files share the same path and name and differ only by their extension, you can use:
$ austral compile \
--module=src/A \
--module=src/B \
--module=src/C \
--entrypoint=C:Main \
--output=program.cpp
The order in which --module
options appear is the order in which they are
compiled, so it matters.
The --entrypoint
option must be the name of a module, followed by a colon,
followed by the name of a public function with the following signature:
function Main(root: Root_Capability): Root_Capability;
Finally, the --output
option is just the path to dump the compiled C++ to.
There's also a command to typecheck a program without outputting anything. Only --module
flags are accepted:
$ austral typecheck \ --module=src/A \ --module=src/B \ --module=src/C
Status
-
The bootstrapping compiler, written in OCaml, is implemented. It has a couple of limitations, these are to speed up development so I can iterate on a working compiler as early as possible:
-
The compiler outputs templated C++ so I don't have to bother implementing a monomorphization step.
-
The compiler does not support separate compilation. In practice this is not a problem: there's not enough Austral code for this to matter.
-
-
A standard library with a few basic data structures and capability-based filesystem access is being designed.
License
Copyright 2018–2021 Fernando Borretti.
Licensed under the GPLv3 license. See the COPYING file for details.
Recommend
-
40
It gives my brain a pleasant thrum to learn new mathematics which mimics the algebra I learned in middle school. Basically this means that the new system has operations with properties that match those of regular numbers...
-
16
Introduction Into Decomposition Methods of Linear Equation Systems – thoughts on coding
-
6
13 March 2017 — by Jean-Philippe Bernardy and Arnaud SpiwackLinear types make performance more predictableWe’re extending GHC with linear types. Ever since Jean-Yves Girard discovered
-
7
First M2 MacBook Air Orders Now Arriving to Customers in New Zealand and Australia
-
5
Introducing Austral: A Systems Language with Linear Types and Capabilities Austral is a new systems programming language. You can thi...
-
7
How Austral’s Linear Type Checker Works What I cannot create, I do not understand. — Richard Feynman Austr...
-
11
February 10, 2023 ...
-
11
Friday, 21 April 2023 11:19 ACCC seeks views on ‘competition and consumer issues’ affecting Australian savers Featured By Gordon Peters ...
-
5
How Capabilities Work in Austral Code is permissionless by default. Rather, all code within the same address space runs with uniform permissions, despite different modules having different...
-
1
The Austral Programming Language The Austral Programming Language Austral is a new systems programming language. It uses linear types to provide memory safety and
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK