r/Compilers • u/ryusei3135 • Sep 19 '26
I made my own programming language and I would like to get some feedback.
https://github.com/ryusei3135/hexl-languageI made my own programming language and I would like to get some feedback.
One of the main features of this language is a contract system.
For example, it can be used to safely handle functions like "malloc" and "free".
If a value has a contract, you have to finish the contract before leaving the scope.
The compiler checks whether the required function is called.
For example:
a: int * must=free = malloc(10)
[a] = 123
free(a)
In this example, "a" has a contract with "free".
If I forget to call "free(a)", the compiler gives an error.
It is also possible to define contracts for functions and structs.
My goal is to make low-level programming safer while still keeping the language simple and close to the hardware.
I am still developing the language, so I would like to hear opinions from people who are interested in programming languages.
What do you think about this idea?
Are there any similar features in other languages that I should look at?
And what problems do you think this kind of contract system could have?
Any feedback is welcome.
2
u/Admirable-Mind54 Sep 19 '26
The concept of contracts is interesting to me as someone who is planning their own language to be made at a future date. Did u get any inspiration from existing languages and what do u choose to mirror?
2
u/adityazero Sep 19 '26
Programming with contracts is quite interesting and few languages have been able to pull it off successfully. C++ hasn't been able to do that yet. Question: how do you make sure contracts are respected across calls/modules? In Vx, we use requires/ensures attributes to ensure this across calls (See: https://vxlang.org/docs/contracts.html )
2
u/rantingpug Sep 20 '26
This is a kinda of session types, is it not? Could clarify how exactly you track these contracts in the typechecker?
2
u/Green_Dog4314 Sep 22 '26 edited Sep 22 '26
I think it is a good thing to make a language yourself. congradulation! But the commit is a bit mess..
By the way, it is kind of great power for one can commit 164 times during 2 months.. And I believe you that instead of using cargo new, but write the Cargo.toml yourself? or just change the edition back? Any way, with the new cargo, you should get edition 2024 by default. Maybe I just have consider too much
Sorry, maybe this comment is not related to your project, I just want to receive the answer..
Any way, this language is similar with EIFFEL language, maybe you can read the old paper or code as reference?
As soon as this is created by yourself, I think it is a good practice
6
u/AnArmoredPony Sep 19 '26
>first commit: Jun 13, 2026
>edition = "2021"
yeah, you made
4
u/KingOfZero Sep 19 '26
Google the EIFFEL language from 1985