Compile-to-JavaScript language with macros, classes, parallel loops, and more.

JavaScript has a lot of warts in the language and while the ECMAScript community is doing a good job with its upcoming revisions, it’s still left with a lot of the old cruft. Also, for those who want to code for older browsers, all the shiny new features that the newer versions of ECMAScript provide are for all intents and purposes unreachable.

Some of the features that are available in GorillaScript that are not (or are otherwise unwieldy) in vanilla JavaScript are:

  • Constants
  • Some new operators
  • String interpolation
  • Optional parameters
  • Spread parameters
  • Maps and Sets
  • Lexical scoping in loops
  • Array slicing
  • Cascades
  • Classes
  • Destructuring
  • Topicless switch
  • Iterators
  • Promises
  • Parallel loops
  • Optional typing
  • Operators-as-functions
  • Getters and setters (only in engines that support it)
  • Curried functions
  • Generics
  • Macros
class Animal
  def constructor(@name) ->

  def eat() "$(@name) eats"

class GreatApe extends Animal
  // no constructor, Animal's is automatically called
  def eat(food="fruit") & " a " & food

class Gorilla extends GreatApe
  def constructor(@name, @favorite-food)
    // important to call the super constructor.

  def eat()

class Chimp extends GreatApe
  def eat()"banana")

let bobo = Chimp("Bobo") // new is not required on GorillaScript-made classes
assert == "Bobo eats a banana"

let toko = Gorilla("Toko", "cherry")
assert == "Toko eats a cherry"

// set a method on the Gorilla constructor
Gorilla::barrel := # @name & " throws a barrel!"

assert toko.barrel() == "Toko throws a barrel!"
Information updated 07/01/16
View Comments