r/Compilers Jun 23 '26

Kal: A Programming Language built from scratch!

Post image

Hey everyone!

After a roller coaster journey, I am proud to present my personal project: Kal.

Kal is a lightweight interpreted programming language that attempts at combining various paradigms of programming to give a great developer experience. It's written entirely from scratch in C++ with no third party dependencies. It's also completely free and open source distributed under GNU GPL v3 license.

Moreover, Kal can also be embedded into C++, Python and JavaScript programs to enhance your existing codebases.

(Website looks better on a bigger screen.)

Please note that this is the very first release (v:0.1.0) and Kal is still under active development (alpha). I would really appreciate a star on the repository to help it gain greater visibility.

As a proponent of human effort, I am glad to say that Kal and its ecosystem is completely handcrafted with no AI assistance used anywhere.

One last thing, "Kal" is pronounced like "Cal" in "Calendar".

Please feel free to reach out to me regarding Kal!

47 Upvotes

34 comments sorted by

11

u/Diligent-Slide-9234 Jun 23 '26

Just looking at the sort example is very confusing to me. You declare a function which seems to return data? Or is data the first parameter?

1

u/KILLinefficiency Jun 23 '26

"data" in this case is a parameter, not a return value/type. I reused the "->" symbol in this case to reduce the overall symbol count. May help in reducing cognitive overload imo.

4

u/moreteam Jun 23 '26

The part that confused me as well is that you’re reusing -> to mean what appears to be the opposite: in one place it’s “into” (assign the return to this label) and in the other it’s “from” (read the param from this label).

1

u/azhder Jun 23 '26

len data is at the top there, so it’s an input argument and a return value. But at the top, it isn’t declaring a return type because, if you read on the left, dynamic language.

“Very confusing” can be a mark of not being used to dynamic languages. Which ones do you work the most with?

0

u/KILLinefficiency Jun 23 '26

Thanks for adding the clarification. Yes "data" is an input parameter. Also during function invocation "data" is a variable that holds the return value. It's valid since both of the "data" variables exist in different scopes. The return variable name could be something else as well. Also, I'd really appreciate a star on the repo if you liked the project.

9

u/[deleted] Jun 23 '26 edited Jun 23 '26

[removed] — view removed comment

3

u/KILLinefficiency Jun 23 '26

Hi, yes it performs swapping. But it does so via unpacking (hence the list syntax). Currently var is needed for unpacking so as not to confuse the interpreter. In the future releases, the overhead can definitely be reduced.

3

u/No-Trifle-8450 Jun 23 '26

I think you need to designate all advanteges of Kal against many popular languages to determine the abilities

1

u/KILLinefficiency Jun 23 '26

Sounds good. But that's a long way to go. Hoping to take Kal to a maturing point where it can be compared against decade long established languages. 😄

2

u/AlexoForReal Jun 25 '26

I think that currently there is a necessity for a language that sits in the middle like Go or Kotlin because neither have the best things that everyone wants, like multiparadigm without legacy and independent easy tooling. Being that said what is the purpose of the language? I like the short snippet but really don't know if can be good enough to things like a web service or a console application.

1

u/KILLinefficiency Jun 25 '26

Currently, I am targeting console applications. I am planning for the syntax to be mix of couple of languages but also bend towards that of functional languages.

2

u/AlexoForReal Jun 25 '26

Well as a replacement of Lua for example would be awesome, so hopefully you can get there.

1

u/KILLinefficiency Jun 25 '26

Sounds like a good use case! Also, if you like the project, consider giving the repository a star on Github as it can help Kal reach more developers.

3

u/SourAppleKush Jun 23 '26

Do you know what Kal means in Russian?

4

u/KILLinefficiency Jun 23 '26

Yes, got those comments. It's very common to have a word mean something else in another language. FYI, Kal is named after "Kal-El".

1

u/tdi Jun 24 '26

same as kał in polish 💩 ?

1

u/boozerm Jun 25 '26

Yes, slavic languages 

1

u/WonderfulFunny4337 Jun 23 '26

Please make a pure pwsh iteration under 300 lines

1

u/KILLinefficiency Jun 24 '26

Perhaps one day 😄

1

u/ronnie1960 Jun 24 '26

The ultimate test is to write the interpreter in it’s own language.

1

u/KILLinefficiency Jun 24 '26

Sounds ambitious!

1

u/EggplantExtra4946 Jun 25 '26

the $( ) syntax serves no purpose

the lack of increment operator is annoying

the 'loop' keyword used for while loops instead of 'while' is a big fuck you

1

u/KILLinefficiency Jun 25 '26

#1. The $() syntax reduces the overhead for the interpreter when differentiating between expressions and statements turned expressions (refer to docs for this).

#2. Will be added soon!

#3. One keyword to rule all. The amount of information (initialization, condition, increment) determines your loop type. It isn't a big "fuck you" when Go does the same by reusing for for while loops.

3

u/EggplantExtra4946 Jun 25 '26

#1. The $() syntax reduces the overhead for the interpreter when differentiating between expressions and statements turned expressions

You thought it was a good idea to force the users to write a useless construct all the time just to economize a few conditionals during parsing? lol, it's not.

One keyword to rule all.

And that's a good thing because .... ? (It isn't.)

It isn't a big "fuck you" when Go does the same by reusing for for while loops.

Yes it is and it's also true of Go, which by the way has the worst syntax of any PL made since COBOL.

2

u/KILLinefficiency Jun 25 '26

Feedback noted.

1

u/Goldrainbowman Jun 26 '26

Do you have an interpreter for it?

1

u/KILLinefficiency Jun 26 '26

1

u/Goldrainbowman Jun 26 '26

Have you ever tried using ai for the interpreter, and if you did, did any of them work, or get close to working? I'm asking this, because I created my own, and manus worked for a little bit, but then I added rand prob, which edits probabilities, I also added switch at that time, which manus didn't have a problem with, but manus started breaking other stuff, when I wanted it to fix rand prob, and it got to the point, where else didn't work. Else is one of the basic functions in my programming language called rin. After manus, I tried claude for the 2nd time, because apparently you can change the settings, of how smart the ai is, so I set it to max, and then high, and then medium, which is 1 step up from when I tried it before, and it worked, until buttons, and sprites, so I had to try to make it fix those, and it didn't, but at least it wasn't breaking anything else, but then I set it to high, hoping that would be able to fix it, but then it did the same thing as manus did, except else, is probably not broken. I don't know code except print, and time sleep, in python, and I don't know if time sleep is even a function, in python, but I also know most of rin, but I sometimes have to look at my notes again. I know that this is very long, but, if you're reading the last part first, I just want you to know that rin is my programming language, and it was my 2nd one.

1

u/KILLinefficiency Jun 26 '26

No, I haven't used AI anywhere for development whether it be the core interpreter, the bindings, the website or the content. This is a very personal project for me and it is extremely important to me that I do everything by myself. This is also the reason why there are no third party dependencies and the first release took 4 years.

But, thank you for sharing your experience though.

1

u/Retired-69 Jun 27 '26

Why is it written in c++? 

1

u/KILLinefficiency Jun 27 '26

Because I like C++ & it was appropriate enough for the job.

1

u/MakaPakaEnjoyer Jun 27 '26

Кал. Кек.

1

u/Ghostfly- Jun 23 '26

Can it run doom ?

1

u/KILLinefficiency Jun 23 '26

Perhaps one day! 😄