Fork me on GitHub

Latte-lang

100% interoperable with Java™

Download Latte

Latte

Latte is a readable, flexible, simple and extensive JVM programming language. It's 100% interoperable with Java.

Features

  • Operator Binding
  • DSL
  • `fun` Syntax
  • Pre Processing define/undef
  • inner methods
  • Lambda
  • calling functional object
  • JSON Literals
  • REPL

Please visit the Document for more features

// You can try out most of these statements in REPL
// Operator Binding
list = ArrayList()
list + 1
// same as list.add(1)
list[0]
// same as list.get(0)

a = BigInteger("1")
b = BigInteger("2")

addRes = a + b
// same as a.add(b)
subRes = a - b
// same as a.subtract(b)
a << 1
// same as a.shiftLeft(1)

Atom Highlighting



a Syntax Highlighting

which help you write Latte source code conveniently

How to Build

Latte only requires JDK 1.6, and also supports JDK 9.

The project is managed by Gradle, and a build script is provided.

clone the repository, and run ./build.py.

run ./latte , and REPL will launch

and

Gradle Plugin

You can compile latte source codes or run latte scripts with the help of latte-gradle-plugin.

Click here for more info

and

REPL and Compiling

Latte provides an REPL, you can run the jar generated via automatic building, or execute lt.repl.REPL class directly.

Besides the importings of Latte, the REPL also imports :

  • lt::util::_
  • java::util::_
  • java::math::_
  • lt::repl::_

If Latte source files (*.lt) are to be compiled, you can enter the REPL mode and use Compiler() to construct a lt::repl::Compiler object. You can compile lt files in similar way in java.

compiler = Compiler()
compiler + 'class-path'
compiler >> 'output directory'
compiler compile filesInDirectory('source file directory', '.*\\.lt'.r)

// or you can chain these invocations up

Compiler() + 'class-path' >> 'output dir' compile filesInDirectory('source file directory', '.*\\.lt'.r)

Operator Binding may be helpful.