Skip to content

Releases: brwhale/KataScript

Official Release v1.0!

03 Aug 20:01
3bd1bfb
Compare
Choose a tag to compare

After an overlong beta period, KataScript is now officially "ready for production"! I've been putting it to the test by having the main game logic of Floppy Cat Bow Golf rely almost entirely on KataScript.

There may still be hidden unknown bugs, but all known bugs have been solved, and all initially planned functionality is - well - functional!

The biggest deal is the death of "the kraken" - which is what I named the last elusive bug. Of course it turned out to be a parsing issue, so as a bonus, I significantly streamlined the parsing process, and removed a lot of unnecessary complexity.

Moving forward, I'm looking at optimizations and extra quality of life features, if you have an idea you want to see in KataScript, please open up a GitHub issue to propose it! Thanks!

As always, you can demo KataScript in your browser! https://brwhale.github.io/KataScript/

Hotfix for if with no else

02 May 02:30
b8224e6
Compare
Choose a tag to compare

Was adding extra tests and noticed an egregious bug, so - hotfix!

the issue was as follows:

fn something() {
    var x = 0;
    if (someVar > 2) { x = 4;}
    return x;
}

That would always return null, but these variations worked fine:

fn something() {
    var x = 0;
    if (someVar > 2) { x = 4;};
    return x;
}

fn something() {
    var x = 0;
    if (someVar > 2) { x = 4;} else {}
    return x;
}

It turned out there was a parse bug that would "eat" the rest of the function after an if block until it hit an else or a ";".

Bug is now fixed so you can write functions ergonomically without worrying about it anymore!

0.9 Release - "Break"

01 May 23:04
02242ef
Compare
Choose a tag to compare

Smaller feature update this time just adds the break keyword and tests around early returning and breaking.

Destructors and Efficiency!

02 Sep 10:40
Compare
Choose a tag to compare

Classes can now have Destructors!! They work like they do in C++. Right before an instance of a class gets destroyed, it's destructor function is called if it exists. You make a destructor the same way as in C++, just make a class method named ~ClassName(). In addition to just being a nice feature, destructors will be key for the upcoming Async/Await module and many other eventual modules like http, graphics, etc.

But even more than I'm excited about destructors, I'm excited to have finally refactored away the biggest hack in the whole codebase! That hack was called "applyfunction". Very early on in the project, I wanted functions as a first class type. To facilitate functional programming, I added a simple and powerful function: "applyfunction". You can call applyfunction(print, someVar) to print a var or even applyfunction("someFuncName", someVar1, someVar2, etc). Then I realized I could also use the function inside the interpreter! And that's where things started getting weird. It started off innocuous though, I made a shortcut syntax, unknownFunc(a, b, c) which would desugar into -> applyfunction("unknownFunc", a, b, c). That was pretty cool! It made code easier to read and I could cache the function lookup to slightly boost speed. Then I started making structs. "I already have this nifty function lookup tool, I can just use that for structs too!" I thought, and then I extended applyfunction to work with structs. And then structs evolved into classes with inheritance and somewhere along the way every single function was going through applyfunction, even stuff like sqrt, even applyfunction itself if you called it by name! The only thing that was spared were the math operators. What a mess! So I finally added real AST Expression types for class member functions and variables and did away with all that nonsense!

As always, the live demo is up to date with the current version of KataScript: https://brwhale.github.io/KataScript/

Destructors:

In KataScript:

var beanCount = 0;
class BeansClass {
    var color = "white";
    func BeansClass(col) {
        color = col;
        beanCount++;
    }
    func ~BeansClass() {
        beanCount--;
    }
    func changeColor(col) {
        color = col;
    }
    func isRipe() {
        return color == "brown";
    }
}

Equivalent C++ injected class:

KataScriptInterpereter interpreter;
auto interp = &interpreter;
interpreter.newClass(
    "BeansClass", 
    { { "color", std::make_shared<KataScript::Value>("white") } }, 
    [interp](KataScript::Class* myClass, KataScript::ScopeRef scope, const KataScript::List& vars) {
        if (vars.size() > 0) {
            interp->resolveVariable("color", myClass, scope) = vars[0];
        }
        (*interp->resolveVariable("beanCount"))++; 
        return std::make_shared<KataScript::Value>(); 
    }, {
        { "~BeansClass", [interp](KataScript::Class* classs, KataScript::ScopeRef scope, const KataScript::List& vars) {
            (*interp->resolveVariable("beanCount"))++; 
            return std::make_shared<KataScript::Value>();
         }},
         {"changeColor", [interp](KataScript::Class* myClass, KataScript::ScopeRef scope, const KataScript::List& vars) {
             if (vars.size() > 0) {
                 interp->resolveVariable("color", myClass, scope) = vars[0];
             }
             return std::make_shared<KataScript::Value>();
         }},
         {"isRipe", [interp](KataScript::Class* myClass, KataScript::ScopeRef scope, const KataScript::List&) {
             auto color = interp->resolveVariable("color", myClass, scope);
             if (color->getType() == KataScript::Type::String) { return std::make_shared<KataScript::Value>(color->getString() == "brown"); }
             return std::make_shared<KataScript::Value>(false);
         }},
    }
);

