javacoffee

0.0.2 • Public • Published

javacoffee

Coffeescript-like syntax for writing Java code.

npm install javacoffee -g

Please don't install yet. This is still in development!!!

Examples

Fibonacci

class Fibonacci
  # Print out the Fibonacci sequence for values < 50
  main
    lo = hi = 1
    println lo
    while hi < 50
      print hi
      hi = lo + hi
      lo = hi - lo

converts to

class Fibonacci {
  // Print out the Fibonacci sequence for values < 50 
  public static void main(String[] args) {
    int lo = 1;
    int hi = 1;
    System.out.println(lo);
    while (hi < 50) {
      System.out.print(hi);
      hi = lo + hi;
      lo = hi - lo;
    }
  }
}

Point

class Point
  +double x, y
  +&origin = Point 0 0
  Point @x @y
  +clear @x = @y = 0
  +distance(Point that):double
    xDiff = x - that.x
    yDiff = y - that.y
    Math.sqrt xDiff^2 + yDiff^2

converts to

class Point {
  public double x, y; 
  public static Point origin = new Point(0,0); 
  Point(double x_valuedouble y_value) {
    x = x_value; 
    y = y_value; 
  }
  public void clear() {
    this.= 0; 
    this.= 0; 
  }
  public double distance(Point that) {
    double xDiff = x - that.x; 
    double yDiff = y - that.y; 
    return Math.sqrt(xDiff * xDiff + yDiff * yDiff);
  }
}

How to compile

javacoffee file.jc -> file.class

How to develop

Install and keep gulp running

npm install
gulp

Test with the following:

node ./bin/javacoffee myFile.jc

Run tests

npm test

Filetype: .jc

Package Sidebar

Install

npm i javacoffee

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • grant