r/Compilers • • Jul 08 '26

Mathic: A programming language with builtin symbolic algebra

Hi everyone!

My name is Franco. In a previous post, I made a little introduction to Mathic and its purpose. In this post I want to make continuation of it.

By the time I was writing the previous post, Mathic did not have in symbolic capabilities. Now, it does. For now, there's support for simple arithmetic operations like addition, subtraction, multiplication and division.

I wanted this feature not to be implemented in the rust side, so I created a custom dialect symbolic for the job. This dialect is, of course, responsible of handling symbolic operations. This operations then get lowered to arith operations to be able to lower them to LLVMIR at the end of the compilation.

Currently, the dialect supports operating with symbols (placeholder that then get replaced when evaluating an expression with a value), numerical constants and numerical variables. However, currently it's not possible to modify an expression inside a loop (this is a know bug for now and next to be fixed).

The final idea, if ever happens, is to make something similar to sympy but compiled to machine code, and thus faster.

I would appreciate any advises, things that could be done better. Specially on the dialect implementation, which is my very first one.

Thanks!

31 Upvotes

10 comments sorted by

View all comments

Show parent comment

0

u/Inconstant_Moo Jul 08 '26

Well, yes. Believe it or not, I try not to use AI.

I already congratulated you on not being insane or an LLM, But the point is, it's getting harder to tell. Unless you can explain what you're doing to other humans so they can understand it, they're not even going to look at it.

1

u/Francog2709 Jul 08 '26

Oh, please don't get me wrong, I totally agree with you on this. I'll be working on improving the documentation then. Thanks for the suggestions!