Mantra is a fast, expressive programming language built in Rust & C++. Full object-oriented design โ classes, interfaces, inheritance, abstract classes & static members โ with Python-like readability.
Every feature in Mantra exists to help you write clear, structured, maintainable code — at any scale.
__init__, and self. Build real data models fast.interface. Any class can implements multiple interfaces enabling true polymorphism.extends parent classes, call super().__init__(), and override methods. Full multi-level class hierarchies.abstract class and abstract def. Force subclasses to implement required behaviour.static. Utility classes like MathUtils.square(7) with zero boilerplate.@property getters and object composition โ build rich models by assembling simpler objects.mantrac_lexer, mantrac_parser, mantrac_vm, mantrac_codegenโฆ). Native code output via Clang.mantra.lang, mantra.io, mantra.util.collections, mantra.net.http, mantra.sql.orm.mantra.toml manifests.mantra.io, mantra.net.http,
mantra.sql.orm โ as a foundation to build libraries and share them with the community.
The MDK provides mantra new, mantra doc, and mantra fmt
so contributing is one command away.
Mantra ships with a curated set of packages covering I/O, collections, networking, and database access — no third-party setup required.
Core language foundation, primitive wrappers, and base exceptions.
Console output, file read/write, and environment variable access.
Classic data structures: hash maps, stacks, and queues.
HTTP request/response models and server routing primitives.
Pluggable database adapters: swap MySQL and PostgreSQL without changing your service code.
Developer tooling: project scaffolding, doc generation, and formatting.
HTTP server, URL router, request/response models, middleware pipeline, and template engine.
REST controller base, JSON serializer, typed route handlers, and standardised API response envelope.
Now includes QueryBuilder (fluent SQL), SQLiteAdapter (embedded / :memory:), and Migration + SchemaBuilder.
Explore the language feature by feature โ every snippet is runnable with mantrac.
Every .mantra file passes through a deterministic 6-stage pipeline built
entirely in Rust. The same clean source code can either run instantly on the
Mantra VM or be compiled to a fully optimised native binary via Clang — your choice at the command line.
.mantra)Developers write expressive, Python-like Mantra source code โ classes, interfaces, functions. The file is read as UTF-8 text and passed to the lexer.
mantrac_lexerThe Rust lexer scans the raw characters and produces a flat Token Stream (keywords, identifiers, literals, operators). No allocation-heavy trees yet.
mantrac_parserA zero-copy recursive-descent parser turns the token stream into a typed Abstract Syntax Tree (AST) using nodes defined in mantrac_ast.
mantrac_checkerName resolution, interface contract verification, and override correctness are enforced. Errors are reported with precise source locations before any code runs.
mantrac_vm --emit vmThe verified AST is walked by the Rust bytecode interpreter. Zero compile delay โ perfect for scripting, REPL sessions, and rapid iteration during development.
mantrac_codegen --emit nativeEmits portable C99 from the AST, then invokes Clang/LLVM to produce a fully optimised, OS-native binary. Maximum performance for production workloads.
Mantra bridges the gap between developer productivity and machine performance. Write expressive, readable code once โ execute it two ways.
mantrac_vmThe Mantra VM is a tree-walking bytecode interpreter written in Rust. Your source is parsed, type-checked, then executed directly โ no intermediate binary. Ideal for scripting, test suites, CI pipelines, and interactive REPL sessions.
mantrac_codegenThe code generator emits portable C99 from your verified AST, then hands it to Clang/LLVM for full optimisation. The result is a platform-native binary โ no runtime, no GC, no VM overhead. Used for production services, CLI tools, and performance-critical applications.
Mantra is MIT-licensed and community-driven. Use the standard packages as building blocks, publish your own libraries, and help shape the language through GitHub contributions and RFCs.
Build on top of mantra.lang, mantra.io, mantra.net.http, and mantra.sql.orm. Complete docs with examples for every class and method.
Create a new Mantra project, implement your library, and publish it. The MDK handles project layout, doc generation, and formatting automatically.
The 8-crate Rust workspace is structured for contribution. Add stdlib classes, fix bugs in the checker, improve the VM, or write new codegen backends.
View on GitHub →Mantra's unambiguous syntax makes it the ideal language for AI-assisted coding. LLMs produce correct Mantra code with high reliability โ fewer corrections, faster shipping.
See Examples →Install the MDK, create a project, write your first .mantra file, and run it.
Download the installer for your platform from the Downloads page, then verify:
Use the MDK scaffolder to generate a project skeleton:
Edit src/main.mantra and run with mantrac: