Moth is a new programming language and toolchain.
This website was created using Moth!
Everything you see on this page, including the layout, styles, and even the text content was written in Moth files and generated using the compiler's built-in HTML project builder.
The source code for this whole website can be found on Github.
The Alpha language docs explains everything about the language, compiler and making Moth projects.
This compiler is in early alpha and is undergoing rapid development, so not everything is exactly up to date with the current compiler.
You can already use Moth for web projects, but be aware of the early alpha status
Programmers should spend less time worrying about bundling piles of languages together and what their code should look like in their codebase.
This is why Moth exists.
Most languages leave a lot of the powerful stuff we use all the time in modern development to libraries and frameworks. Template engines, bundlers, web frameworks, documentation generation and module systems often get overlooked as fertile ground for first-class features that have been tried and tested already.
Moth considers the lifecycle of a project the responsibility of the language and its integrated build system. And it should look the same no matter the scale.
When you build something powerful directly into the semantics of a language rather than bolting it on, you can go so much further without excessive complexity, nasty trade-offs or weird DSLs within the same language.
The source stays small, statically typed and opinionated, while the compiler and build system take on more of the work. Borrow validation, compile-time templates, reactive dependencies and project builders all feed through one toolchain.
Each piece of this is still modular, the language semantics stay agnostic to the platform its running on.
The HTML builder proves that model, while a backend-neutral frontend and experimental WebAssembly path push the same ideas way beyond it.
Templates are central to all of these design principles. They are Moth's most powerful feature.
Templates are core to the language and produce ordinary String values. The compiler then handles the composition, slots, control flow and Markdown formatting. When every input resolves at compile time, Moth folds the whole template to a string before HIR and code generation. When runtime work remains, only that work survives.
The HTML builder then brings Moth source, .mtf templates, Markdown, assets, routing and hot reload into the same project flow. Static content leaves no general template engine behind, and builders consume compiler graphs and link plans instead of inventing a second understanding of the program.
This docs site already runs through this toolchain.
Memory follows the same principles of simplicity for the programmer: Keep the programmer-facing model small and make the compiler prove more.
Moth treats restraint as a feature.
General closures, operator overloading, reflection, trait objects and broad metaprogramming are excluded from the language design on purpose. Those mechanisms can hide control flow, add runtime machinery or turn local code into a type-solving exercise. Moth provides simpler tools that scale better.
Moth still has plenty of rough edges but aspires to grow into a language that feels joyful at every scale without different sized projects feeling like a completely different tech stack.
If you want to explore something a bit more unique against other C-like languages, with plenty of fresh ideas and remixes of what stands the test of time, have a go at Moth.