ATS (language)
ATS (Applied Type System) is a statically typed, functional and imperative programming language that uses dependent and linear types to let programmers formally verify memory safety and program correctness at compile time while generating…
Definition
ATS (Applied Type System) is a statically typed, functional and imperative programming language that uses dependent and linear types to let programmers formally verify memory safety and program correctness at compile time while generating C-level performance code.
Overview
ATS was designed by Hongwei Xi, building on his earlier research into dependent types (in the language DML) and separation logic, with the goal of unifying two normally separate activities — writing a program and formally specifying/verifying its properties — inside a single practical language. ATS's type system supports dependent types (types that can depend on values, such as an array type parameterized by its exact length) and linear types (which track that a resource, such as a manually allocated pointer or file handle, is used exactly once and properly disposed of), allowing many classes of bugs — out-of-bounds array access, use-after-free, double-free, resource leaks — to be caught by the type checker rather than discovered at runtime or via external verification tools. Despite this heavyweight type system, ATS compiles to C and is explicitly designed to run with performance comparable to hand-written C, with no garbage collector required for code using its linear types, and with proof-related constructs erased entirely at compile time so they impose zero runtime cost. This makes ATS unusual among languages with strong formal-verification capabilities, which are typically much slower or dependent on managed runtimes; ATS instead targets the same low-level, systems-programming niche as C and C++ while offering compile-time safety guarantees closer to those of proof assistants like Coq. ATS has a notoriously steep learning curve, since writing idiomatic ATS often means writing not just a program but also a proof, expressed in the language's own syntax, that the program satisfies certain invariants. As a result it has remained primarily a research and enthusiast language rather than a mainstream industrial one, used in academic work on verified systems programming, safety-critical or security-sensitive low-level code, and as a case study in how far static verification can be pushed without sacrificing C-like performance.
Key Features
- Dependent types allow types to be parameterized by runtime values (e.g., an array's exact length)
- Linear types enforce that resources like pointers or file handles are used exactly once and freed properly
- Compiles to C and targets performance on par with hand-written C code
- Proof-related type-checking constructs are erased at compile time with zero runtime cost
- No garbage collector required for code that relies on linear types for memory management
- Combines functional and imperative programming styles in one language
- Can catch memory-safety and resource-leak bugs at compile time rather than at runtime