[go: nahoru, domu]

Skip to content
/ Fox Public

Fox – fast, lighweight and beginner-friendly programming language! 🦊

License

Notifications You must be signed in to change notification settings

holoisme/Fox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fox: A fast and beginner-friendly programming language.

Isn't he cute?

Overview

Fox is a simple yet fully fletched programming language, with beginner-friendly syntax and library, and finally offers a transparent API with Java !

If your user has to write some code in your Java software (e.g. Game engine, or mod support), it can be quite a challenge to make it work properly without bloating your code or reinventing the wheel; and reinventing the wheel I did. 🦊
Offering you an extremely easy way to connect your already existing Java project to Fox, it offers what we call a "transparent API" (see below) πŸ”₯

Quick sample πŸ“ƒ

var name = "John Doe";
var chars = for(c in name): c; // [J, o, h, n,  , D, o, e]

var sum = (a, b) -> a + b;
function generateRandomValues(): for(var i = 0; i < 20000; i++): random(); // creates and populates a list with random values

var instance = generateRandomValues();

var pi = 3.1415;
var pi_float = 3.1415f;

class Vector {
  constructor() {
    this.x = this.y = this.z = 0;
  }

  constructor(x, y, z) {
    this.x = x;
    this.y = y;
    this.z = z;
  }
  
  function crossProduct(other): x * other.x + y * other.y + z * other.z;
  
  static function stringify(vector) {
    var str = "";
    str += "x: " + vector.x;
    str += "y: " + vector.y;
    str += "z: " + vector.z;
    return str;
  }
}

enum TokenType {
  PLUS('+'), MINUS('-'), MULTIPLY('*'), DIVIDE('/');
  
  constructor(symbol): this.symbol = symbol;
}

Java API β˜•

Let's say you want to include the following Java class into the Fox environnement, this is how we proceed :

public class Player {

  private String name;
  private float damage;
  
  public Player(String name) {
    this.name = name;
  }
  
  public void setDamage(float damage) { this.damage = damage; }
  
  public void present() {
    System.out.println("My name is " + name + " and I do " + damage + " of damage ! Rwar!");
  }
  
  @FoxIgnore // This will assure that Fox doesn't access this
  public void someSensitiveContent() {
    /* bip boop boop */
  }
}

We can simply add the following line :

interpreter.includeClass(Player.class);

And you're done !
Your end-users have now full access to that class from the Fox scripts :

var p = new Player("John");
p.setDamage(12.5f);
p.present();

The real point of Fox is that it is an interpreted programming language, meaning that everything happens in runtime, which is perfect for Game Engines, mod support, plugin development, sandboxes etc.

Please enjoy it, I did :)