Ceylon

Appeared in:
2011
Influenced by:
Paradigm:
Typing discipline:
File extensions:
.ceylon
Versions and implementations (Collapse all | Expand all):
Programming language

Ceylon is an imperative programming language aimed at team development of large-scale projects.

The first release of the language, Ceylon M1, was released on December 20th, 2011 and provides about 80% of intended language features.

Major design principles of the language:

  • code readability: the value of this increases along with the size of development team.
  • predictability: the compiler’s and program’s behavior must be intuitive and easy to be reproduced by the programmer.
  • toolability: extensive usage of tools improves programmer’s productivity a lot, and the effect increases along with the scale of the project, so the language should provide a lot of tools, starting with IDE, and have as few features hard for tools to understand as possible.
  • modularity: once again, the larger are the programs developed, the more important their organization becomes.
  • metaprogramming: a lot of libraries and complex frameworks are based on the ability to write code which manipulates on other code.

The language syntax resembles Java and C# a lot. In fact, Ceylon is largely based on Java, but it aims to inherit successful features and eliminate or fix unsuccessful ones.

Ceylon logo
Ceylon logo

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 "...");
}