Hello everyone, today I will share with you the story about my programming language Amun, which is an open source low level general purpose language that compile to machine code using LLVM Framework.
The story begins two years ago, when I am as a self taught software engineer learning the subjects of computer science and in this time, I started to learn about Compiler design for the first time from Courses and Books, I created many small programming languages some of them are for specific goals like creating bots, drawing shapes …etc
I really loved the career of Compiler engineer and started to learn more about it, reading source code, try to design new features, watching live streams about compilers.
In the last year, I got the idea to design a high performance language that should be fast as C/C++ but to be very simple and easy to learn, also to give you some features to create good libraries and DSL (Domain specific Languages).
I already created a design for a small language with some features and concepts inspired by other languages such as C/C++, Go, Rust, Jai, Swift, Kotlin, and I started to simplify this design and named it Jot.
What I want is a language that is simple as C and Go, no preprocessor, no garbage collection (remember I need a high performance language).
It also has such as Type inference and Generic Programming support, Compile time stuff, lambda expression, operator overloading, infix, prefix and postfix functions inspired by Swift, and some cool other features for examples.
Lambda expression with the ability to move lambda moved out of parentheses in function call and constructor
var lambda = { printf("Hello from lambda!\n"); };
fun let(value *void, callback *() void) {
if (value != null) { callback(); }
}
fun main() {
let(null) {
printf("Will never printed");
};
}
Also, to come up with an easy way to iterate over arrays and strings.
for array { printf("array[%d] = %d\n", it_index, it); }
for item : array { printf("array[%d] = %d\n", it_index, item); }
for item, index : array { printf("array[%d] = %d\n", index, item); }
Tuples so you can create a collection of different type values and use it to make a function that return more than one type
var tuple = (1, 2, "Hello", 3, 4, "World");
fun max_min(x int64, y int64) (int64, int64) {
return if (x > y) (x, y) else (y, x);
}
One of the most important goals is to have a cool and helpful compiler like rust, it should tell you messages that help you yo not only fix the bug but also understand more about problem and the language.
After some research, I found that the easiest way to create a high performance low level language is to use the LLVM Framework as a backend for the compiler so it can optimize and generate machine code for most of platforms. So I started to learn more about LLVM from Books and created a few projects with it.
In June 2022 I started to work on the compiler, and I decided to create it using C++ for many reasons such as high performance and LLVM is also created using C++ so I can easily found samples written in C++, also because I have some experience using it.
In Jan 2023 the language had most of the features that can help you to provide any programs that you can create in C but without Macros and i started to create simple programs and link with libraries such as OpenGL and Raylib to create simple GUI Applications.
Then I started to work on features that can make creating libraries and applications easier, such as tuples, operator overloading, lambda, type alias, directives and also improve the compiler error message, I can’t covering all features in this article but I will write about them latter with cool samples.
After testing the features i ported a Pong game written using C++ and Raylib in my language and this is the result.
Until this step, the language name was Jot, but I was surprised that there is already a language with the same name, so I searched for a new name, and I named it Amun. The name is inspired by Ancient Egyptian mythology when Amun was the chief deity of the Egyptian Empire.
The language is now still in development and everyone is most welcome to contribute to it. You can help with documentation, compiler, samples …etc.
You can follow the development on the GitHub repository, and there are more than 200 samples to over all language features, so feel free to star the project if you loved it.
Github Repo: https://github.com/AmrDeveloper/amun
Enjoy Programming and creating cool stuff 😇
Top comments (0)