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

1

u/Francog2709 Jul 08 '26

Mmm, well obviously you should have a little knowledge on at least what symbolic algebra is I guess. I don't want to make docs that are endless to read. I want them to introduce you to the idea of the project for now (the project is still pretty young, less than a year).

What is it in particular that you think could be improve in the docs?

We waste a lot of time right now thinking "is this bad writing, advanced math, or just AI psychosis?"

Well, yes. Believe it or not, I try not to use AI. In fact, this project has no target other and learning compilers and just for the love of programming.

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!