Just Another Interpreted Language

JAIL is just another interpreted language. You can execute the programs you write through a terminal/command line or embed and extend JAIL in a C program. The language is kind of a mix between C, NaaLaa and Lua. I've just begun working on it, so there's not that much more to say yet.

Currently I'm writing some standard libraries while messing around with the communication interface between C and JAIL.

Code examples

Hello world

// Import system library.
system := import("system.txt");

// Use wln to output text.
system.wln("Hello world!");

Sorting an array of numbers

system := import("system.txt");
array := import("array.txt");
math := import("math.txt");

// Create 100 random numbers.
for (i = 0, 99) {
    a[i] = math.rnd(1000);
}

// Sort the numbers with qsort, given a sorting function.
array.qsort(a, function(a, b) {
    if (a <= b) { return 1; }
    return 0;
});

// Print the numbers.
for (i = 0, 99) {
    system.wln(a[i]);
}

Self awareness

system := import("system.txt");
// Let wln reference system.wln.
wln ref system.wln;

// Creator function for things.
NewThing = function() {
  // Setup members.
  thing.x = 0; thing.y = 0;
  thing.dx = 0; thing.dy = 0;

  // Set position.
  thing.setPos = function(x, y) {
    self.x = x;
    self.y = y;
  };

  // Set speed.
  thing.setSpeed = function(dx, dy) {
    self.dx = dx;
    self.dy = dy;
  };

  // Move.
  thing.move = function() {
    self.x += self.dx;
    self.y += self.dy;
  };

  // Set intrinsic value to a "to string" function.
  thing = function() {
    // Guess the difference between "this" and "self" :)
    return "(" + tostring(this.x) + ", " + tostring(this.y) + ")";
  };

  // Return thing.
  return thing;
};

// Create and mess with a new thing.
myThing := NewThing();
myThing.setPos(320, 240);
myThing.setSpeed(2, 1);
myThing.move();
// Print current position of myThing.
wln(myThing());

Download

Linux: jail_181009.tar.gz

Windows: jail_win_x86.zip

Changelog

181009: Minor changes to Linux and Windows versions

181006: First Windows upload

180811: return now always returns a deep copy when passed a variable

180809: First upload

Contact

marcus@naalaa.com