Yong He

Project - GxScript 3.0

This is an object-oriented and dynamic functional scripting language. A virtual machine is implemented to execute the intermediate instructions generated by the compiler. The scripting engine provides interfaces on both native C++ and .net managed environment for compiling and hosting scripts.The project also provided a convenient IDE (developed in C#) for coding and debugging. This version is evolved from two prior experimental versions, each adds new language features.

Features of GxScript include:

  • Dynamic type system
  • Higher order functions (closures)
  • Complete object oriented programming support
  • Properties
  • Multiple inheritance
  • Exceptions
  • Operator overloads
  • Constructor and destructor
  • Function overload
  • Cascaded class definition
  • Runtime code compilation and execution
  • Garbbage collection
  • Reflection
  • Dynamic changing class definitions
  • Interop with hosting application

You can download the Windows binary package here [gxscript3_win32_bin.zip] (3.3 MB). While the core engine is written in C++, the IDE of GxScript is written in C# and requires at least .Net Framework 3.5 to run. The package contains serveral example projects that may help you get started with GxScript.

Sample program 1: higher order functions

var array = [1,2,3,4,5];
var Applier = function(function f, array arr)
{
    // you can also use for each statement here.
    for (i=0; i<arr.Size; i++)
        arr[i] = f(arr[i]);
}
Applier(function (int x) {return x^2;}, array);
writeln(array);

Output:

[1, 4, 9, 16, 25]

Sample program 2: dynamic classes

class Dynamic
{
public:
    var memberA;
    constructor()
    {
        memberA = 5;
    }
}
var obj = new Dynamic();
writeln(obj.memberA, " ",obj["memberA"]);
writeln(obj._prototype.ClassName);
obj._prototype.Members.Add("memberB", 0);
obj.memberB = 25;
writeln(obj.memberB);

Output:

5 5
Dynamic
25

GxScript IDE screenshot

The GxScript IDE in debugging mode

GxScript provides a simple GUI library that can be used to build GUI applications. The following is a screenshot of a function graph renderer written in GxScript.

Function Graph Renderer screenshot

A function graph renderer written in GxScript