Jay

Jay is a dynamically-typed, object-oriented, prototype-based programming language that compiles to JavaScript. It is based on the Finch language created by Bob Nystrom, which itself is inspired by Smalltalk, Self, and JavaScript.

This project is a hobby that does not currently aim to serve any particular purpose other than exploration. If you have thoughts on the language, I would love to hear them. At the moment, it is almost exactly a re-implementation of Finch in JS. I hope to change the syntax slightly to be slightly more familiar for someone with a background in JS.

Because the language compiles to JavaScript, some things need to be worked out for how to bridge between the two languages. Currently, Jay names are mangled during compilation, so you do not have direct access to JS variables in the environment. Methods are compiled as functions directly attached to objects, and dispatched as normal JS method calls. Native JS types like Array and Number are bridged to their Jay equivalents.

Getting Started

Try it in your browser, or you can check out the source on Github.

A Taste of the Language

Here's a little example to get you going. This little program doesn't draw, but it will tell you what turns to make to draw a dragon curve:

// create an object and put it in a variable "dragon"
dragon <- [
  // define a "trace:" method for outputting the series of left and
  // right turns needed to draw a dragon curve.
  trace: depth {
    self trace-depth: depth turn: "R"
    write-line: "" // end the line
  }

  // the main recursive method
  trace-depth: n turn: turn {
    if: n > 0 then: {
      self trace-depth: n - 1 turn: "R"
      write: turn
      self trace-depth: n - 1 turn: "L"
    }
  }
]

// now let's try it
dragon trace: 5