Overview
Kalang is another static type-safe language base on jvm with flexible syntax.
Features
- Powerful scripting mode
- Auto type
- Dependency manager integration
- Static type-safe
- Flexible syntax
- Compatible with other jvm-based languages like java,groovy and so on.
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:
- Download latest binary distribution:http://search.maven.org/remotecontent?filepath=site/kason/kalang/kalang-compiler/1.9.2/kalang-compiler-1.9.2.zip
- Unzip the downloaded zip file
- Add the absolute path of the
bin
directory to thePATH
environment variable
Make kalang script files executable
Linux:
- Use
#!/usr/bin/env kalangsh
as the first line of your kalang script file. - 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
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:
- jdk8
Clone the source,and run
>./gradlew build