Kang2 is now just about done. Almost every feature I set out to add is now done and should (hopefully) work.
So what did I add?
There have been complex types before, with structs but not primitive ones, like string and number. BUT NOW there are
For this, there is a built in library, which has all the functions. Speaking of which, Number two:
Currently it's very small and doesn't have a lot, because I didn't feel like adding all these features only for me. PLUS they can be added very easily. The most "complete" one is array, just because I used it a bunch of times for the brainfck compiler.
So basically when you call some function from this library, it just calls one of these functions and passes the value of the variable as self
. This, of course, happens automatically. In the last picture, you can actually see the next thing, which is:
Before, the only way to do loops was just this:
This is very simple, yes, BUT as soon as you want to actually know the current index, you'd have to do lots of gymnastics
This gets annoying quick, so now we finally have advanced loops, which look like this:
It basically compresses the old way of looping into one line, just like in Java or C. The three fields can be manipulated however you want. The first is just what gets called before the loop starts, the middle is an expression for some condition (could be a function call too) and the last is what gets called after each loop iteration. Very nice indeed
Active reference is the last and my favorite feature. One thing I really dislike about all these modern language is the lack of a way to explicitly set references.
In JavaScript it's just set a variable to another and it references it, but you HAVE to know that yourself. So somebody maybe wouldn't know that they reference each other. Also if you DON'T know about it, you may end up creating references where you actually didn't want to and suddenly two variables that should be different just became the same. If you want to copy, you HAVE to copy.
In Python there's just straight up no way of doing that, apart from either a function that returns the variable or a class that stores the variable, both of which being pretty weird to use. I've read up on how python handles memory and as SOON AS you mutate a variable, that another variable "references" (with an Object for example), the "reference" stays the same, while the actual variabe points to a new field now. This is why Yo-Masta-Nag has the "Container" class, which is just there to store something as a reference. It's highly unintuitive to use and I wish they'd just add an explicit reference.
Dart has the same problem, you will have to create a wrapper class to reference primitives. Again just dumb
Fun fact: Because I didn't find anything about references in Python, I asked the nice and friendly community of Stack Overflow, if they had an answer. The nice and friendly community of Stack Overflow gave me basically no answer BUT they directed me in a nice and friendly way of their site and of the "Ask question" button entirely.
In C# there IS a way, but to this day I haven't figured out how to use it. I'm talking about the ref
keyword. Every time I tried it, it just resulted in some long hieroglyphical error
The only languages where you can actually do that are those low-level languages like C and Rust. Rust has it's borrowing and ownership model, which ACTUALLY allows real references, while C is just barebones manual memory managment with pointers.
So, what if a language had a way to reference things explicitly? Introducing active reference!
Reference any variable only using &
and unreference using @
. This makes all the problems mentioned above pretty much obsolete. Active references was a feature I always planned to add, since the beginning, which is now almost 2 years ago.
So what now? I guess I'm finished with Kang2. There are probably still a plethora of bugs and whatever. I could continue and add another thousand things, but I feel like this is enough. The language has been in the back of my mind for the past two years and now I can finally move on to my backlog of unfinished projects. Kang2 has been one of, if not my favorite Project I've done. I'm very proud of it and It's has definitely something of a brag factor. Even though, there is a version 1.0, I really feel like only NOW has it become a full and fleshed out language. So I guess it's time to say