r/rust • u/Francog2709 • Mar 16 '26
🛠️ project Mathic: My Programming Language
Hi everyone!
My name is Franco. This is a post to introduce Mathic to the public. Perhaps it is too early, perhaps not — I wanted to do it anyway.
Mathic is the programming language I always wanted to build. It started as a way of learning and improving my skills with MLIR/LLVM. My goal is to build a language with simplicity as its first-class implementation driver, with native support for symbolic algebra.
Mathic is built with Rust, from which its syntax took some inspiration, and as I mentioned, LLVM/MLIR.
The project is at quite an early stage right now. However, it does support some features like control flow, variables, functions, structs, and types.
I would very much appreciate feedback from anyone. Also, if anyone has experience with MLIR, I'd love any recommendations on things that could have been done better.
View all comments
Show parent comment
1
u/Francog2709 Mar 26 '26
With melior, the crate I'm using for MLIR, you need to create the dialect in C++/TableGen. Then it gives you some macros to ease the use of the dialect itself from rust (it's basically how it handles ods dialects). However it uses MLIR-C bindings, so properly use a custom dialect, you need to adapt it to the C interface to be able to integrate it with rust through melior. Fortunately, LLVM already has some functions to allow this adaptation.
I played a little trying to integrate a custom dialect with rust in this repo: https://github.com/FrancoGiachetta/mlir-tut-impl . It does nothing since I've never finished it, but might be a good starting point I guess.