Kalang

View on GitHub

Overview

Kalang is another static type-safe language base on jvm with flexible syntax.

Features

Installation

For Linux users:

wget -O kalang-compiler-1.9.2.tar http://search.maven.org/remotecontent?filepath=site/kason/kalang/kalang-compiler/1.9.2/kalang-compiler-1.9.2.tar
tar -xvf kalang-compiler-1.9.2.tar
ln -s `pwd`/kalang-compiler-1.9.2/bin/kalangc /usr/local/bin/kalangc
ln -s `pwd`/kalang-compiler-1.9.2/bin/kalangsh /usr/local/bin/kalangsh
ln -s `pwd`/kalang-compiler-1.9.2/bin/kalangeditor /usr/local/bin/kalangeditor

For Windows users:

  1. Download latest binary distribution:http://search.maven.org/remotecontent?filepath=site/kason/kalang/kalang-compiler/1.9.2/kalang-compiler-1.9.2.zip
  2. Unzip the downloaded zip file
  3. Add the absolute path of the bin directory to the PATH environment variable

Make kalang script files executable

Linux:

  1. Use #!/usr/bin/env kalangsh as the first line of your kalang script file.
  2. Use chmod +x to make the file executable.

Windows:

Run the following commands in Command Prompt(cmd.exe)

> assoc .kls=KalangScript 
> ftype KalangScript=kalangsh.bat "%1" %*

Syntax

See Syntax

Usage

Launch kalang scripts

> kalangsh YOUR_SCRIPT_FILE YOUR_SCRIPT_ARGUMENTS

Launch kalang compiler

> kalangc SOURCE_FILE

For example:kalangc Helloworld.kl would compile Helloworld.kl in current directory.

Launch the built-in editor

> kalangeditor

Kalang Editor

Get more usages

>kalangsh --help
>kalangc --help
>kalangeditor --help

HelloWorld Example

var s = "Hello,world!";
println(s);

Dependency manage

You can declare you dependencies in kalang scripts.Kalang shell will resolve the dependencies and download the related files automatically when executing.

For example:

#repository http://maven.aliyun.com/nexus/content/groups/public/
#dependency site.kason:color-console:1.0.0

import site.kason.colorconsole.ColorConsole;
var console = ColorConsole.getDefault();
console.info("Hello,world!");

Build from source

Requirements:

Clone the source,and run

>./gradlew build

IDE/Editor plugin support