Ferrite (programming language)
From Wikipedia, the free encyclopedia
| Paradigm | Multi-paradigm (Functional, Imperative, Tensor) |
|---|---|
| Designed by | Vishwanath M M |
| First appeared | January 2026 |
| Stable release | 2.4.1 (July 2026) |
| Typing | Static, Strong, Nominal, Inferred |
| Implementation | Rust |
| License | MIT / Apache-2.0 |
| Website | ferrite-lang.org |
Ferrite is a statically-typed, ahead-of-time compiled, and interpreted programming language developed specifically for artificial intelligence, machine learning, and systems programming. Designed and created by Vishwanath M M in 2026, the reference compiler implementation is written in Rust.
Ferrite features native multi-dimensional tensor primitives with
compile-time shape verification, zero implicit type coercion,
compiler-generated automatic differentiation, and
scope-delimited execution contexts (such as
train and infer blocks).
History
Development of Ferrite began in early 2026 to address productivity and runtime safety challenges in machine learning software development. While languages such as Python dominate machine learning research due to dynamic flexibility, they frequently suffer from runtime shape mismatch errors, heavy interpreter overhead, and dynamic typing bugs. Conversely, native systems languages such as C++ or Rust require complex foreign function interface (FFI) bindings to interface with high-level tensor computing libraries.
Ferrite was designed as an "AI-Native" compiled language that integrates tensor algebra directly into the language specification and type checker.
- v1.0.0 (Jan 2026): Initial release featuring the core lexer, recursive descent parser, and tree-walk interpreter supporting primitive types and basic control flow.
-
v1.4.0 (Mar 2026): Introduced nominal struct
types (
group), interface contracts (trait), and algebraic data types (enum) with pattern matching. -
v2.0.0 (May 2026): Integrated compile-time
shaped tensor generics (
Tensor<T, Shape>) and matrix multiplication operators. -
v2.4.0 (Jul 2026): Added a full module
import/export system with symbol visibility controls
(
pub) and explicit symbol aliasing. - v2.4.1 (Jul 2026): Added first-class function closures and published the 21-chapter Engineering Knowledge Base (EKB) compiler specification.
Design and philosophy
Strict type safety and zero coercion
Ferrite enforces absolute type safety. The compiler does not
perform implicit type coercion (such as automatically promoting
an integer to a floating-point number or evaluating non-boolean
values in conditional statements). Numeric conversions require
explicit cast invocation (e.g., float(x)).
Compile-time tensor shape verification
Tensors in Ferrite are first-class language primitives. Tensor
dimensions are declared within generic type signatures (e.g.,
Tensor<float, (100, 784)>). During semantic
analysis, the compiler validates matrix operations (such as
matrix multiplication via the @ operator) against
dimension compatibility rules at compile-time, eliminating
runtime dimension mismatch errors.
Execution context blocks
Ferrite provides dedicated language blocks to declare execution intent:
-
train { ... }: Enables automatic differentiation tracking and gradient calculation buffers. -
infer { ... }: Disables gradient tracking and backpropagation overhead, optimizing execution purely for forward-pass inference.
Syntax and semantics
Variables and mutability
Variables declared with the keep keyword are
immutable by default.
// Immutable constant
keep pi: float = 3.14159;
// Reassignable variable
keep count: int = 0;
count = count + 1;
Pattern matching
enum Result<T> {
Ok(T);
Err(string);
}
match status {
case Ok(code) if code == 200 => println("Success");
case Err(msg) => println("Error: " + msg);
}
Examples
Tensor matrix multiplication
import "math";
// Validated matrix dimensions: (100, 784) x (784, 10) => (100, 10)
param inputs: Tensor<float, (100, 784)> = ones();
param weights: Tensor<float, (784, 10)> = rand();
infer {
keep logits = inputs @ weights;
println("Output tensor computed successfully.");
}
Implementation
The reference implementation of the Ferrite compiler is written in Rust. Its pipeline comprises a Lexer, Recursive Descent Parser, Semantic Analyzer for shape unification, and dual execution targets (Tree-Walk interpreter and LLVM AOT codegen).
References
- Ferrite Official Website - Ferrite Language Specification.
- Ferrite Engineering Knowledge Base (EKB) - Architecture & Compiler Architecture.
- Ferrite GitHub Repository - Compiler Source Code.