Ceylon (programming language)

This is an old revision of this page, as edited by CPColin (talk | contribs) at 21:01, 15 April 2011 (Language features: just a hunch that straight quotes are more appropriate). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Ceylon Project is a programming language and SDK, created by Red Hat. It is based on the Java programming language and when it is released, will run under the Java Virtual Machine. The project is described to be what a language and SDK for business computing would look like if it were designed today, keeping in mind the successes and failures of the Java language and Java SE SDK.

Ceylon
ParadigmObject-oriented
Designed byGavin King, Red Hat
First appeared2011 (tentative)
Typing disciplineStatic, strong, safe
Filename extensions.ceylon
Websiteceylon-lang.org
Influenced by
Java

Language features

Ceylon inherits most of Java's syntax. The following is the Ceylon version of the Hello world program:

void hello() {
   writeLine("Hello World!");
}

Operator overloading

Ceylon will not provide operator overloading, as it was deemed to be generally confusing, but instead supports operator polymorphism, where an operator is a shortcut for a method of a built-in type. This is supposed to be safer and simpler than true operator overloading.

Interfaces

Interfaces are data structures that contain member definitions and not actual implementation. They are useful to define a contract between members in different types that have different implementations. Every interface is implicitly abstract.

Implementing an interface

An interface is implemented by a class using the satisfies keyword. It is allowed to implement more than one interface, in which case they are written after satisfies keyword in a comma-separated list. Ceylon allows for limited code besides for the definitions. An interface may not contain initialization logic, but can contain mixins.

shared interface Comparable<in T> {
   shared formal Comparison compare(T other);
   
   shared Boolean largerThan(T other) {
      return compare(other)==larger;
   }
   
   shared Boolean smallerThan(T other) {
      return compare(other)==smaller;
   }
   ...
}

Inheritance

Classes in Ceylon, as in Java, may only inherit from one class. Inheritance is declared using extends keyword. A class may reference itself using this keyword.

Abstract classes

Abstract classes are classes that only serve as templates and cannot be instantiated. Otherwise it is just like an ordinary class.

Only abstract classes are allowed to have abstract methods. Abstract methods do not have any implementation and must be overridden by a subclass unless it is abstract itself.

Releases

  • A compiler release is planned for late 2011.