Ceylon

Implementation of programming language Ceylon

The native and the only implementation of the language, first released in December 2011. It includes a command line compiler, documentation compiler, language module and runtime, and is distributed under GNU GPL v2 license.

Besides, a Ceylon IDE is available as an Eclipse plugin; it is distributed under Eclipse Public License 1.0.

Examples:

Hello, World!:

Example for versions Ceylon M1

Let’s say we want this code to belong to helloworld.progopedia.com module. Then it has to be placed in a file /source/com/progopedia/helloworld.ceylon (the path is relative to the main directory of the program). Besides, a file named /source/com/progopedia/module.ceylon has to contain module description, for example, this one:

Module module {
 name = 'com.progopedia.helloworld';
 version = '1.0.0';
 by = {"Mariia Mykhailova"};
 dependencies = {};
 doc = "Hello, World!";
 license = 'Public domain';
}

Once the files are filled out, the program can be compiled with command ceylonc com.progopedia.helloworld and executed with ceylon com.progopedia.helloworld/1.0.0 (noting the version explicitly is a must).

void run() {
    print("Hello, World!");
}

Factorial:

Example for versions Ceylon M1

This example calculates factorials iteratively. variable keyword points out that the value of the variable fact is going to be changed later (exactly the opposite of Java keyword final). Integer data type allows to store values of factorial without overflow. The arguments of print are concatenated without any explicit operator, but for this the first and the last elements of the list to be concatenated have to be string literals.

void run() {
    variable Integer fact := 1;
    for (i in 0..16) {
        print("" i "! = " fact "");
        fact *= i + 1;
    }
}

Fibonacci numbers:

Example for versions Ceylon M1

This example calculates Fibonacci numbers iteratively.

void run() {
    variable String output := "";
    variable Integer fib1 := 0;
    variable Integer fib2 := 1;
    variable Integer fib3;
    for (i in 1..16) {
        output := "" output "" fib2 ", ";
        fib3 := fib1 + fib2;
        fib1 := fib2;
        fib2 := fib3;
    }
    print("" output "...");
}