Stability and Correctness

21 Aug 01:07
Compare
Choose a tag to compare

In the last year there have been tons of small bugfixes! Now, nearly every corner of the language has been unit tested!

To celebrate a new era of stability, I will no longer be pushing directly to main! We are now doing active dev in new feature specific branches. From here forward, main will be updated on releases only.

As always, you can demo the new features here: https://brwhale.github.io/KataScript/

Next steps: Finish the modules system! Once the modules are complete, we will be ready for version 1.0! 🎉🥳

Structs have evolved into Classes

10 Jan 10:05
Compare
Choose a tag to compare

Well, structs got multiple inheritance, so I renamed them to class

Now you can do this:

class xx { 
    var x; 
    func xx(_x) { 
        x = _x; 
    } 
    func add(_x, _y) { 
        x += _x; y += _y; 
    } 
}
class yy { 
    var y; 
    func yy(_y) { 
        y = _y; 
    } 
    func sqr() { 
        return x * y; 
    } 
}
class prexy -> xx, yy { 
    func prexy(_x, _y) { 
        x = _x; y = _y; 
    } 
}
class xy -> prexy { 
    func xy(_x, _y) { 
        x = _x; y = _y;
    } 
}
a = xy(4,5.0); b = copy(a); b.add("a","b"); c = a.sqr(); a.add(4,5); d = a.sqr(); e = a.x; f = a.y;
print(a);
// prints:
// xy:
// `x: 8`
// `y: 10.000000`
// `add: add`
// `sqr: sqr`
print(b);
// prints:
// xy:
// `x: 4a`
// `add: add`
// `y: 5.000000b`
// `sqr: sqr`
print(c);
// prints: 20.000000
print(d);
// prints: 80.000000
print(e);
// prints: 8
print(f);
// prints: 10.000000

Bash Shebang and Makefile

10 Jan 01:31
Compare
Choose a tag to compare

KataScript now has a makefile! It's not the most amazing one, as it requires you to manually install g++9, but it is better than the old g++ script since it can install the interpreter into your local bin.

make
make install

And now you have KataScript in your PATH and usable from any folder

In bigger news, KataScript now supports Bash Shebang semantics, so you can use KataScript in shell scripting like so:

#!/usr/bin/env KataScript
print("hello ", "world");
// any other script stuff you want

Also we now support a new type: userpointer. It's an opaque pointer type so you can store pointers in KataScripts without having to cast them to ints or anything weird like that.

Structures!

08 Jan 02:46
5f4db2a
Compare
Choose a tag to compare

As always, you can try KataScript in your browser: https://brwhale.github.io/KataScript/

KataScript now has structs!

struct person {
    var name;
    var age;
    var hobby;
    func person(n, a, h) {
        name = n;
        age = a;
        hobby = h;
    }
    func wouldLike(other) {
        return hobby == other.hobby;
    }
    func greet() {
        print("Hey I'm " + name + ", age " + age + ", and my hobby is " + hobby);
    }
}

Hooray!

The other big new feature is dot syntax for functions! What this means is that:

function(var1, var2, var3);

and

var1.function(var2, var3);

Are now equivalent. What this means is that you can call the standard library free functions as though they were member functions of a non-struct type. This allows you to create free functions with the same name as a struct's member function to create a sort of dynamic template.

struct A {
    var x;
    func A () {
        x = "A";
    }
    func getName() {
        return x;
    }
}

struct B {
    var x;
    func B () {
        x = "B";
    }
    func getName() {
        return x;
    }
}

func getName(x) {
    return string(x);
}

print(A().getName());
// prints: A
print(B().getName());
// prints: B
print("tacos".getName());
// prints: tacos

This release also includes minor features like the new toarray()/tolist() for casting to list/array rather than the weird overloading of the array()/list() functions, so now array(), and list() with just one argument will now make a list/array of length one and containing just that one argument.

Bugfixes and stability

01 Jan 01:58
2a75b81
Compare
Choose a tag to compare

It's been about a week since I've added any bugfix patches, so to celebrate the relative stability, we're doing release v0.2! New features include: 64 bit number types, more standard functions, and more unit tests.

KataScript v0.1 - Initial Release!

23 Dec 23:53
Compare
Choose a tag to compare

With the addition of Dictionaries, lower level Arrays, higher order functions, unit tests, and removal of lots of bugs, KataScript now has all the tools required to solve just about any game scripting challenge!

Learn KataScript!

Play with KataScript!